File size: 1,383 Bytes
8a82485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# agent.py
import requests
import os
import re
from typing import List, Dict

def get_questions() -> List[Dict]:
    response = requests.get("https://gaia-course-api.huggingface.co/questions")
    return response.json()

def get_file(task_id: str) -> str:
    response = requests.get(f"https://gaia-course-api.huggingface.co/files/{task_id}")
    file_path = f"{task_id}.txt"
    with open(file_path, "w") as f:
        f.write(response.text)
    return file_path

def reasoning_prompt(question: str) -> str:
    """
    Chain-of-thought + Zero-shot reasoning
    """
    # ู…ุซุงู„ ุจุณูŠุท ูŠู…ูƒู† ุชุญุณูŠู†ู‡ ู„ุงุญู‚ู‹ุง
    if "capital" in question.lower():
        if "france" in question.lower():
            return "Paris"
        if "germany" in question.lower():
            return "Berlin"
    if "sum" in question.lower():
        numbers = re.findall(r"\\d+", question)
        if len(numbers) >= 2:
            return str(sum(map(int, numbers)))
    return "I don't know"

def solve_question(question: Dict) -> str:
    q_text = question.get("question", "")
    return reasoning_prompt(q_text)

def run_agent() -> List[Dict]:
    questions = get_questions()
    answers = []
    for q in questions:
        ans = solve_question(q)
        answers.append({
            "task_id": q["task_id"],
            "submitted_answer": ans.strip()
        })
    return answers