Spaces:
Sleeping
Sleeping
Create groq_compound.py
Browse files- groq_compound.py +29 -0
groq_compound.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# agents/groq_compound.py
|
| 2 |
+
from groq import Groq
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
class GroqCompoundAgent:
|
| 6 |
+
"""Wrapper around Groq’s compound-beta model for GAIA scoring."""
|
| 7 |
+
def __init__(self, model: str = "compound-beta", temperature: float = 0.2):
|
| 8 |
+
self.client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 9 |
+
self.model = model
|
| 10 |
+
self.temperature = temperature
|
| 11 |
+
|
| 12 |
+
def __call__(self, question: str) -> str:
|
| 13 |
+
resp = self.client.chat.completions.create(
|
| 14 |
+
model=self.model,
|
| 15 |
+
messages=[
|
| 16 |
+
{
|
| 17 |
+
"role": "system",
|
| 18 |
+
"content": (
|
| 19 |
+
"You are a careful GAIA solver. "
|
| 20 |
+
"Think step-by-step, use tools when helpful, "
|
| 21 |
+
"and then return ONLY the final answer on one line."
|
| 22 |
+
),
|
| 23 |
+
},
|
| 24 |
+
{"role": "user", "content": question},
|
| 25 |
+
],
|
| 26 |
+
temperature=self.temperature,
|
| 27 |
+
max_tokens=512,
|
| 28 |
+
)
|
| 29 |
+
return resp.choices[0].message.content.strip()
|