diff --git a/config.example.json b/config.example.json index ced6b0c..88db689 100644 --- a/config.example.json +++ b/config.example.json @@ -4,6 +4,7 @@ "freshrss_api_key": "your-api-password", "ollama_url": "http://your-ollama-ip:11434", "ollama_model": "gemma4:26b", + "ollama_select_model": "qwen2.5:1.5b", "yourls_url": "http://your-yourls-ip/yourls-api.php", "yourls_user": "yourls-username", "yourls_pass": "yourls-password", diff --git a/pos_briefing.py b/pos_briefing.py index 91e484f..eae7b7b 100644 --- a/pos_briefing.py +++ b/pos_briefing.py @@ -24,6 +24,10 @@ FRESHRSS_USER = config["freshrss_user"] FRESHRSS_TOKEN = config["freshrss_api_key"] OLLAMA_URL = config["ollama_url"] OLLAMA_MODEL = config["ollama_model"] +# Phase-1 story selection wants a fast model that emits a bare JSON array. +# gemma4 (the summary model) ignores the format and returns reasoning objects, +# so selection uses a small, literal model by default. +OLLAMA_SELECT_MODEL = config.get("ollama_select_model", "qwen2.5:1.5b") YOURLS_URL = config["yourls_url"] YOURLS_USER = config["yourls_user"] YOURLS_PASS = config["yourls_pass"] @@ -143,12 +147,16 @@ def summarize_news(items, count=5, length="30-50 words"): try: resp = requests.post( f"{OLLAMA_URL}/api/generate", - json={"model": OLLAMA_MODEL, "prompt": prompt_select, "stream": False, + json={"model": OLLAMA_SELECT_MODEL, "prompt": prompt_select, "stream": False, "options": {"num_ctx": 16384, "temperature": 0.1}, "format": "json"}, timeout=300 ).json() data = json.loads(resp.get("response", "[]")) - selected_indices = data if isinstance(data, list) else list(data.values())[0] + if isinstance(data, list): + selected_indices = data + elif isinstance(data, dict): + # Tolerate {"stories": [...]} or similar; pick the first list value. + selected_indices = next((v for v in data.values() if isinstance(v, list)), []) except Exception as e: print(f"[!] Selection error: {e}") selected_indices = list(range(min(count, len(items))))