Update app.py
Browse files
app.py
CHANGED
|
@@ -39,7 +39,7 @@ class LLMGAIAAgent:
|
|
| 39 |
self.tokenizer = None
|
| 40 |
self.model_name = None
|
| 41 |
|
| 42 |
-
def __call__(self, question: str) -> str:
|
| 43 |
"""Process a question and return an answer using the language model."""
|
| 44 |
print(f"Processing question: {question}")
|
| 45 |
|
|
@@ -152,7 +152,7 @@ class GAIAAgent:
|
|
| 152 |
}
|
| 153 |
print("GAIAAgent initialized with specialized question handlers.")
|
| 154 |
|
| 155 |
-
def __call__(self, question: str) -> str:
|
| 156 |
"""Process a question and return an appropriate answer."""
|
| 157 |
print(f"Processing question: {question}")
|
| 158 |
|
|
@@ -200,20 +200,20 @@ class GAIAAgent:
|
|
| 200 |
# Determine operation type
|
| 201 |
if any(op in question_lower for op in ["sum", "add", "plus", "+"]):
|
| 202 |
result = sum(int(num) for num in numbers)
|
| 203 |
-
return f"
|
| 204 |
|
| 205 |
elif any(op in question_lower for op in ["difference", "subtract", "minus", "-"]):
|
| 206 |
result = int(numbers[0]) - int(numbers[1])
|
| 207 |
-
return f"
|
| 208 |
|
| 209 |
elif any(op in question_lower for op in ["product", "multiply", "times", "*"]):
|
| 210 |
result = int(numbers[0]) * int(numbers[1])
|
| 211 |
-
return f"
|
| 212 |
|
| 213 |
elif any(op in question_lower for op in ["divide", "division", "/"]):
|
| 214 |
if int(numbers[1]) != 0:
|
| 215 |
result = int(numbers[0]) / int(numbers[1])
|
| 216 |
-
return f"
|
| 217 |
else:
|
| 218 |
return "Cannot divide by zero"
|
| 219 |
|
|
@@ -338,7 +338,12 @@ class EvaluationRunner:
|
|
| 338 |
continue
|
| 339 |
|
| 340 |
try:
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
answers_payload.append({
|
| 343 |
"task_id": task_id,
|
| 344 |
"submitted_answer": submitted_answer
|
|
|
|
| 39 |
self.tokenizer = None
|
| 40 |
self.model_name = None
|
| 41 |
|
| 42 |
+
def __call__(self, question: str, task_id: str = None) -> str:
|
| 43 |
"""Process a question and return an answer using the language model."""
|
| 44 |
print(f"Processing question: {question}")
|
| 45 |
|
|
|
|
| 152 |
}
|
| 153 |
print("GAIAAgent initialized with specialized question handlers.")
|
| 154 |
|
| 155 |
+
def __call__(self, question: str, task_id: str = None) -> str:
|
| 156 |
"""Process a question and return an appropriate answer."""
|
| 157 |
print(f"Processing question: {question}")
|
| 158 |
|
|
|
|
| 200 |
# Determine operation type
|
| 201 |
if any(op in question_lower for op in ["sum", "add", "plus", "+"]):
|
| 202 |
result = sum(int(num) for num in numbers)
|
| 203 |
+
return f"{result}"
|
| 204 |
|
| 205 |
elif any(op in question_lower for op in ["difference", "subtract", "minus", "-"]):
|
| 206 |
result = int(numbers[0]) - int(numbers[1])
|
| 207 |
+
return f"{result}"
|
| 208 |
|
| 209 |
elif any(op in question_lower for op in ["product", "multiply", "times", "*"]):
|
| 210 |
result = int(numbers[0]) * int(numbers[1])
|
| 211 |
+
return f"{result}"
|
| 212 |
|
| 213 |
elif any(op in question_lower for op in ["divide", "division", "/"]):
|
| 214 |
if int(numbers[1]) != 0:
|
| 215 |
result = int(numbers[0]) / int(numbers[1])
|
| 216 |
+
return f"{result}"
|
| 217 |
else:
|
| 218 |
return "Cannot divide by zero"
|
| 219 |
|
|
|
|
| 338 |
continue
|
| 339 |
|
| 340 |
try:
|
| 341 |
+
# Call agent with task_id parameter if supported
|
| 342 |
+
if hasattr(agent, '__code__') and 'task_id' in agent.__code__.co_varnames:
|
| 343 |
+
submitted_answer = agent(question_text, task_id)
|
| 344 |
+
else:
|
| 345 |
+
submitted_answer = agent(question_text)
|
| 346 |
+
|
| 347 |
answers_payload.append({
|
| 348 |
"task_id": task_id,
|
| 349 |
"submitted_answer": submitted_answer
|