"""Try the agent outside the Space (laptop or Colab), without submitting anything. python run_local.py --list # show the questions and their task ids python run_local.py --task 8e867cd7 # answer one question (task id prefix is enough) python run_local.py --first 3 # answer the first 3 questions python run_local.py --ask "What is 2+2?" # any ad-hoc question Answers for real tasks are written to the same answers_cache.json the Space uses. """ import argparse import gaia_api as api def main(): p = argparse.ArgumentParser() p.add_argument("--list", action="store_true") p.add_argument("--task", help="task_id or a unique prefix of it") p.add_argument("--first", type=int) p.add_argument("--ask") args = p.parse_args() if args.ask: from agent import GaiaAgent print("ANSWER:", GaiaAgent()(args.ask)) return questions = api.fetch_questions() if args.list: for q in questions: f = f" [file: {q['file_name']}]" if q.get("file_name") else "" print(f"{q['task_id'][:8]} {q['question'][:90]!r}{f}") return if args.task: chosen = [q for q in questions if q["task_id"].startswith(args.task)] else: chosen = questions[: args.first or 1] if not chosen: raise SystemExit("No matching task.") from agent import GaiaAgent agent = GaiaAgent() cache = api.load_cache() for q in chosen: path = api.download_task_file(q["task_id"], q.get("file_name", "")) answer = agent(q["question"], path) print(f"\n=== {q['task_id'][:8]} -> {answer!r}\n") cache[q["task_id"]] = {"question": q["question"], "file_name": q.get("file_name", ""), "submitted_answer": answer} api.save_cache(cache) if __name__ == "__main__": main()