Create agent.py
#174
by
dawid-lorek
- opened
agent.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from openai import OpenAI
|
2 |
+
import requests
|
3 |
+
import os
|
4 |
+
|
5 |
+
class GaiaAgent:
|
6 |
+
def __init__(self):
|
7 |
+
self.client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
8 |
+
self.instructions = (
|
9 |
+
"You are a fact-based research assistant solving GAIA benchmark questions. "
|
10 |
+
"For each question, reason step-by-step and output a single factual answer only."
|
11 |
+
)
|
12 |
+
|
13 |
+
def __call__(self, question: str) -> str:
|
14 |
+
response = self.client.chat.completions.create(
|
15 |
+
model="gpt-4-turbo",
|
16 |
+
messages=[
|
17 |
+
{"role": "system", "content": self.instructions},
|
18 |
+
{"role": "user", "content": question}
|
19 |
+
],
|
20 |
+
temperature=0.0,
|
21 |
+
)
|
22 |
+
return response.choices[0].message.content.strip()
|