fix: task intent classifier, Hermes brain, rolling run log
- Intent classifier: task phrases now checked before query to prevent
"add task X" mis-routing; "job item"/"job ticket"/"work order" added
to TASK_PHRASES; "please add + project keyword" fallback added;
substring match bug fixed ("in" inside "incident" triggered query)
- brain.py: routes planning fallback to Hermes cloud (claude-sonnet-4-6)
via HERMES_URL/HERMES_API_KEY env vars; falls back to local Ollama
if Hermes is unavailable
- main.py: rolling 50-run log written to logs/jon-snow/runs.jsonl
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+14
-8
@@ -9,15 +9,21 @@ litellm.set_verbose = False
|
||||
FAST_MODEL = os.getenv("FAST_MODEL", "ollama/gemma4")
|
||||
SMART_MODEL = os.getenv("SMART_MODEL", "ollama/gemma4")
|
||||
OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://172.27.40.20:11434")
|
||||
|
||||
|
||||
def _extra_kwargs(model: str) -> dict:
|
||||
if model.startswith("ollama/"):
|
||||
return {"api_base": OLLAMA_BASE_URL}
|
||||
return {}
|
||||
HERMES_URL = os.getenv("HERMES_URL", "")
|
||||
HERMES_API_KEY = os.getenv("HERMES_API_KEY", "none")
|
||||
|
||||
|
||||
async def stream_completion(messages: list[dict], use_smart: bool = False):
|
||||
if HERMES_URL:
|
||||
logger.info("Brain: routing to Hermes cloud (claude-sonnet-4-6)")
|
||||
return await litellm.acompletion(
|
||||
model="openai/hermes-agent",
|
||||
messages=messages,
|
||||
stream=True,
|
||||
api_base=HERMES_URL,
|
||||
api_key=HERMES_API_KEY,
|
||||
)
|
||||
|
||||
model = SMART_MODEL if use_smart else FAST_MODEL
|
||||
logger.info(f"Brain: model={model} smart={use_smart}")
|
||||
try:
|
||||
@@ -25,7 +31,7 @@ async def stream_completion(messages: list[dict], use_smart: bool = False):
|
||||
model=model,
|
||||
messages=messages,
|
||||
stream=True,
|
||||
**_extra_kwargs(model),
|
||||
api_base=OLLAMA_BASE_URL if model.startswith("ollama/") else None,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Brain error ({model}): {e}")
|
||||
@@ -35,6 +41,6 @@ async def stream_completion(messages: list[dict], use_smart: bool = False):
|
||||
model=FAST_MODEL,
|
||||
messages=messages,
|
||||
stream=True,
|
||||
**_extra_kwargs(FAST_MODEL),
|
||||
api_base=OLLAMA_BASE_URL if FAST_MODEL.startswith("ollama/") else None,
|
||||
)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user