Make Ollama chat the primary workflow

This commit is contained in:
Hermes Agent
2026-08-29 08:50:03 +10:00
parent 309947d353
commit e1f0589c3c
7 changed files with 316 additions and 87 deletions
+79
View File
@@ -139,6 +139,85 @@ class ValidationHarnessTests(unittest.TestCase):
self.assertIn("VALIDATOR 1", compiler_prompt)
self.assertIn("VALIDATOR 2", compiler_prompt)
self.assertNotIn("validator-a found no material issue\n\nvalidator-b found no material issue", final)
def test_status_omits_full_catalog_by_default(self):
with patch.object(api, "_local_tags", return_value=[]), patch.object(api, "_local_ps", return_value=[]), patch.object(
api, "_ensure_catalog", return_value={"models": [], "families": {}, "source": "test"}
), patch.object(api, "_ollama_version", return_value="test"), patch.object(
api, "_connection_snapshot", return_value=[]
), patch.object(api, "_disk_snapshot", return_value={}), patch.object(api, "_running_in_container", return_value=False), patch.object(
api, "_next_refresh", return_value=None
):
response = api.status()
self.assertNotIn("catalog", response)
self.assertNotIn("catalog_all", response)
self.assertEqual(response["catalog_count"], 0)
def test_conversation_history_excludes_current_request(self):
class Cursor:
def fetchall(self):
return [
{"role": "user", "content": "prior question", "request_id": "prior"},
{"role": "assistant", "content": "prior answer", "request_id": "prior"},
{"role": "user", "content": "current question", "request_id": "current"},
]
class Database:
def execute(self, statement, parameters=()):
self.parameters = parameters
return Cursor()
def close(self):
pass
database = Database()
with patch.object(api, "_chat_db", return_value=database):
history = api._conversation_history("conversation", exclude_request_id="current")
self.assertEqual(history, [{"role": "user", "content": "prior question"}, {"role": "assistant", "content": "prior answer"}])
def test_catalog_endpoint_returns_filtered_page(self):
catalog_rows = [
{"name": "qwen3:8b", "family": "qwen3", "capabilities": ["completion"], "is_moe": False},
{"name": "llama3:8b", "family": "llama3", "capabilities": ["completion"], "is_moe": False},
]
snapshot = {
"catalog": catalog_rows,
"catalog_all": catalog_rows,
"catalog_count": 2,
"catalog_filter_options": {"capabilities": ["completion"]},
"catalog_source": "test",
"catalog_updated_at": None,
"catalog_error": None,
}
with patch.object(api, "status", return_value=snapshot):
response = api.catalog(q="qwen", page=1, page_size=1, recent_only=False)
self.assertEqual(response["total"], 1)
self.assertEqual(response["catalog"][0]["name"], "qwen3:8b")
self.assertFalse(response["has_more"])
def test_chat_route_persists_empty_browser_history_in_job(self):
body = api.ChatRequest(primary_model="primary", message="Canonical only", history=[{"role": "user", "content": "stale"}])
fake_job = {
"request_id": "request",
"conversation_id": "conversation",
"status": "queued",
"mode": "direct",
"primary_model": "primary",
"validator_models_json": "[]",
"result_json": "{}",
"error": "",
"updated_at": 1.0,
}
created = []
with patch.object(api, "_harness_models", return_value=("primary", [], False)), patch.object(
api, "_get_chat_job", side_effect=[None, fake_job]
), patch.object(api, "_ensure_conversation"), patch.object(api, "_persist_message"), patch.object(
api, "_chat_state"
), patch.object(api, "_create_chat_job", side_effect=lambda request_id, conversation_id, value, primary, validators, harness: created.append(value)), patch.object(
api, "_submit_chat_job"
):
api.chat(body)
self.assertEqual(len(created), 1)
self.assertEqual(created[0].history, [])
if __name__ == "__main__":