File size: 873 Bytes
1c4cf5d
 
991437e
f34ea4b
a1b5009
991437e
ab4a23f
1c4cf5d
a1b5009
1c4cf5d
 
 
a1b5009
991437e
 
f34ea4b
1c4cf5d
 
 
 
a1b5009
f34ea4b
 
 
1c4cf5d
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
from tools import TOOLS
from metadata import load_metadata
from mistral_hf_wrapper import MistralInference

# Load Mistral endpoint and token from environment
API_URL = os.getenv("HF_MISTRAL_ENDPOINT")
API_TOKEN = os.getenv("HF_TOKEN")

# Load all tasks from metadata.jsonl
def load_tasks():
    return load_metadata("metadata.jsonl")

# Initialize MistralInference wrapper
mistral = MistralInference(api_url=API_URL, api_token=API_TOKEN)

# Solve a single task
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["question_id"],
        "submitted_answer": response.strip()
    }