test(evals): run the evals against any server named by EVAL_JUDGE_BASE_URL, including /v1

Ten eval files pinned their reply engine to http://localhost:11434 and the
judge only spoke Ollama's /api/tags and /api/chat, so pointing the suite at
Strata (OpenAI-compatible /v1 only) skipped or broke most evals.

- MockConfig and every eval config read EVAL_JUDGE_BASE_URL.
- The judge availability check reads /v1/models and the judge call goes
  through jarvis.llm when the URL ends in /v1; the Ollama path is unchanged.
- run_evals.sh probes /models for a /v1 URL.

The intent-judge and listener evals stay pinned to gemma4:e2b on local Ollama.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 18:49:08 +09:00
parent a45e198df6
commit 69a884b182
13 changed files with 167 additions and 50 deletions

View File

@@ -23,6 +23,8 @@ import os
# were only testing the 20B tier. Defaulting to the small tier is the
# cheapest way to stop that happening again.
JUDGE_MODEL = os.environ.get("EVAL_JUDGE_MODEL", "gemma4:e2b")
# A base URL ending in ``/v1`` (Strata, llama.cpp, Ollama's /v1) selects the
# OpenAI-compatible API, the same switch the app uses in ``jarvis.llm``.
JUDGE_BASE_URL = os.environ.get("EVAL_JUDGE_BASE_URL", "http://localhost:11434")
@@ -242,7 +244,8 @@ def create_mock_tool_run(
@dataclass
class MockConfig:
"""Minimal config object for eval tests."""
ollama_base_url: str = "http://localhost:11434"
# Read at construction so EVAL_JUDGE_BASE_URL reaches every eval.
ollama_base_url: str = field(default_factory=lambda: JUDGE_BASE_URL)
ollama_chat_model: str = "gemma4:e2b"
ollama_embed_model: str = "nomic-embed-text"
db_path: str = ":memory:"
@@ -398,16 +401,21 @@ class JudgeVerdict:
def is_judge_llm_available() -> bool:
"""Check if the judge LLM is available and the model exists."""
import requests
from jarvis.llm import is_openai_compatible
base = JUDGE_BASE_URL.rstrip('/')
try:
# First check if Ollama is running
resp = requests.get(f"{JUDGE_BASE_URL.rstrip('/')}/api/tags", timeout=2)
if resp.status_code != 200:
return False
# Check if the judge model is available
data = resp.json()
models = data.get("models", [])
model_names = [m.get("name", "").split(":")[0] for m in models]
if is_openai_compatible(base):
resp = requests.get(f"{base}/models", timeout=2)
if resp.status_code != 200:
return False
model_names = [m.get("id", "") for m in resp.json().get("data", [])]
else:
# First check if Ollama is running
resp = requests.get(f"{base}/api/tags", timeout=2)
if resp.status_code != 200:
return False
models = resp.json().get("models", [])
model_names = [m.get("name", "").split(":")[0] for m in models]
# Check if our judge model (or a variant) is available
judge_base = JUDGE_MODEL.split(":")[0]
@@ -419,13 +427,23 @@ def is_judge_llm_available() -> bool:
def call_judge_llm(system_prompt: str, user_prompt: str, timeout_sec: float = 120.0) -> Optional[str]:
"""Call the judge LLM with a prompt."""
import requests
from jarvis.llm import chat_with_messages, is_openai_compatible
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
]
if is_openai_compatible(JUDGE_BASE_URL):
data = chat_with_messages(JUDGE_BASE_URL, JUDGE_MODEL, messages, timeout_sec=timeout_sec)
if isinstance(data, dict) and isinstance(data.get("message"), dict):
return data["message"].get("content", "")
print("⚠️ Judge LLM call failed: no reply")
return None
payload = {
"model": JUDGE_MODEL,
"messages": [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
],
"messages": messages,
"stream": False,
"options": {"num_ctx": 4096},
}