FD900 commited on
Commit
4ed3db0
·
verified ·
1 Parent(s): ecb72ca

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +13 -8
agent.py CHANGED
@@ -3,18 +3,23 @@ from tools import TOOLS
3
  from metadata import load_metadata
4
  from mistral_hf_wrapper import MistralInference
5
 
6
- # Load Mistral endpoint and token from environment
7
  API_URL = os.getenv("HF_MISTRAL_ENDPOINT")
8
  API_TOKEN = os.getenv("HF_TOKEN")
9
 
10
- # Load all tasks from metadata.jsonl
11
  def load_tasks():
12
- return load_metadata("metadata.jsonl")
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- # Initialize MistralInference wrapper
15
- mistral = MistralInference(api_url=API_URL, api_token=API_TOKEN)
16
-
17
- # Solve a single task
18
  def solve_task(task, tools=TOOLS):
19
  system_prompt = "You are a helpful agent. Use reasoning, tools if needed, and return the answer only."
20
  user_prompt = task["question"]
@@ -23,6 +28,6 @@ def solve_task(task, tools=TOOLS):
23
  response = mistral.run(prompt)
24
 
25
  return {
26
- "question_id": task["question_id"],
27
  "submitted_answer": response.strip()
28
  }
 
3
  from metadata import load_metadata
4
  from mistral_hf_wrapper import MistralInference
5
 
 
6
  API_URL = os.getenv("HF_MISTRAL_ENDPOINT")
7
  API_TOKEN = os.getenv("HF_TOKEN")
8
 
 
9
  def load_tasks():
10
+ tasks = []
11
+ with open("metadata.jsonl", "r", encoding="utf-8") as f:
12
+ for line in f:
13
+ item = json.loads(line)
14
+ task_id = item.get("task_id") or item.get("question_id")
15
+ question = item.get("Question") or item.get("question")
16
+ if task_id and question:
17
+ tasks.append({
18
+ "task_id": task_id,
19
+ "question": question
20
+ })
21
+ return tasks
22
 
 
 
 
 
23
  def solve_task(task, tools=TOOLS):
24
  system_prompt = "You are a helpful agent. Use reasoning, tools if needed, and return the answer only."
25
  user_prompt = task["question"]
 
28
  response = mistral.run(prompt)
29
 
30
  return {
31
+ "task_id": task["task_id"],
32
  "submitted_answer": response.strip()
33
  }