feat: rebuild news summarizer on local Ollama
Swap Nous Portal for the newsPipeline local_llm generate path (POST /api/generate, GET /api/tags). No API key. Settings model selector lists Ollama tags; idle if the host is down.
This commit is contained in:
parent
d2bf55183c
commit
58ff43bdee
15 changed files with 336 additions and 339 deletions
|
|
@ -1,36 +0,0 @@
|
|||
"""HTTP client for the Nous inference chat completions API."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
import httpx
|
||||
|
||||
_DEFAULT_UA = "osint-dashboard-news-summarizer"
|
||||
_DEFAULT_BASE = "https://inference-api.nousresearch.com/v1"
|
||||
|
||||
|
||||
def chat(prompt, *, api_key, model, base_url, json_mode=False) -> str:
|
||||
resolved = (base_url or os.environ.get("NOUS_BASE_URL", _DEFAULT_BASE)).rstrip("/")
|
||||
url = f"{resolved}/chat/completions"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {api_key}",
|
||||
"User-Agent": os.environ.get("OSINT_USER_AGENT") or _DEFAULT_UA,
|
||||
}
|
||||
payload = {
|
||||
"model": model,
|
||||
"messages": [{"role": "user", "content": prompt}],
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 4096,
|
||||
}
|
||||
if json_mode:
|
||||
payload["response_format"] = {"type": "json_object"}
|
||||
try:
|
||||
with httpx.Client(timeout=60.0) as client:
|
||||
resp = client.post(url, headers=headers, json=payload)
|
||||
if resp.status_code == 401 or resp.status_code >= 500:
|
||||
return ""
|
||||
data = resp.json()
|
||||
return data["choices"][0]["message"]["content"]
|
||||
except Exception:
|
||||
return ""
|
||||
102
news/summerizer/ollama_client.py
Normal file
102
news/summerizer/ollama_client.py
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
"""HTTP client for a local Ollama generate API.
|
||||
|
||||
Matches the newsPipeline local_llm summarizer: POST /api/generate,
|
||||
GET /api/tags. No API key. ``LLM_URL`` may be a host, ``/api``, or
|
||||
``/api/generate`` — we normalize to the origin.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
import httpx
|
||||
|
||||
_DEFAULT_UA = "osint-dashboard-news-summarizer"
|
||||
_DEFAULT_BASE = "http://127.0.0.1:11434"
|
||||
_GENERATE_TIMEOUT = 300.0
|
||||
_TAGS_TIMEOUT = 8.0
|
||||
|
||||
_GENERATE_OPTIONS = {
|
||||
"num_predict": 4096,
|
||||
"temperature": 0.6,
|
||||
"top_p": 0.9,
|
||||
"top_k": 40,
|
||||
"num_ctx": 32768,
|
||||
"repeat_penalty": 1.1,
|
||||
}
|
||||
|
||||
|
||||
def normalize_base(url: str | None) -> str:
|
||||
"""Strip path suffixes so LLM_URL variants share one origin."""
|
||||
raw = (url or os.environ.get("LLM_URL", "") or _DEFAULT_BASE).strip()
|
||||
raw = raw.rstrip("/")
|
||||
for suffix in ("/api/generate", "/api/chat", "/api", "/v1"):
|
||||
if raw.endswith(suffix):
|
||||
raw = raw[: -len(suffix)].rstrip("/")
|
||||
break
|
||||
return raw or _DEFAULT_BASE
|
||||
|
||||
|
||||
def _headers() -> dict[str, str]:
|
||||
return {
|
||||
"User-Agent": os.environ.get("OSINT_USER_AGENT") or _DEFAULT_UA,
|
||||
"Accept": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def chat(prompt: str, *, model: str, base_url: str | None = None, json_mode: bool = False) -> str:
|
||||
"""POST /api/generate. Returns response text, or \"\" on any failure."""
|
||||
if not (model or "").strip():
|
||||
return ""
|
||||
origin = normalize_base(base_url)
|
||||
url = f"{origin}/api/generate"
|
||||
payload: dict = {
|
||||
"model": model.strip(),
|
||||
"prompt": prompt,
|
||||
"stream": False,
|
||||
"options": dict(_GENERATE_OPTIONS),
|
||||
}
|
||||
if json_mode:
|
||||
payload["format"] = "json"
|
||||
try:
|
||||
with httpx.Client(timeout=_GENERATE_TIMEOUT) as client:
|
||||
resp = client.post(url, headers=_headers(), json=payload)
|
||||
if resp.status_code == 401 or resp.status_code >= 500:
|
||||
return ""
|
||||
data = resp.json()
|
||||
text = data.get("response") if isinstance(data, dict) else None
|
||||
return text if isinstance(text, str) else ""
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
|
||||
def list_tags(base_url: str | None = None) -> list[str]:
|
||||
"""GET /api/tags model names. Empty list on failure."""
|
||||
origin = normalize_base(base_url)
|
||||
url = f"{origin}/api/tags"
|
||||
try:
|
||||
with httpx.Client(timeout=_TAGS_TIMEOUT) as client:
|
||||
resp = client.get(url, headers=_headers())
|
||||
if resp.status_code != 200:
|
||||
return []
|
||||
models = (resp.json() or {}).get("models") or []
|
||||
names: list[str] = []
|
||||
for item in models:
|
||||
if isinstance(item, dict):
|
||||
name = item.get("name") or item.get("model") or ""
|
||||
if name:
|
||||
names.append(str(name))
|
||||
return names
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
|
||||
def ollama_ready(model: str, *, base_url: str | None = None) -> bool:
|
||||
"""True when /api/tags is up and ``model`` is present (prefix match)."""
|
||||
if not (model or "").strip():
|
||||
return False
|
||||
names = list_tags(base_url)
|
||||
if not names:
|
||||
return False
|
||||
want = model.strip()
|
||||
return any(n == want or n.startswith(want) for n in names)
|
||||
|
|
@ -1,16 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Scheduler loop for the news summarizer — hourly summarize at minute :05.
|
||||
|
||||
Replaces the k8s CronJob (`5 * * * *`) with an in-compose loop. Runs once on
|
||||
boot (catches up on any articles scraped since the last summary), then fires
|
||||
at each :NEWS_SUMMARIZE_MINUTE wall-clock boundary.
|
||||
|
||||
The loop is serial, so a slow LLM pass never overlaps the next run.
|
||||
|
||||
Env (all optional, 12-factor):
|
||||
NEWS_SUMMARIZE_MINUTE minute of the hour to fire (default 5)
|
||||
NEWS_SUMMARIZE_RUN_ON_START "1" to summarize once immediately on boot (default 1)
|
||||
NOUS_API_KEY optional in env; Keys UI / api_keys also works
|
||||
LLM_URL Ollama origin; default http://127.0.0.1:11434
|
||||
SUMMARY_MODEL Ollama tag (else app_settings)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
|
@ -46,13 +41,10 @@ def run_summarize() -> None:
|
|||
|
||||
|
||||
def main() -> None:
|
||||
if not os.getenv("NOUS_API_KEY", "").strip():
|
||||
logger.warning(
|
||||
"NOUS_API_KEY unset in env — will read api_keys on each run; idle if both empty"
|
||||
)
|
||||
llm_url = os.getenv("LLM_URL", "").strip() or "http://127.0.0.1:11434"
|
||||
logger.info(
|
||||
"news summarizer loop starting (minute=%s, run_on_start=%s)",
|
||||
MINUTE, RUN_ON_START,
|
||||
"news summarizer loop starting (minute=%s, run_on_start=%s, llm_url=%s)",
|
||||
MINUTE, RUN_ON_START, llm_url,
|
||||
)
|
||||
if RUN_ON_START:
|
||||
run_summarize()
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
#!/usr/bin/env python3
|
||||
"""News summarizer — Nous map-reduce of scraped articles into brief/ticker/map.
|
||||
"""News summarizer — local Ollama map-reduce into brief/ticker/map.
|
||||
|
||||
Reads articles scraped within the last hour from the shared `articles` table,
|
||||
maps them with Nous (per-article English fact blocks), reduces to one JSON
|
||||
object (summary_en + ticker + map_items), and stores the brief in
|
||||
maps them with a local Ollama model (per-article English fact blocks), reduces
|
||||
to one JSON object (summary_en + ticker + map_items), and stores the brief in
|
||||
`article_summaries` plus flagged rows in `news_items`. Tables live in the
|
||||
EXISTING osint-db (alembic 003_news + 005_news_items, idempotent).
|
||||
|
||||
Everything is env-driven (12-factor). Secrets/config are resolved at the start
|
||||
of each summarize_news() — env wins, else api_keys / app_settings:
|
||||
LLM is the newsPipeline local_llm path: Ollama POST /api/generate. No API key.
|
||||
|
||||
DB_HOST / DB_NAME / DB_USER / DB_PASSWORD / DB_PORT PostgreSQL (osint-db)
|
||||
NOUS_API_KEY Nous Portal key (else api_keys.name='NOUS_API_KEY')
|
||||
NOUS_BASE_URL default https://inference-api.nousresearch.com/v1
|
||||
SUMMARY_MODEL default Hermes-4.3-36B (else app_settings)
|
||||
LLM_URL Ollama origin (default http://127.0.0.1:11434)
|
||||
SUMMARY_MODEL Ollama tag (else app_settings; default qwen3:30b-a3b)
|
||||
BATCH_SIZE articles per map-phase batch (default 50)
|
||||
SUMMARY_WINDOW_HOURS look-back window in hours (default 1)
|
||||
OSINT_USER_AGENT default osint-dashboard-news-summarizer
|
||||
|
|
@ -21,11 +19,6 @@ of each summarize_news() — env wins, else api_keys / app_settings:
|
|||
SUMMARY_PROMPT override reduce-phase prompt (uses {final_input})
|
||||
NEWS_SUMMARIZE_FORCE "1" to ignore the current-UTC-hour idempotency skip
|
||||
INCLUDE_FUTURES "1" to prepend live futures prices (default 0)
|
||||
|
||||
The futures/markets coupling from the original pipeline is gated behind
|
||||
INCLUDE_FUTURES and OFF by default — it is irrelevant to the OSINT dashboard
|
||||
and pulled yfinance into the image. Re-enable by installing yfinance and
|
||||
setting INCLUDE_FUTURES=1.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
|
@ -37,7 +30,7 @@ from datetime import datetime
|
|||
import psycopg2
|
||||
|
||||
from intel import parse_reduce_json, select_map, select_ticker
|
||||
from nous_client import chat
|
||||
from ollama_client import chat, ollama_ready
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
||||
logger = logging.getLogger("news.summarizer")
|
||||
|
|
@ -51,8 +44,8 @@ DB_CONFIG = {
|
|||
"port": int(os.getenv("DB_PORT", "5432")),
|
||||
}
|
||||
|
||||
DEFAULT_NOUS_BASE_URL = "https://inference-api.nousresearch.com/v1"
|
||||
DEFAULT_SUMMARY_MODEL = "Hermes-4.3-36B"
|
||||
DEFAULT_LLM_URL = "http://127.0.0.1:11434"
|
||||
DEFAULT_SUMMARY_MODEL = "qwen3:30b-a3b"
|
||||
BATCH_SIZE = int(os.getenv("BATCH_SIZE", "50"))
|
||||
SUMMARY_WINDOW_HOURS = int(os.getenv("SUMMARY_WINDOW_HOURS", "1"))
|
||||
INCLUDE_FUTURES = os.getenv("INCLUDE_FUTURES", "0").lower() in ("1", "true", "yes")
|
||||
|
|
@ -134,20 +127,6 @@ def _kv(conn, table, name) -> str:
|
|||
return (row[0] or "").strip() if row else ""
|
||||
|
||||
|
||||
def resolve_api_key() -> str:
|
||||
env = os.getenv("NOUS_API_KEY", "").strip()
|
||||
if env:
|
||||
return env
|
||||
try:
|
||||
conn = psycopg2.connect(**DB_CONFIG)
|
||||
try:
|
||||
return _kv(conn, "api_keys", "NOUS_API_KEY")
|
||||
finally:
|
||||
conn.close()
|
||||
except Exception: # noqa: BLE001
|
||||
return ""
|
||||
|
||||
|
||||
def resolve_model() -> str:
|
||||
env = os.getenv("SUMMARY_MODEL", "").strip()
|
||||
if env:
|
||||
|
|
@ -164,15 +143,15 @@ def resolve_model() -> str:
|
|||
|
||||
|
||||
def resolve_base_url() -> str:
|
||||
return os.getenv("NOUS_BASE_URL", DEFAULT_NOUS_BASE_URL).strip() or DEFAULT_NOUS_BASE_URL
|
||||
return os.getenv("LLM_URL", DEFAULT_LLM_URL).strip() or DEFAULT_LLM_URL
|
||||
|
||||
|
||||
def call_llm(prompt: str, *, api_key: str, model: str, base_url: str, json_mode: bool = False) -> str:
|
||||
"""Send a prompt to Nous chat completions and return the text (\"\" on failure)."""
|
||||
if not api_key:
|
||||
logger.warning("NOUS_API_KEY not set — skipping LLM call")
|
||||
def call_llm(prompt: str, *, model: str, base_url: str, json_mode: bool = False) -> str:
|
||||
"""Send a prompt to Ollama generate and return the text (\"\" on failure)."""
|
||||
if not model:
|
||||
logger.warning("SUMMARY_MODEL empty — skipping LLM call")
|
||||
return ""
|
||||
return chat(prompt, api_key=api_key, model=model, base_url=base_url, json_mode=json_mode)
|
||||
return chat(prompt, model=model, base_url=base_url, json_mode=json_mode)
|
||||
|
||||
|
||||
# ── Futures (legacy, gated) ────────────────────────────────────────────────
|
||||
|
|
@ -426,11 +405,16 @@ def summarize_news() -> None:
|
|||
)
|
||||
return
|
||||
|
||||
api_key = resolve_api_key()
|
||||
model = resolve_model()
|
||||
base_url = resolve_base_url()
|
||||
if not api_key:
|
||||
logger.warning("NOUS_API_KEY unset in env and api_keys — idle this run")
|
||||
if not model:
|
||||
logger.warning("SUMMARY_MODEL empty — idle this run")
|
||||
return
|
||||
if not ollama_ready(model, base_url=base_url):
|
||||
logger.warning(
|
||||
"Ollama not ready at %s (model %s missing or /api/tags down) — idle this run",
|
||||
base_url, model,
|
||||
)
|
||||
return
|
||||
|
||||
articles = get_recent_news()
|
||||
|
|
@ -452,7 +436,6 @@ def summarize_news() -> None:
|
|||
)
|
||||
summary = call_llm(
|
||||
build_map_prompt(batch),
|
||||
api_key=api_key,
|
||||
model=model,
|
||||
base_url=base_url,
|
||||
json_mode=False,
|
||||
|
|
@ -468,7 +451,6 @@ def summarize_news() -> None:
|
|||
logger.info("reduce phase over %d partial summaries", len(partial_summaries))
|
||||
master_raw = call_llm(
|
||||
build_master_prompt(final_input),
|
||||
api_key=api_key,
|
||||
model=model,
|
||||
base_url=base_url,
|
||||
json_mode=True,
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
from unittest.mock import MagicMock
|
||||
|
||||
import httpx
|
||||
from nous_client import chat
|
||||
|
||||
DEFAULT_UA = "osint-dashboard-news-summarizer"
|
||||
BASE = "https://inference-api.nousresearch.com/v1"
|
||||
|
||||
|
||||
def _ok_response(content="hello"):
|
||||
resp = MagicMock()
|
||||
resp.status_code = 200
|
||||
resp.json.return_value = {"choices": [{"message": {"content": content}}]}
|
||||
return resp
|
||||
|
||||
|
||||
def _install_fake(monkeypatch, post_impl):
|
||||
captured = {}
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self, timeout=None, **kwargs):
|
||||
captured["timeout"] = timeout
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc):
|
||||
return False
|
||||
|
||||
def post(self, url, *, headers=None, json=None, **kwargs):
|
||||
captured["url"] = url
|
||||
captured["headers"] = headers
|
||||
captured["json"] = json
|
||||
return post_impl(url, headers, json)
|
||||
|
||||
monkeypatch.setattr(httpx, "Client", FakeClient)
|
||||
return captured
|
||||
|
||||
|
||||
def test_posts_chat_completions_with_auth_body_and_returns_content(monkeypatch):
|
||||
captured = _install_fake(monkeypatch, lambda *a: _ok_response("the-content"))
|
||||
out = chat(
|
||||
"summarize this",
|
||||
api_key="secret-key",
|
||||
model="hermes-3",
|
||||
base_url=BASE,
|
||||
)
|
||||
assert out == "the-content"
|
||||
assert captured["url"] == f"{BASE}/chat/completions"
|
||||
assert captured["headers"]["Authorization"] == "Bearer secret-key"
|
||||
assert captured["headers"]["User-Agent"] == DEFAULT_UA
|
||||
assert captured["json"]["model"] == "hermes-3"
|
||||
assert captured["json"]["messages"] == [{"role": "user", "content": "summarize this"}]
|
||||
assert captured["json"]["temperature"] == 0.2
|
||||
assert captured["json"]["max_tokens"] == 4096
|
||||
assert "response_format" not in captured["json"]
|
||||
|
||||
|
||||
def test_user_agent_equals_osint_user_agent_env(monkeypatch):
|
||||
monkeypatch.setenv("OSINT_USER_AGENT", "custom-ua/2.0")
|
||||
captured = _install_fake(monkeypatch, lambda *a: _ok_response("ok"))
|
||||
chat("p", api_key="k", model="m", base_url=BASE)
|
||||
assert captured["headers"]["User-Agent"] == "custom-ua/2.0"
|
||||
|
||||
|
||||
def test_json_mode_sets_response_format(monkeypatch):
|
||||
captured = _install_fake(monkeypatch, lambda *a: _ok_response("{}"))
|
||||
chat("p", api_key="k", model="m", base_url=BASE, json_mode=True)
|
||||
assert captured["json"]["response_format"] == {"type": "json_object"}
|
||||
|
||||
|
||||
def test_401_returns_empty_string(monkeypatch):
|
||||
def post_impl(*a):
|
||||
resp = MagicMock()
|
||||
resp.status_code = 401
|
||||
return resp
|
||||
|
||||
_install_fake(monkeypatch, post_impl)
|
||||
assert chat("p", api_key="bad", model="m", base_url=BASE) == ""
|
||||
|
||||
|
||||
def test_5xx_returns_empty_string(monkeypatch):
|
||||
def post_impl(*a):
|
||||
resp = MagicMock()
|
||||
resp.status_code = 503
|
||||
return resp
|
||||
|
||||
_install_fake(monkeypatch, post_impl)
|
||||
assert chat("p", api_key="k", model="m", base_url=BASE) == ""
|
||||
|
||||
|
||||
def test_timeout_returns_empty_string(monkeypatch):
|
||||
def post_impl(*a):
|
||||
raise httpx.TimeoutException("timed out")
|
||||
|
||||
_install_fake(monkeypatch, post_impl)
|
||||
assert chat("p", api_key="k", model="m", base_url=BASE) == ""
|
||||
111
news/summerizer/tests/test_ollama_client.py
Normal file
111
news/summerizer/tests/test_ollama_client.py
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
from unittest.mock import MagicMock
|
||||
|
||||
import httpx
|
||||
from ollama_client import chat, list_tags, normalize_base, ollama_ready
|
||||
|
||||
DEFAULT_UA = "osint-dashboard-news-summarizer"
|
||||
BASE = "http://127.0.0.1:11434"
|
||||
|
||||
|
||||
def _ok_response(content="hello"):
|
||||
resp = MagicMock()
|
||||
resp.status_code = 200
|
||||
resp.json.return_value = {"response": content}
|
||||
return resp
|
||||
|
||||
|
||||
def _install_fake(monkeypatch, post_impl=None, get_impl=None):
|
||||
captured = {}
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self, timeout=None, **kwargs):
|
||||
captured["timeout"] = timeout
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc):
|
||||
return False
|
||||
|
||||
def post(self, url, *, headers=None, json=None, **kwargs):
|
||||
captured["url"] = url
|
||||
captured["headers"] = headers
|
||||
captured["json"] = json
|
||||
if post_impl is None:
|
||||
raise AssertionError("post not expected")
|
||||
return post_impl(url, headers, json)
|
||||
|
||||
def get(self, url, *, headers=None, **kwargs):
|
||||
captured["url"] = url
|
||||
captured["headers"] = headers
|
||||
if get_impl is None:
|
||||
raise AssertionError("get not expected")
|
||||
return get_impl(url, headers)
|
||||
|
||||
monkeypatch.setattr(httpx, "Client", FakeClient)
|
||||
return captured
|
||||
|
||||
|
||||
def test_normalize_base_strips_generate_path():
|
||||
assert normalize_base("http://ollama:11434/api/generate") == "http://ollama:11434"
|
||||
assert normalize_base("http://ollama:11434/api/") == "http://ollama:11434"
|
||||
assert normalize_base("http://ollama:11434") == "http://ollama:11434"
|
||||
|
||||
|
||||
def test_posts_generate_and_returns_response(monkeypatch):
|
||||
captured = _install_fake(monkeypatch, post_impl=lambda *a: _ok_response("the-content"))
|
||||
out = chat("summarize this", model="qwen3:30b-a3b", base_url=BASE)
|
||||
assert out == "the-content"
|
||||
assert captured["url"] == f"{BASE}/api/generate"
|
||||
assert captured["headers"]["User-Agent"] == DEFAULT_UA
|
||||
assert captured["json"]["model"] == "qwen3:30b-a3b"
|
||||
assert captured["json"]["prompt"] == "summarize this"
|
||||
assert captured["json"]["stream"] is False
|
||||
assert "format" not in captured["json"]
|
||||
assert captured["json"]["options"]["num_ctx"] == 32768
|
||||
assert captured["timeout"] == 300.0
|
||||
|
||||
|
||||
def test_json_mode_sets_format_json(monkeypatch):
|
||||
captured = _install_fake(monkeypatch, post_impl=lambda *a: _ok_response("{}"))
|
||||
chat("p", model="m", base_url=BASE, json_mode=True)
|
||||
assert captured["json"]["format"] == "json"
|
||||
|
||||
|
||||
def test_empty_model_returns_empty(monkeypatch):
|
||||
assert chat("p", model="", base_url=BASE) == ""
|
||||
|
||||
|
||||
def test_5xx_returns_empty_string(monkeypatch):
|
||||
def post_impl(*a):
|
||||
resp = MagicMock()
|
||||
resp.status_code = 503
|
||||
return resp
|
||||
|
||||
_install_fake(monkeypatch, post_impl=post_impl)
|
||||
assert chat("p", model="m", base_url=BASE) == ""
|
||||
|
||||
|
||||
def test_timeout_returns_empty_string(monkeypatch):
|
||||
def post_impl(*a):
|
||||
raise httpx.TimeoutException("timed out")
|
||||
|
||||
_install_fake(monkeypatch, post_impl=post_impl)
|
||||
assert chat("p", model="m", base_url=BASE) == ""
|
||||
|
||||
|
||||
def test_list_tags_and_ready(monkeypatch):
|
||||
def get_impl(*a):
|
||||
resp = MagicMock()
|
||||
resp.status_code = 200
|
||||
resp.json.return_value = {
|
||||
"models": [{"name": "qwen3:30b-a3b"}, {"name": "llama3.2:latest"}],
|
||||
}
|
||||
return resp
|
||||
|
||||
captured = _install_fake(monkeypatch, get_impl=get_impl)
|
||||
names = list_tags(BASE)
|
||||
assert names == ["qwen3:30b-a3b", "llama3.2:latest"]
|
||||
assert captured["url"] == f"{BASE}/api/tags"
|
||||
assert ollama_ready("qwen3:30b-a3b", base_url=BASE) is True
|
||||
assert ollama_ready("missing", base_url=BASE) is False
|
||||
Loading…
Reference in a new issue