fix: rss classifier think-tag stripping, briefing calendar dict access, embed empty-string guard
- rss_classifier: strip <think>...</think> blocks (qwen3 reasoning output) before JSON parse; use strict=False for control chars; bump timeout 30s→120s - briefing_pipeline: list_events returns dicts not Event objects — fix attribute access (.all_day/.start_dt/.title) to dict access - embeddings: guard upsert_note_embedding and semantic_search_notes against empty-string input to prevent Ollama embed 400 errors Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ Called from rss.py after new items are stored — fire-and-forget.
|
||||
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import httpx
|
||||
@@ -37,7 +38,7 @@ async def _llm_classify(prompt: str, model: str) -> str:
|
||||
"stream": False,
|
||||
"options": {"num_ctx": 2048, "temperature": 0.0},
|
||||
}
|
||||
async with httpx.AsyncClient(timeout=30.0) as client:
|
||||
async with httpx.AsyncClient(timeout=120.0) as client:
|
||||
resp = await client.post(f"{Config.OLLAMA_URL}/api/chat", json=payload)
|
||||
resp.raise_for_status()
|
||||
return resp.json().get("message", {}).get("content", "")
|
||||
@@ -75,13 +76,17 @@ async def classify_items_batch(
|
||||
|
||||
try:
|
||||
raw = await _llm_classify(prompt, model)
|
||||
# Strip <think>...</think> blocks emitted by reasoning models (e.g. qwen3)
|
||||
raw = re.sub(r"<think>.*?</think>", "", raw, flags=re.DOTALL)
|
||||
# Extract JSON from response (LLM may wrap it in markdown)
|
||||
raw = raw.strip()
|
||||
if raw.startswith("```"):
|
||||
raw = raw.split("```")[1]
|
||||
if raw.startswith("json"):
|
||||
raw = raw[4:]
|
||||
parsed = json.loads(raw)
|
||||
raw = raw.strip()
|
||||
# Allow control characters that may appear in LLM-generated JSON strings
|
||||
parsed = json.loads(raw, strict=False)
|
||||
return {int(k): v for k, v in parsed.items() if isinstance(v, list)}
|
||||
except Exception:
|
||||
logger.warning("RSS classification failed", exc_info=True)
|
||||
|
||||
Reference in New Issue
Block a user