diff --git a/homelab-ai-bot/llm.py b/homelab-ai-bot/llm.py index fd9ff3d2..9c9918de 100644 --- a/homelab-ai-bot/llm.py +++ b/homelab-ai-bot/llm.py @@ -204,7 +204,18 @@ def _call_openrouter(messages: list, api_key: str, use_tools: bool = True, if use_ollama: url = f"{OLLAMA_BASE}/v1/chat/completions" headers = {"Content-Type": "application/json"} - timeout = 180 + timeout = 120 + for msg in reversed(payload.get("messages", [])): + if msg.get("role") == "user": + content = msg.get("content", "") + if isinstance(content, str) and "/no_think" not in content: + msg["content"] = content + " /no_think" + elif isinstance(content, list): + for item in content: + if item.get("type") == "text" and "/no_think" not in item.get("text", ""): + item["text"] = item["text"] + " /no_think" + break + break else: url = f"{OPENROUTER_BASE}/chat/completions" headers = {"Authorization": f"Bearer {api_key}"}