File size: 1,910 Bytes
332e48b
eb7cc40
332e48b
 
 
 
75e40db
2a7c7e6
 
75e40db
2a7c7e6
 
 
9eb69da
392825a
2a7c7e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392825a
 
 
 
 
 
2a7c7e6
392825a
75e40db
392825a
 
d48b3cc
2a7c7e6
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
import os
from openai import OpenAI

class GaiaAgent:
    def __init__(self):
        self.client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
        self.instructions = (
            "You are a research assistant solving GAIA benchmark questions using 2022 English Wikipedia knowledge.\n"
            "For each question, reason step-by-step and only return the final answer in exact format."
        )
        self.task_templates = {
            "8e867cd7-cff9-4e6c-867a-ff5ddc2550be": self.q_mercedes_sosa_albums
        }

    def __call__(self, question: str, task_id: str = None) -> str:
        if task_id in self.task_templates:
            return self.task_templates[task_id](question)
        else:
            return "[SKIPPED: Task not yet implemented in Agent V9]"

    def q_mercedes_sosa_albums(self, question: str) -> str:
        prompt = (
            "You are a research assistant using 2022 English Wikipedia knowledge.\n"
            "\nQUESTION:\n"
            "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)?\n"
            "\nFollow this step-by-step reasoning chain:\n"
            "Step 1: Identify all studio albums by Mercedes Sosa.\n"
            "Step 2: Filter the albums published between 2000 and 2009 inclusive.\n"
            "Step 3: Count them.\n"
            "Step 4: Return only the count as a number (no text, no explanation).\n"
            "\nANSWER:"
        )

        try:
            response = self.client.chat.completions.create(
                model="gpt-4-turbo",
                messages=[
                    {"role": "system", "content": self.instructions},
                    {"role": "user", "content": prompt}
                ],
                temperature=0.0
            )
            return response.choices[0].message.content.strip()
        except Exception as e:
            return f"[AGENT ERROR: {e}]"