Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -26,13 +26,9 @@ class MultiModelManager:
|
|
| 26 |
"""Manages multiple Groq models with rotation and fallback."""
|
| 27 |
|
| 28 |
def __init__(self):
|
| 29 |
-
#
|
| 30 |
self.models = [
|
| 31 |
-
"openai/gpt-oss-120b",
|
| 32 |
-
"openai/gpt-oss-20b", # GPT OSS 20B - Fast, 1000 tok/s
|
| 33 |
-
"meta-llama/llama-4-scout-17b-16e-instruct", # Llama 4 Scout - Multimodal
|
| 34 |
-
"qwen/qwen3-32b", # Qwen 3 32B - Advanced reasoning
|
| 35 |
-
"moonshotai/kimi-k2-instruct", # Kimi K2 - 1T params, agentic
|
| 36 |
]
|
| 37 |
|
| 38 |
self.api_key = os.getenv("GROQ_API_KEY")
|
|
@@ -123,17 +119,16 @@ class ExcelToTextTool(Tool):
|
|
| 123 |
|
| 124 |
|
| 125 |
class GaiaAgent:
|
| 126 |
-
"""An agent
|
| 127 |
|
| 128 |
def __init__(self, strategy: str = "primary"):
|
| 129 |
"""
|
| 130 |
-
Initialize agent with
|
| 131 |
|
| 132 |
Args:
|
| 133 |
-
strategy:
|
| 134 |
-
or "adaptive" (choose based on task complexity)
|
| 135 |
"""
|
| 136 |
-
print(f"✅ GaiaAgent initialized with
|
| 137 |
|
| 138 |
self.strategy = strategy
|
| 139 |
self.model_manager = MultiModelManager()
|
|
@@ -157,13 +152,8 @@ class GaiaAgent:
|
|
| 157 |
self._reinitialize_agent()
|
| 158 |
|
| 159 |
def _reinitialize_agent(self):
|
| 160 |
-
"""Reinitialize the agent with
|
| 161 |
-
|
| 162 |
-
model = self.model_manager.get_primary_model()
|
| 163 |
-
elif self.strategy == "rotate":
|
| 164 |
-
model = self.model_manager.get_next_model()
|
| 165 |
-
else: # adaptive
|
| 166 |
-
model = self.model_manager.get_model_by_complexity("high")
|
| 167 |
|
| 168 |
print(f"🤖 Using model: {self.model_manager.current_model_name}")
|
| 169 |
|
|
@@ -202,15 +192,6 @@ class GaiaAgent:
|
|
| 202 |
print(f"🔹 Task ID: {task_id}")
|
| 203 |
print(f"🔹 Question: {question[:100]}...")
|
| 204 |
|
| 205 |
-
# Adaptive strategy: choose model based on complexity
|
| 206 |
-
if self.strategy == "adaptive":
|
| 207 |
-
complexity = self._detect_complexity(question)
|
| 208 |
-
model = self.model_manager.get_model_by_complexity(complexity)
|
| 209 |
-
print(f"🎯 Detected complexity: {complexity}")
|
| 210 |
-
self._reinitialize_agent()
|
| 211 |
-
elif self.strategy == "rotate":
|
| 212 |
-
self._reinitialize_agent()
|
| 213 |
-
|
| 214 |
# Try to get answer with retry logic
|
| 215 |
answer = None
|
| 216 |
for attempt in range(self.max_retries + 1):
|
|
@@ -237,13 +218,6 @@ class GaiaAgent:
|
|
| 237 |
return answer
|
| 238 |
|
| 239 |
|
| 240 |
-
# Example usage
|
| 241 |
-
|
| 242 |
-
#
|
| 243 |
-
# agent = GaiaAgent(strategy="primary")
|
| 244 |
-
|
| 245 |
-
# Strategy 2: Rotate between models to distribute load
|
| 246 |
-
# agent = GaiaAgent(strategy="rotate")
|
| 247 |
-
|
| 248 |
-
# Strategy 3: Adaptive - choose model based on question complexity
|
| 249 |
-
# agent = GaiaAgent(strategy="adaptive")
|
|
|
|
| 26 |
"""Manages multiple Groq models with rotation and fallback."""
|
| 27 |
|
| 28 |
def __init__(self):
|
| 29 |
+
# Using only GPT-OSS 120B as requested
|
| 30 |
self.models = [
|
| 31 |
+
"openai/gpt-oss-120b", # GPT OSS 120B - Most powerful
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
]
|
| 33 |
|
| 34 |
self.api_key = os.getenv("GROQ_API_KEY")
|
|
|
|
| 119 |
|
| 120 |
|
| 121 |
class GaiaAgent:
|
| 122 |
+
"""An agent using only GPT-OSS 120B for maximum performance."""
|
| 123 |
|
| 124 |
def __init__(self, strategy: str = "primary"):
|
| 125 |
"""
|
| 126 |
+
Initialize agent with GPT-OSS 120B.
|
| 127 |
|
| 128 |
Args:
|
| 129 |
+
strategy: Kept for compatibility but only uses GPT-OSS 120B
|
|
|
|
| 130 |
"""
|
| 131 |
+
print(f"✅ GaiaAgent initialized with GPT-OSS 120B.")
|
| 132 |
|
| 133 |
self.strategy = strategy
|
| 134 |
self.model_manager = MultiModelManager()
|
|
|
|
| 152 |
self._reinitialize_agent()
|
| 153 |
|
| 154 |
def _reinitialize_agent(self):
|
| 155 |
+
"""Reinitialize the agent with GPT-OSS 120B."""
|
| 156 |
+
model = self.model_manager.get_primary_model()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
print(f"🤖 Using model: {self.model_manager.current_model_name}")
|
| 159 |
|
|
|
|
| 192 |
print(f"🔹 Task ID: {task_id}")
|
| 193 |
print(f"🔹 Question: {question[:100]}...")
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
# Try to get answer with retry logic
|
| 196 |
answer = None
|
| 197 |
for attempt in range(self.max_retries + 1):
|
|
|
|
| 218 |
return answer
|
| 219 |
|
| 220 |
|
| 221 |
+
# Example usage:
|
| 222 |
+
# Simply initialize the agent - it will always use GPT-OSS 120B
|
| 223 |
+
# agent = GaiaAgent()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|