Files
APAW/scripts/test_real_api.py
Deploy Bot 26362c7359 fix: milestone 78 — remove USE_MOCK and hardcoded API key
- Remove _DEFAULT_KEY from real-fit-engine.py, run-focused-eval.py, test_real_api.py
- Replace USE_MOCK env var with DRY_RUN --dry-run CLI flag
- Create tests/mocks/ollama_mock.py for isolated mock testing
- Remove stale glm-5.1 from DEFAULT_MODELS and docs
- Update .env.example with OLLAMA_HOST and OLLAMA_KEY

Issues: #123
2026-06-01 12:25:50 +01:00

35 lines
1.3 KiB
Python

#!/usr/bin/env python3
import sys, os
# OLLAMA_KEY must be set via environment variable or .env file — never hardcode
if not os.environ.get("OLLAMA_KEY"):
print("[FATAL] OLLAMA_KEY not set. Set it via environment variable or .env file.", file=sys.stderr)
sys.exit(1)
os.environ.setdefault("OLLAMA_HOST", "https://ollama.com/v1")
sys.path.insert(0, "scripts")
from real_fit_engine import call_ollama, evaluate_response, init_db, import_from_evolution, generate_prompts
import sqlite3
init_db()
import_from_evolution()
generate_prompts()
conn = sqlite3.connect("agent-evolution/data/real-fit.db")
row = conn.execute("SELECT system_prompt, user_prompt, expected_keywords, rubric FROM test_prompts WHERE agent_name = ?", ("code-skeptic",)).fetchone()
conn.close()
if row:
system, user, expected, rubric = row
print("=== REAL Ollama: code-skeptic x kimi-k2.6 ===")
resp, latency, tokens = call_ollama("kimi-k2.6", system, user, expected)
print(f"Latency: {latency}ms")
print(f"Tokens: {tokens}")
print("Response (first 300 chars):")
print(resp[:300])
print("\n...")
ev = evaluate_response(resp, expected, rubric)
print(f"Score: {ev['total']:.1f}")
print(f"Explanation: {ev['explanation']}")
else:
print("No prompt found for code-skeptic")