Ubik80 commited on
Commit
269ccad
·
verified ·
1 Parent(s): 1a99730

Delete agent.py

Browse files
Files changed (1) hide show
  1. agent.py +0 -66
agent.py DELETED
@@ -1,66 +0,0 @@
1
-
2
- import os
3
- import requests
4
- from smolagents import CodeAgent, tool, OpenAIServerModel
5
-
6
- API_URL = "https://agents-course-unit4-scoring.hf.space"
7
-
8
- @tool
9
- def fetch_questions() -> list:
10
- """
11
- Fetch the full list of GAIA evaluation questions.
12
-
13
- Returns:
14
- list: A list of question dicts, each with 'task_id' and 'question'.
15
- """
16
- resp = requests.get(f"{API_URL}/questions", timeout=15)
17
- resp.raise_for_status()
18
- return resp.json()
19
-
20
- @tool
21
- def fetch_random_question() -> dict:
22
- """
23
- Fetch a single random GAIA question.
24
-
25
- Returns:
26
- dict: A dict with keys 'task_id' and 'question'.
27
- """
28
- resp = requests.get(f"{API_URL}/random-question", timeout=15)
29
- resp.raise_for_status()
30
- return resp.json()
31
-
32
- @tool
33
- def submit_answers(username: str, agent_code: str, answers: list) -> dict:
34
- """
35
- Submit the agent's answers to GAIA and get the scoring.
36
-
37
- Args:
38
- username (str): HF username for the submission.
39
- agent_code (str): URL of your Space repo for verification.
40
- answers (list): List of dicts, each with 'task_id' and 'submitted_answer'.
41
-
42
- Returns:
43
- dict: Contains 'score', 'correct_count', 'total_attempted', 'message', etc.
44
- """
45
- payload = {"username": username, "agent_code": agent_code, "answers": answers}
46
- resp = requests.post(f"{API_URL}/submit", json=payload, timeout=60)
47
- resp.raise_for_status()
48
- return resp.json()
49
-
50
- def create_agent() -> CodeAgent:
51
- """
52
- Build and return a configured CodeAgent using OpenAI GPT-3.5 Turbo.
53
- Requires OPENAI_API_KEY in the environment.
54
-
55
- Returns:
56
- CodeAgent: Configured with GAIA tools.
57
- """
58
- # Initialize the model for CodeAgent
59
- # Use GPT-4 for improved performance (ensure your API key has GPT-4 access)
60
- model = OpenAIServerModel(model_id="gpt-4")
61
- # Instantiate CodeAgent with default prompt and provided tools
62
- agent = CodeAgent(
63
- tools=[fetch_questions, fetch_random_question, submit_answers],
64
- model=model
65
- )
66
- return agent