diff --git a/CHANGELOG.md b/CHANGELOG.md index da755bc..ed97c54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- Aligns the default local Ollama answer model with the city-core installer + pull set by using `gemma4:e4b` when `CIVICCODE_OLLAMA_MODEL` is unset. - Hardened the existing CivicClerk ordinance-event intake route with an optional shared-intake authorization header for city-core service-to-service handoff calls, without broadening trusted staff-header access for the rest of diff --git a/civiccode/ai_answer.py b/civiccode/ai_answer.py index 58d1f2e..4ac86d8 100644 --- a/civiccode/ai_answer.py +++ b/civiccode/ai_answer.py @@ -31,7 +31,7 @@ def load_local_llm_config() -> LocalLLMConfig | None: return LocalLLMConfig( provider="ollama", base_url=(base_url or "http://127.0.0.1:11434").rstrip("/"), - model=os.environ.get("CIVICCODE_OLLAMA_MODEL", "llama3.1:8b").strip() or "llama3.1:8b", + model=os.environ.get("CIVICCODE_OLLAMA_MODEL", "gemma4:e4b").strip() or "gemma4:e4b", timeout_seconds=float(os.environ.get("CIVICCODE_OLLAMA_TIMEOUT_SECONDS", "20")), ) diff --git a/tests/test_milestone_7_citation_grounded_qa.py b/tests/test_milestone_7_citation_grounded_qa.py index 242ef48..93c2857 100644 --- a/tests/test_milestone_7_citation_grounded_qa.py +++ b/tests/test_milestone_7_citation_grounded_qa.py @@ -12,6 +12,8 @@ from conftest import build_suite_staff_headers from httpx import ASGITransport, AsyncClient +from civiccode.ai_answer import load_local_llm_config + ROOT = Path(__file__).resolve().parents[1] @@ -193,6 +195,17 @@ def log_message(self, format: str, *args: object) -> None: # noqa: A002 assert "Source:" in payload["answer"] +def test_local_ollama_default_model_matches_city_core_pull(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("CIVICCODE_AI_MODE", "ollama") + monkeypatch.delenv("CIVICCODE_OLLAMA_MODEL", raising=False) + monkeypatch.delenv("CIVICCODE_OLLAMA_URL", raising=False) + + config = load_local_llm_config() + + assert config is not None + assert config.model == "gemma4:e4b" + + def _ollama_generate_available() -> bool: body = json.dumps( {