Fix summary LLM call: use raw chat text, not classifier-JSON parsing
client._chat() JSON-parses every response (for the classifier), so the plain-text
summary was rejected ("model did not return JSON") even though the model returned
a perfect summary. Split out _raw_content() and add chat_text() for free-form
output; summaries use it. _chat keeps parsing for classification.
This commit is contained in:
@@ -72,9 +72,7 @@ def summarize_article(client: LocalModelClient, title: str, snippet: str, body_t
|
||||
material = (body_text or snippet or title or "")[:4000]
|
||||
user = f"Title: {title}\n\nArticle text:\n{material}\n\nWrite the summary."
|
||||
messages = [{"role": "system", "content": _SYSTEM}, {"role": "user", "content": user}]
|
||||
resp = client._chat(client._build_payload(messages, None))
|
||||
content = (resp.get("choices") or [{}])[0].get("message", {}).get("content") or ""
|
||||
return content.strip()[:1200]
|
||||
return (client.chat_text(messages) or "").strip()[:1200]
|
||||
|
||||
|
||||
def get_summary(conn: sqlite3.Connection, article_id: int) -> str | None:
|
||||
|
||||
Reference in New Issue
Block a user