FD900's picture
Update agent.py
4ed3db0 verified
raw
history blame
1.07 kB
import os
from tools import TOOLS
from metadata import load_metadata
from mistral_hf_wrapper import MistralInference
API_URL = os.getenv("HF_MISTRAL_ENDPOINT")
API_TOKEN = os.getenv("HF_TOKEN")
def load_tasks():
tasks = []
with open("metadata.jsonl", "r", encoding="utf-8") as f:
for line in f:
item = json.loads(line)
task_id = item.get("task_id") or item.get("question_id")
question = item.get("Question") or item.get("question")
if task_id and question:
tasks.append({
"task_id": task_id,
"question": question
})
return tasks
def solve_task(task, tools=TOOLS):
system_prompt = "You are a helpful agent. Use reasoning, tools if needed, and return the answer only."
user_prompt = task["question"]
prompt = f"<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n{user_prompt} [/INST]"
response = mistral.run(prompt)
return {
"task_id": task["task_id"],
"submitted_answer": response.strip()
}