mikarantanen/Tier3
0
1"""2Local iteration harness. Runs the agent over a handful of real GAIA questions3WITHOUT submitting, so you can eyeball answers and tune before spending a submit.4 5Usage:6 export MODEL_ID=gpt-4o-mini7 export OPENAI_API_KEY=sk-... # key for your chosen model8 python test_local.py # first 3 questions9 python test_local.py 8 # first 8 questions10"""11 12import os13import sys14import requests15 16# Importing agent forces stdout/stderr to UTF-8 (via agent._ensure_utf8_output),17# so non-ASCII tool output doesn't crash smolagents' logger on a Windows console.18from agent import GaiaAgent19 20API_URL = os.environ.get(21 "SCORING_API_URL", "https://agents-course-unit4-scoring.hf.space"22)23 24 25def main():26 n = int(sys.argv[1]) if len(sys.argv) > 1 else 327 questions = requests.get(f"{API_URL}/questions", timeout=30).json()28 agent = GaiaAgent()29 30 for item in questions[:n]:31 task_id = item.get("task_id")32 q = item.get("question")33 print("=" * 80)34 print(f"TASK {task_id}")35 print(f"Q: {q}")36 try:37 ans = agent(q, task_id=task_id)38 except Exception as e: # noqa: BLE00139 ans = f"AGENT ERROR: {e}"40 print(f"ANSWER: {ans!r}")41 42 43if __name__ == "__main__":44 main()45 