Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -3,26 +3,27 @@ import json
|
|
| 3 |
|
| 4 |
from tools import TOOLS
|
| 5 |
from metadata import load_metadata
|
| 6 |
-
from
|
| 7 |
|
|
|
|
| 8 |
API_URL = os.getenv("HF_MISTRAL_URL")
|
| 9 |
API_TOKEN = os.getenv("HF_TOKEN")
|
| 10 |
|
| 11 |
-
HEADERS = {
|
| 12 |
-
"Authorization": f"Bearer {API_TOKEN}",
|
| 13 |
-
"Content-Type": "application/json"
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
# Load all tasks from metadata.jsonl
|
| 17 |
def load_tasks():
|
| 18 |
return load_metadata("metadata.jsonl")
|
| 19 |
|
|
|
|
|
|
|
|
|
|
| 20 |
# Solve a single task
|
| 21 |
def solve_task(task, tools=TOOLS):
|
| 22 |
system_prompt = "You are a helpful agent. Use reasoning, tools if needed, and return the answer only."
|
| 23 |
user_prompt = task["question"]
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
return {
|
| 27 |
"task_id": task["question_id"],
|
| 28 |
"submitted_answer": response.strip()
|
|
|
|
| 3 |
|
| 4 |
from tools import TOOLS
|
| 5 |
from metadata import load_metadata
|
| 6 |
+
from mistral_hf_wrapper import MistralInference
|
| 7 |
|
| 8 |
+
# Load environment variables
|
| 9 |
API_URL = os.getenv("HF_MISTRAL_URL")
|
| 10 |
API_TOKEN = os.getenv("HF_TOKEN")
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Load all tasks from metadata.jsonl
|
| 13 |
def load_tasks():
|
| 14 |
return load_metadata("metadata.jsonl")
|
| 15 |
|
| 16 |
+
# Initialize Mistral
|
| 17 |
+
mistral = MistralInference()
|
| 18 |
+
|
| 19 |
# Solve a single task
|
| 20 |
def solve_task(task, tools=TOOLS):
|
| 21 |
system_prompt = "You are a helpful agent. Use reasoning, tools if needed, and return the answer only."
|
| 22 |
user_prompt = task["question"]
|
| 23 |
|
| 24 |
+
prompt = f"<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n{user_prompt} [/INST]"
|
| 25 |
+
response = mistral.run(prompt)
|
| 26 |
+
|
| 27 |
return {
|
| 28 |
"task_id": task["question_id"],
|
| 29 |
"submitted_answer": response.strip()
|