From 6cd500393064f7e7fd19d08d4383e203079300e6 Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Fri, 10 Jul 2026 12:11:54 -0500 Subject: [PATCH] feat(api): route the npc role to its own model --- api/app/config.py | 4 ++++ api/app/routing.py | 6 ++++++ api/tests/test_routing.py | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/api/app/config.py b/api/app/config.py index 4981f57..4d07e1e 100644 --- a/api/app/config.py +++ b/api/app/config.py @@ -18,5 +18,9 @@ def narrator_model() -> str: return os.environ.get("OLLAMA_NARRATOR_MODEL", "qwen3.5:latest") +def npc_model() -> str: + return os.environ.get("OLLAMA_NPC_MODEL", "qwen3.5:latest") + + def call_log_path() -> str | None: return os.environ.get("CALL_LOG_PATH") or None diff --git a/api/app/routing.py b/api/app/routing.py index 98d9dba..8cf1669 100644 --- a/api/app/routing.py +++ b/api/app/routing.py @@ -22,4 +22,10 @@ def for_role(role: str) -> RoleConfig: options={"temperature": 0.8, "top_p": 0.9, "num_predict": 300}, think=False, # qwen3.x thinking OFF; harmless on non-thinking models ) + if role == "npc": + return RoleConfig( + model=config.npc_model(), + options={"temperature": 0.8, "top_p": 0.9, "num_predict": 320}, + think=False, + ) raise KeyError(f"no routing for role: {role}") diff --git a/api/tests/test_routing.py b/api/tests/test_routing.py index d455598..fe1eef4 100644 --- a/api/tests/test_routing.py +++ b/api/tests/test_routing.py @@ -19,3 +19,11 @@ def test_env_overrides_model(monkeypatch): def test_unknown_role_raises(): with pytest.raises(KeyError): for_role("wizard") + + +def test_npc_role_routes_to_npc_model(monkeypatch): + monkeypatch.setenv("OLLAMA_NPC_MODEL", "some-npc-model") + cfg = for_role("npc") + assert cfg.model == "some-npc-model" + assert cfg.think is False + assert "num_predict" in cfg.options