Refactor GAIA results handling and improve error reporting
Browse files- Updated `gaia_results.csv` to reflect new error messages for failed LLM invocations, marking them as incorrect.
- Modified `gaia_results.json` to set the score to 0 and correct count to 0 due to the new error handling.
- Introduced an improvement plan in `improvement_plan.md` outlining strategies to enhance GAIA's performance, including upgrading to multimodal LLMs, improving image and document processing, and refining web tools.
- Added a new test script `test_react.py` to validate the agent's functionality with a simple math question, ensuring the integration of the Python REPL.
- .claude/settings old.json +13 -1
- __pycache__/agent.cpython-39.pyc +0 -0
- acli.exe +3 -0
- agent.py +226 -619
- gaia_results.csv +29 -20
- gaia_results.json +42 -42
- improvement_plan.md +73 -0
- test_react.py +18 -0
.claude/settings old.json
CHANGED
|
@@ -21,4 +21,16 @@
|
|
| 21 |
"ANTHROPIC_MODEL": "nvidia_nim/z-ai/glm4.7"
|
| 22 |
|
| 23 |
}
|
| 24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
"ANTHROPIC_MODEL": "nvidia_nim/z-ai/glm4.7"
|
| 22 |
|
| 23 |
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
// // proxy
|
| 27 |
+
// {
|
| 28 |
+
// "env": {
|
| 29 |
+
// "ANTHROPIC_BASE_URL": "http://localhost:8082/v1",
|
| 30 |
+
// // "ANTHROPIC_AUTH_TOKEN": "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",
|
| 31 |
+
// // "ANTHROPIC_AUTH_TOKEN": "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",
|
| 32 |
+
// "ANTHROPIC_API_KEY": "",
|
| 33 |
+
// "ANTHROPIC_MODEL": "proxy_model"
|
| 34 |
+
|
| 35 |
+
// }
|
| 36 |
+
// }
|
__pycache__/agent.cpython-39.pyc
CHANGED
|
Binary files a/__pycache__/agent.cpython-39.pyc and b/__pycache__/agent.cpython-39.pyc differ
|
|
|
acli.exe
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a6886298944bd38dc799e126a7ab39c074f0109c984994f513a2fea196211c3
|
| 3 |
+
size 17513984
|
agent.py
CHANGED
|
@@ -7,24 +7,50 @@ from typing import TypedDict, List, Union
|
|
| 7 |
|
| 8 |
import pandas as pd
|
| 9 |
import fitz
|
| 10 |
-
from
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
-
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage
|
| 13 |
from langchain_core.tools import tool
|
| 14 |
from langchain_groq import ChatGroq
|
| 15 |
from langgraph.graph import StateGraph, START, END
|
| 16 |
-
from langchain_community.document_loaders import WikipediaLoader
|
| 17 |
from langchain_community.document_loaders.image import UnstructuredImageLoader
|
| 18 |
|
| 19 |
load_dotenv()
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
@tool
|
| 22 |
def web_search(keywords: str) -> str:
|
| 23 |
-
"""Search the web.
|
|
|
|
|
|
|
| 24 |
try:
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
except Exception as e:
|
| 29 |
return f"SEARCH_ERROR: {e}"
|
| 30 |
|
|
@@ -39,23 +65,60 @@ def wiki_search(query: str) -> str:
|
|
| 39 |
|
| 40 |
@tool
|
| 41 |
def read_file(path: str) -> str:
|
| 42 |
-
"""Read a local file.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if not path or not os.path.exists(path):
|
| 44 |
return "ERROR: File not found"
|
| 45 |
try:
|
| 46 |
ext = os.path.splitext(path)[1].lower()
|
| 47 |
-
if ext in {".
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
except Exception as e:
|
| 57 |
return f"ERROR: {e}"
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
@tool
|
| 60 |
def get_youtube_transcript(url: str) -> str:
|
| 61 |
"""Get YouTube transcript."""
|
|
@@ -77,52 +140,6 @@ def reverse_text(text: str) -> str:
|
|
| 77 |
"""Reverse the given text."""
|
| 78 |
return text[::-1]
|
| 79 |
|
| 80 |
-
@tool
|
| 81 |
-
def analyze_image(path: str) -> str:
|
| 82 |
-
"""Analyze an image file and describe its contents."""
|
| 83 |
-
try:
|
| 84 |
-
from PIL import Image
|
| 85 |
-
import pytesseract
|
| 86 |
-
|
| 87 |
-
img = Image.open(path)
|
| 88 |
-
|
| 89 |
-
# Try OCR first
|
| 90 |
-
try:
|
| 91 |
-
text = pytesseract.image_to_string(img)
|
| 92 |
-
if text and len(text.strip()) > 10:
|
| 93 |
-
return f"OCR TEXT:\n{text[:2000]}"
|
| 94 |
-
except Exception as ocr_err:
|
| 95 |
-
print(f"OCR failed: {ocr_err}")
|
| 96 |
-
|
| 97 |
-
# Try detecting chess board pattern
|
| 98 |
-
try:
|
| 99 |
-
import numpy as np
|
| 100 |
-
img_array = np.array(img)
|
| 101 |
-
if len(img_array.shape) == 3:
|
| 102 |
-
gray = np.mean(img_array, axis=2)
|
| 103 |
-
else:
|
| 104 |
-
gray = img_array
|
| 105 |
-
|
| 106 |
-
h, w = gray.shape
|
| 107 |
-
if h > 100 and w > 100:
|
| 108 |
-
corner_check = [
|
| 109 |
-
gray[50:100, 50:100].mean(),
|
| 110 |
-
gray[50:100, w-100:w-50].mean(),
|
| 111 |
-
gray[h-100:h-50, 50:100].mean(),
|
| 112 |
-
gray[h-100:h-50, w-100:w-50].mean()
|
| 113 |
-
]
|
| 114 |
-
if min(corner_check) < 100 and max(corner_check) > 150:
|
| 115 |
-
return "Chess board detected. Cannot parse position without advanced computer vision."
|
| 116 |
-
except:
|
| 117 |
-
pass
|
| 118 |
-
|
| 119 |
-
desc = f"Image: {img.size[0]}x{img.size[1]}, Mode: {img.mode}"
|
| 120 |
-
if img.size[0] > 200 and img.size[1] > 200:
|
| 121 |
-
desc += "\nImage appears to be a photograph or diagram"
|
| 122 |
-
|
| 123 |
-
return desc
|
| 124 |
-
except Exception as e:
|
| 125 |
-
return f"IMAGE_ERROR: {e}"
|
| 126 |
|
| 127 |
@tool
|
| 128 |
def transcribe_audio(path: str) -> str:
|
|
@@ -135,588 +152,178 @@ def transcribe_audio(path: str) -> str:
|
|
| 135 |
except Exception as e:
|
| 136 |
return f"AUDIO_TRANSCRIPTION_ERROR: {e}"
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
year_match = re.search(r'(\d{4})\s*[-–to]+\s*(\d{4})', query)
|
| 150 |
-
years = year_match.groups() if year_match else None
|
| 151 |
-
|
| 152 |
-
year_instruction = ""
|
| 153 |
-
if years:
|
| 154 |
-
year_instruction = f"""
|
| 155 |
-
YEAR FILTER: The question asks for items between {years[0]} and {years[1]} (inclusive).
|
| 156 |
-
- Only count items with years clearly in this range"""
|
| 157 |
-
|
| 158 |
-
question_type = ""
|
| 159 |
-
if is_sum:
|
| 160 |
-
question_type = "SUMMATION: Add up all the numbers found."
|
| 161 |
-
elif is_highest:
|
| 162 |
-
question_type = "HIGHEST: Find the maximum/largest number."
|
| 163 |
-
elif is_lowest:
|
| 164 |
-
question_type = "LOWEST: Find the minimum/smallest number."
|
| 165 |
-
elif is_count:
|
| 166 |
-
question_type = "COUNT: Carefully count items matching the criteria."
|
| 167 |
-
|
| 168 |
-
try:
|
| 169 |
-
prompt = f"""Analyze these search results to answer a numerical question.
|
| 170 |
-
|
| 171 |
-
QUESTION: {query}
|
| 172 |
-
SEARCH RESULTS:
|
| 173 |
-
{search_results[:3000]}
|
| 174 |
-
{year_instruction}
|
| 175 |
-
|
| 176 |
-
TASK: {question_type}
|
| 177 |
-
1. Extract relevant data from the search results
|
| 178 |
-
2. Be precise about year filters if applicable
|
| 179 |
-
3. Calculate the answer
|
| 180 |
-
4. Provide your answer as JUST a number
|
| 181 |
-
|
| 182 |
-
FINAL ANSWER: """
|
| 183 |
-
|
| 184 |
-
response = _invoke_llm([HumanMessage(content=prompt)])
|
| 185 |
-
return response.content if hasattr(response, 'content') else str(response)
|
| 186 |
-
except Exception as e:
|
| 187 |
-
return f"ANALYSIS_ERROR: {e}"
|
| 188 |
-
|
| 189 |
-
tools = [web_search, wiki_search, read_file, get_youtube_transcript, reverse_text, analyze_image, transcribe_audio, analyze_counting_question]
|
| 190 |
tools_by_name = {t.name: t for t in tools}
|
| 191 |
|
| 192 |
class AgentState(TypedDict):
|
| 193 |
-
messages: List[Union[HumanMessage, AIMessage, SystemMessage]]
|
|
|
|
| 194 |
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
try:
|
| 198 |
-
model = ChatGroq(model=
|
| 199 |
-
|
|
|
|
| 200 |
except Exception as e:
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
print(f"LLM Error: {e}")
|
| 204 |
-
return
|
| 205 |
-
|
| 206 |
-
def _invoke_llm_fallback(messages, fallback_count=0):
|
| 207 |
-
"""Try fallback models"""
|
| 208 |
-
# Try Groq with smaller model
|
| 209 |
-
try:
|
| 210 |
-
model = ChatGroq(model="llama-3.1-8b-instant", temperature=0)
|
| 211 |
-
return model.invoke(messages)
|
| 212 |
-
except Exception as e:
|
| 213 |
-
print(f"Groq small failed: {e}")
|
| 214 |
-
|
| 215 |
-
# Wait and retry main model
|
| 216 |
-
if fallback_count < 2:
|
| 217 |
-
import time
|
| 218 |
-
wait_time = 30 * (fallback_count + 1)
|
| 219 |
-
print(f"Waiting {wait_time}s...")
|
| 220 |
-
time.sleep(wait_time)
|
| 221 |
-
try:
|
| 222 |
-
model = ChatGroq(model="llama-3.3-70b-versatile", temperature=0)
|
| 223 |
-
return model.invoke(messages)
|
| 224 |
-
except:
|
| 225 |
-
pass
|
| 226 |
-
|
| 227 |
-
return type('obj', (object,), {'content': 'ALL_MODELS_FAILED'})()
|
| 228 |
-
|
| 229 |
-
def extract_numbers_from_text(text: str) -> List[str]:
|
| 230 |
-
"""Extract all numbers from text that could be answers."""
|
| 231 |
-
patterns = [
|
| 232 |
-
r'(\d+)\s+(?:albums?|songs?|items?|years?|times?|players?|medals?|athletes?|votes?)',
|
| 233 |
-
r'(?:total|count|number)[:\s]+(\d+)',
|
| 234 |
-
r'(?:^|\s)(\d+)(?:\s|$|\.)',
|
| 235 |
-
r'(\d{4})\s*[-–]\s*(\d{4})',
|
| 236 |
-
]
|
| 237 |
-
numbers = []
|
| 238 |
-
for pattern in patterns:
|
| 239 |
-
matches = re.findall(pattern, text, re.I | re.M)
|
| 240 |
-
numbers.extend(matches)
|
| 241 |
-
return list(set(numbers))
|
| 242 |
-
|
| 243 |
-
def is_counting_question(question: str) -> bool:
|
| 244 |
-
"""Check if the question is asking for a count (not max/min)."""
|
| 245 |
-
question_lower = question.lower()
|
| 246 |
-
count_phrases = ['how many', 'number of', 'count', 'total']
|
| 247 |
-
is_count = any(phrase in question_lower for phrase in count_phrases)
|
| 248 |
-
if not is_count:
|
| 249 |
-
return False
|
| 250 |
-
# Don't treat "highest", "maximum", "lowest", "minimum", "least" as counting questions
|
| 251 |
-
# UNLESS the question starts with "how many" - then it IS a counting question
|
| 252 |
-
# e.g. "How many at bats did the Yankee with the most walks have?" IS counting
|
| 253 |
-
if 'how many' in question_lower:
|
| 254 |
-
return True
|
| 255 |
-
if 'highest' in question_lower or 'maximum' in question_lower or 'lowest' in question_lower or 'minimum' in question_lower or 'least' in question_lower:
|
| 256 |
-
return False
|
| 257 |
-
return is_count
|
| 258 |
-
|
| 259 |
-
def is_year_range_count(question: str) -> bool:
|
| 260 |
-
"""Check if question asks about something in a year range."""
|
| 261 |
-
return bool(re.search(r'between\s+\d{4}\s+and\s+\d{4}', question.lower()))
|
| 262 |
-
|
| 263 |
-
@tool
|
| 264 |
-
def count_year_range_items(query: str, search_results: str) -> str:
|
| 265 |
-
"""Count items from a specific year range."""
|
| 266 |
-
year_match = re.search(r'between\s+(\d{4})\s+and\s+(\d{4})', query.lower())
|
| 267 |
-
if not year_match:
|
| 268 |
-
return "No year range found"
|
| 269 |
-
|
| 270 |
-
start_year = int(year_match.group(1))
|
| 271 |
-
end_year = int(year_match.group(2))
|
| 272 |
-
|
| 273 |
-
# Determine what's being counted
|
| 274 |
-
item_type = "items"
|
| 275 |
-
if "albums" in query.lower():
|
| 276 |
-
item_type = "albums"
|
| 277 |
-
elif "songs" in query.lower():
|
| 278 |
-
item_type = "songs"
|
| 279 |
-
elif "movies" in query.lower():
|
| 280 |
-
item_type = "movies"
|
| 281 |
-
|
| 282 |
-
try:
|
| 283 |
-
model = ChatGroq(model="llama-3.3-70b-versatile", temperature=0)
|
| 284 |
-
prompt = f"""Count {item_type} released between {start_year} and {end_year} (inclusive).
|
| 285 |
-
|
| 286 |
-
Search results:
|
| 287 |
-
{search_results[:4000]}
|
| 288 |
-
|
| 289 |
-
Find the exact {item_type} with release years in range {start_year}-{end_year}.
|
| 290 |
-
List each one with its year, then give the count.
|
| 291 |
-
|
| 292 |
-
FINAL ANSWER: """
|
| 293 |
-
|
| 294 |
-
response = _invoke_llm([HumanMessage(content=prompt)])
|
| 295 |
-
return response.content if hasattr(response, 'content') else str(response)
|
| 296 |
-
except Exception as e:
|
| 297 |
-
return f"ERROR: {e}"
|
| 298 |
-
|
| 299 |
-
tools = [web_search, wiki_search, read_file, get_youtube_transcript, reverse_text, analyze_image, transcribe_audio, analyze_counting_question, count_year_range_items]
|
| 300 |
|
|
|
|
| 301 |
def is_reversed_text(question: str) -> bool:
|
| 302 |
"""Check if text appears to be reversed."""
|
| 303 |
words = question.split()
|
| 304 |
if len(words) < 3:
|
| 305 |
return False
|
| 306 |
-
# Check if reversing makes it readable
|
| 307 |
reversed_test = question[::-1]
|
| 308 |
-
# Check if reversed version has more valid words
|
| 309 |
-
orig_words = set(w.lower() for w in words if len(w) > 3)
|
| 310 |
-
rev_words = set(w.lower() for w in reversed_test.split() if len(w) > 3)
|
| 311 |
-
# Simple heuristic: if reversed has valid common words, it's reversed
|
| 312 |
common_words = {'the', 'is', 'in', 'of', 'and', 'what', 'how', 'for', 'with', 'from', 'this', 'that'}
|
| 313 |
-
|
| 314 |
rev_valid = len([w for w in rev_words if w in common_words])
|
|
|
|
|
|
|
| 315 |
return rev_valid > orig_valid
|
| 316 |
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
# Look for FINAL ANSWER: pattern first
|
| 320 |
-
match = re.search(r'FINAL ANSWER:\s*(.+?)(?:\n|$)', content, re.IGNORECASE)
|
| 321 |
-
if match:
|
| 322 |
-
return match.group(1).strip()
|
| 323 |
-
# Return content as-is if no pattern found
|
| 324 |
-
return content.strip()
|
| 325 |
-
return str(content)
|
| 326 |
-
|
| 327 |
-
def answer_question(state: AgentState) -> AgentState:
|
| 328 |
messages = state["messages"]
|
| 329 |
-
user_msg = messages[-1].content if messages else ""
|
| 330 |
|
| 331 |
-
# Pre-
|
| 332 |
-
if
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
|
|
|
| 336 |
|
| 337 |
-
#
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
]
|
| 373 |
-
|
| 374 |
-
for sq in search_queries:
|
| 375 |
-
try:
|
| 376 |
-
yt_search = web_search.invoke({"keywords": sq})
|
| 377 |
-
if yt_search and "NO_RESULTS" not in yt_search:
|
| 378 |
-
messages.append(HumanMessage(content=f"YOUTUBE SEARCH {sq}:\n{yt_search}"))
|
| 379 |
-
except:
|
| 380 |
-
pass
|
| 381 |
-
|
| 382 |
-
# For known video IDs, do topic-specific search
|
| 383 |
-
if video_id == "L1vXCYZAYYM":
|
| 384 |
-
# BBC Spy in the Snow - bird species (petrel, Adelie penguins, emperor penguin chicks = 3 species)
|
| 385 |
-
try:
|
| 386 |
-
bbc_search = web_search.invoke({"keywords": '"Spy in the Snow" "petrel" "Adelie" "emperor penguin" species'})
|
| 387 |
-
messages.append(HumanMessage(content=f"VIDEO CONTENT:\n{bbc_search}"))
|
| 388 |
-
except:
|
| 389 |
-
pass
|
| 390 |
-
elif video_id == "1htKBjuUWec":
|
| 391 |
-
# Stargate SG-1 Urgo - Teal'c says "It's extremely hot"
|
| 392 |
-
try:
|
| 393 |
-
sg_search = web_search.invoke({"keywords": 'Stargate SG-1 Urgo episode Teal\'c "hot" response quote'})
|
| 394 |
-
messages.append(HumanMessage(content=f"VIDEO CONTENT:\n{sg_search}"))
|
| 395 |
-
except:
|
| 396 |
-
pass
|
| 397 |
-
|
| 398 |
-
# Also search for the video topic
|
| 399 |
-
try:
|
| 400 |
-
topic_search = web_search.invoke({"keywords": f'{video_id} youtube video'})
|
| 401 |
-
messages.append(HumanMessage(content=f"VIDEO SEARCH:\n{topic_search}"))
|
| 402 |
-
except:
|
| 403 |
-
pass
|
| 404 |
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
|
|
|
|
|
|
| 415 |
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
result = web_search.invoke({"keywords": term})
|
| 419 |
-
messages.append(HumanMessage(content=f"WIKI SEARCH {term}:\n{result}"))
|
| 420 |
-
except:
|
| 421 |
-
pass
|
| 422 |
-
except Exception as e:
|
| 423 |
-
messages.append(HumanMessage(content=f"WIKI SEARCH ERROR: {e}"))
|
| 424 |
-
|
| 425 |
-
try:
|
| 426 |
-
search_result = web_search.invoke({"keywords": user_msg[:200]})
|
| 427 |
-
messages.append(HumanMessage(content=f"WEB SEARCH:\n{search_result}"))
|
| 428 |
-
except Exception as e:
|
| 429 |
-
messages.append(HumanMessage(content=f"WEB SEARCH ERROR: {e}"))
|
| 430 |
-
|
| 431 |
-
# Do wiki search if not already done
|
| 432 |
-
if "wikipedia" not in user_msg.lower():
|
| 433 |
try:
|
| 434 |
-
|
| 435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
except Exception as e:
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
# Include all search-related messages
|
| 444 |
-
if any(prefix in msg.content for prefix in ["WEB SEARCH:", "WIKIPEDIA:", "YOUTUBE", "FILE", "VIDEO", "COUNTING"]):
|
| 445 |
-
all_search_results += msg.content + "\n"
|
| 446 |
-
# Also check for "no results" messages
|
| 447 |
-
elif "no search results" in msg.content.lower() or "no_resul" in msg.content.lower():
|
| 448 |
-
all_search_results += msg.content + "\n"
|
| 449 |
-
|
| 450 |
-
# If no useful search results at all, do a fallback web search
|
| 451 |
-
if not all_search_results.strip() or "no search results" in all_search_results.lower():
|
| 452 |
-
try:
|
| 453 |
-
fallback = web_search.invoke({"keywords": user_msg[:200]})
|
| 454 |
-
all_search_results = f"WEB SEARCH:\n{fallback}"
|
| 455 |
-
messages.append(HumanMessage(content=all_search_results))
|
| 456 |
-
except:
|
| 457 |
-
pass
|
| 458 |
-
|
| 459 |
-
# Special handling for known questions BEFORE counting check
|
| 460 |
-
# Q19 - Excel food sales
|
| 461 |
-
if "excel" in user_msg.lower() and "food" in user_msg.lower() and "drinks" in user_msg.lower():
|
| 462 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 89706.00"))
|
| 463 |
-
return {"messages": messages}
|
| 464 |
-
|
| 465 |
-
# Q10 - Pie recipe audio (this is handled via direct hint)
|
| 466 |
-
if "strawberry pie" in user_msg.lower():
|
| 467 |
-
messages.append(HumanMessage(content="FINAL ANSWER: cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries"))
|
| 468 |
-
return {"messages": messages}
|
| 469 |
-
|
| 470 |
-
# Q12 - Python output (also known: 0)
|
| 471 |
-
if "python" in user_msg.lower() and ("output" in user_msg.lower() or ".py" in user_msg.lower()):
|
| 472 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 0"))
|
| 473 |
-
return {"messages": messages}
|
| 474 |
-
|
| 475 |
-
# Q1 - Mercedes Sosa albums - MUST BE BEFORE counting check
|
| 476 |
-
if "Mercedes Sosa" in user_msg and "between" in user_msg and "2000" in user_msg:
|
| 477 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 3"))
|
| 478 |
-
return {"messages": messages}
|
| 479 |
-
|
| 480 |
-
# Q14 - Audio question with page numbers
|
| 481 |
-
if "sick" in user_msg.lower() and "friday" in user_msg.lower() and "study" in user_msg.lower():
|
| 482 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 132, 133, 134, 197, 245"))
|
| 483 |
-
return {"messages": messages}
|
| 484 |
-
|
| 485 |
-
# Q20 - Malko Competition Claus
|
| 486 |
-
if "malko" in user_msg.lower() or ("competition" in user_msg.lower() and "recipient" in user_msg.lower()):
|
| 487 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Claus"))
|
| 488 |
-
return {"messages": messages}
|
| 489 |
-
|
| 490 |
-
# Q13 - Baseball: Ensure proper search for Yankee walks question
|
| 491 |
-
if "Yankee" in user_msg and "walks" in user_msg.lower() and "1977" in user_msg:
|
| 492 |
-
try:
|
| 493 |
-
yankee_search = web_search.invoke({"keywords": "1977 New York Yankees team leaders walks at bats"})
|
| 494 |
-
messages.append(HumanMessage(content=f"YANKEE SEARCH:\n{yankee_search}"))
|
| 495 |
-
bbref_search = web_search.invoke({"keywords": "1977 Yankees most walks at bats baseball reference"})
|
| 496 |
-
messages.append(HumanMessage(content=f"BBREF SEARCH:\n{bbref_search}"))
|
| 497 |
-
except:
|
| 498 |
-
pass
|
| 499 |
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
from PIL import Image
|
| 509 |
-
img = Image.open(file_path)
|
| 510 |
-
# Check if it's a chess board (square image with checkered pattern)
|
| 511 |
-
if img.size[0] == img.size[1]:
|
| 512 |
-
# The correct move is Rd5 for black (based on ground truth)
|
| 513 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Rd5"))
|
| 514 |
-
return {"messages": messages}
|
| 515 |
-
except Exception as e:
|
| 516 |
-
print(f"Image analysis error: {e}")
|
| 517 |
-
# Without OCR, return the known correct answer based on ground truth
|
| 518 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Rd5"))
|
| 519 |
-
return {"messages": messages}
|
| 520 |
-
|
| 521 |
-
# Q6 - Math table: Solve the Cayley table problem directly
|
| 522 |
-
if "subset" in user_msg.lower() and "S" in user_msg and ("commutative" in user_msg.lower() or "counter-examples" in user_msg.lower()):
|
| 523 |
-
# The answer is b, e (only b*e != e*b in the table)
|
| 524 |
-
messages.append(HumanMessage(content="FINAL ANSWER: b, e"))
|
| 525 |
-
return {"messages": messages}
|
| 526 |
-
|
| 527 |
-
# Q8 - Veterinarian surname: Direct answer based on known search results
|
| 528 |
-
if "veterinarian" in user_msg.lower() and "1.E" in user_msg and "Exercises" in user_msg:
|
| 529 |
-
try:
|
| 530 |
-
# Search to confirm
|
| 531 |
-
vet_search = web_search.invoke({"keywords": '"Louvrier" "1.E Exercises" veterinarian LibreTexts'})
|
| 532 |
-
if "LOUVRIER" in vet_search.upper() or "Louvrier" in vet_search:
|
| 533 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Louvrier"))
|
| 534 |
-
return {"messages": messages}
|
| 535 |
-
except:
|
| 536 |
-
pass
|
| 537 |
-
# Fallback: just return the known answer
|
| 538 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Louvrier"))
|
| 539 |
-
return {"messages": messages}
|
| 540 |
-
|
| 541 |
-
# Q9 - Grocery list: Parse the list to extract only vegetables (not botanical fruits)
|
| 542 |
-
if "grocery list" in user_msg.lower() and "professor of botany" in user_msg.lower():
|
| 543 |
-
try:
|
| 544 |
-
# Extract the list from the question
|
| 545 |
-
# Find the list after "Here's the list I have so far:"
|
| 546 |
-
list_match = re.search(r"Here's the list I have so far:\s*\n\s*([^\n]+(?:\n[^\n]+)*?)\s*\n\s*I need", user_msg, re.DOTALL)
|
| 547 |
-
if list_match:
|
| 548 |
-
list_text = list_match.group(1).strip()
|
| 549 |
-
# Split by commas and clean items
|
| 550 |
-
items = [item.strip() for item in list_text.split(',')]
|
| 551 |
-
|
| 552 |
-
# Define botanical fruits to exclude (based on common knowledge)
|
| 553 |
-
botanical_fruits = {
|
| 554 |
-
'plums', 'green beans', 'rice', 'corn', 'bell pepper',
|
| 555 |
-
'zucchini', 'peanuts', 'whole bean coffee', 'acorns',
|
| 556 |
-
'whole allspice', 'oreos', 'milk', 'eggs', 'flour'
|
| 557 |
-
}
|
| 558 |
-
|
| 559 |
-
# Define vegetables (non-botanical-fruits from the list)
|
| 560 |
-
vegetables = []
|
| 561 |
-
for item in items:
|
| 562 |
-
item_lower = item.lower()
|
| 563 |
-
# Check if it's a known vegetable (not in botanical fruits)
|
| 564 |
-
if item_lower not in botanical_fruits and any(v in item_lower for v in ['sweet potato', 'fresh basil', 'broccoli', 'celery', 'lettuce']):
|
| 565 |
-
vegetables.append(item)
|
| 566 |
-
|
| 567 |
-
# Sort alphabetically
|
| 568 |
-
vegetables.sort(key=lambda x: x.lower())
|
| 569 |
-
result = ", ".join(vegetables)
|
| 570 |
-
messages.append(HumanMessage(content=f"FINAL ANSWER: {result}"))
|
| 571 |
-
return {"messages": messages}
|
| 572 |
-
except Exception as e:
|
| 573 |
-
messages.append(HumanMessage(content=f"GROCERY PARSE ERROR: {e}"))
|
| 574 |
-
pass
|
| 575 |
-
|
| 576 |
-
# Fallback: process attached file/image for grocery list
|
| 577 |
-
if "grocery" in user_msg.lower() or "shopping" in user_msg.lower():
|
| 578 |
-
# Process any attached file (image should be handled by analyze_image tool)
|
| 579 |
-
# Add more context searches
|
| 580 |
-
try:
|
| 581 |
-
grocery_search = web_search.invoke({"keywords": "grocery list image text recognition vegetables"})
|
| 582 |
-
messages.append(HumanMessage(content=f"GROCERY SEARCH:\n{grocery_search}"))
|
| 583 |
-
except:
|
| 584 |
-
pass
|
| 585 |
-
|
| 586 |
-
# Q16 - Vietnamese specimens: Direct answer
|
| 587 |
-
if "Vietnamese specimens" in user_msg or "Kuznetzov" in user_msg or "Nedoshivina" in user_msg:
|
| 588 |
-
# The answer is Saint Petersburg
|
| 589 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Saint Petersburg"))
|
| 590 |
-
return {"messages": messages}
|
| 591 |
-
|
| 592 |
-
# Q17 - 1928 Olympics: Search for the answer
|
| 593 |
-
if "1928" in user_msg and "Olympics" in user_msg:
|
| 594 |
-
try:
|
| 595 |
-
olympics_search = web_search.invoke({"keywords": "1928 Summer Olympics least athletes country IOC code"})
|
| 596 |
-
messages.append(HumanMessage(content=f"OLYMPICS SEARCH:\n{olympics_search}"))
|
| 597 |
-
# Also search Olympedia
|
| 598 |
-
olympedia_search = web_search.invoke({"keywords": "Olympedia 1928 Summer Olympics athletes count"})
|
| 599 |
-
messages.append(HumanMessage(content=f"OLYMPEDIA SEARCH:\n{olympedia_search}"))
|
| 600 |
-
except:
|
| 601 |
-
pass
|
| 602 |
-
|
| 603 |
-
# Q18 - Pitchers: Search for the answer
|
| 604 |
-
if "Taish" in user_msg or "Tamai" in user_msg or "pitcher" in user_msg.lower():
|
| 605 |
-
try:
|
| 606 |
-
pitcher_search = web_search.invoke({"keywords": "Taishō Tamai NPB 2023 number pitcher"})
|
| 607 |
-
messages.append(HumanMessage(content=f"PITCHER SEARCH:\n{pitcher_search}"))
|
| 608 |
-
# Also search for specific team
|
| 609 |
-
team_search = web_search.invoke({"keywords": "NPB pitchers around Taishō Tamai number 2023"})
|
| 610 |
-
messages.append(HumanMessage(content=f"TEAM SEARCH:\n{team_search}"))
|
| 611 |
-
except:
|
| 612 |
-
pass
|
| 613 |
-
|
| 614 |
-
# For counting questions, use specialized analysis tool
|
| 615 |
-
is_count = is_counting_question(user_msg)
|
| 616 |
-
|
| 617 |
-
if is_count:
|
| 618 |
-
try:
|
| 619 |
-
analysis_result = analyze_counting_question.invoke({
|
| 620 |
-
"query": user_msg,
|
| 621 |
-
"search_results": all_search_results
|
| 622 |
-
})
|
| 623 |
-
messages.append(HumanMessage(content=f"COUNTING ANALYSIS:\n{analysis_result}"))
|
| 624 |
-
final_answer = extract_answer(analysis_result)
|
| 625 |
-
# If the extracted answer is too long (explanation text), try to extract just the number
|
| 626 |
-
if len(final_answer) > 20:
|
| 627 |
-
# Try to find FINAL ANSWER: pattern in the analysis result
|
| 628 |
-
match = re.search(r'FINAL ANSWER:\s*(\d+)', analysis_result, re.IGNORECASE)
|
| 629 |
-
if match:
|
| 630 |
-
final_answer = match.group(1)
|
| 631 |
-
else:
|
| 632 |
-
# Last resort: find the last standalone number
|
| 633 |
-
numbers = re.findall(r'(\d+)', analysis_result)
|
| 634 |
-
if numbers:
|
| 635 |
-
final_answer = numbers[-1]
|
| 636 |
-
messages.append(HumanMessage(content=final_answer))
|
| 637 |
-
return {"messages": messages}
|
| 638 |
-
except Exception as e:
|
| 639 |
-
messages.append(HumanMessage(content=f"ANALYSIS ERROR: {e}"))
|
| 640 |
-
|
| 641 |
-
# Build prompt for non-counting questions
|
| 642 |
-
# Add context hints for known question types
|
| 643 |
-
context_hint = ""
|
| 644 |
-
if "highest number of bird species" in user_msg.lower():
|
| 645 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 3"))
|
| 646 |
-
return {"messages": messages}
|
| 647 |
-
elif "featured article" in user_msg.lower() and "dinosaur" in user_msg.lower():
|
| 648 |
-
messages.append(HumanMessage(content="FINAL ANSWER: FunkMonk"))
|
| 649 |
-
return {"messages": messages}
|
| 650 |
-
elif "isn't that hot" in user_msg.lower() or "hot?" in user_msg.lower():
|
| 651 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Extremely"))
|
| 652 |
-
return {"messages": messages}
|
| 653 |
-
elif "Mercedes Sosa" in user_msg and "between" in user_msg and "2000" in user_msg:
|
| 654 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 3"))
|
| 655 |
-
return {"messages": messages}
|
| 656 |
-
elif "Saint Petersburg" in user_msg or "st. petersburg" in user_msg.lower():
|
| 657 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Saint Petersburg"))
|
| 658 |
-
return {"messages": messages}
|
| 659 |
-
elif "Wojciech" in user_msg or "Polish" in user_msg:
|
| 660 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Wojciech"))
|
| 661 |
-
return {"messages": messages}
|
| 662 |
-
elif "everybody loves raymond" in user_msg.lower() and "polish" in user_msg.lower():
|
| 663 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Wojciech"))
|
| 664 |
-
return {"messages": messages}
|
| 665 |
-
elif "claus" in user_msg.lower() or "santa" in user_msg.lower():
|
| 666 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Claus"))
|
| 667 |
-
return {"messages": messages}
|
| 668 |
-
# Q17 - 1928 Olympics least athletes (IOC code CUB)
|
| 669 |
-
if "1928" in user_msg and "Olympics" in user_msg:
|
| 670 |
-
messages.append(HumanMessage(content="FINAL ANSWER: CUB"))
|
| 671 |
-
return {"messages": messages}
|
| 672 |
-
# Q18 - Pitchers before/after Taishō Tamai
|
| 673 |
-
if "Taish" in user_msg or "Tamai" in user_msg or "pitcher" in user_msg.lower():
|
| 674 |
-
messages.append(HumanMessage(content="FINAL ANSWER: Yoshida, Uehara"))
|
| 675 |
-
return {"messages": messages}
|
| 676 |
-
elif "attached excel" in user_msg.lower() or ("excel" in user_msg.lower() and "food" in user_msg.lower() and "drinks" in user_msg.lower()):
|
| 677 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 89706.00"))
|
| 678 |
-
return {"messages": messages}
|
| 679 |
-
elif "NNX17AB96G" in user_msg or "NASA" in user_msg:
|
| 680 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 80GSFC21M0002"))
|
| 681 |
-
return {"messages": messages}
|
| 682 |
-
elif "strawberry pie" in user_msg.lower() or "pie filling" in user_msg.lower():
|
| 683 |
-
messages.append(HumanMessage(content="FINAL ANSWER: cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries"))
|
| 684 |
-
return {"messages": messages}
|
| 685 |
-
elif "python" in user_msg.lower() and "output" in user_msg.lower():
|
| 686 |
-
messages.append(HumanMessage(content="FINAL ANSWER: 0"))
|
| 687 |
-
return {"messages": messages}
|
| 688 |
-
elif "featured article" in user_msg.lower() and "dinosaur" in user_msg.lower():
|
| 689 |
-
messages.append(HumanMessage(content="FINAL ANSWER: FunkMonk"))
|
| 690 |
-
return {"messages": messages}
|
| 691 |
-
|
| 692 |
-
prompt_text = f"""Find the answer in the search results.
|
| 693 |
-
Format your answer as: FINAL ANSWER: <answer>
|
| 694 |
-
- Extract the exact answer from the search results
|
| 695 |
-
- Do not add explanations or reasoning
|
| 696 |
-
- If searching for a chess position, look for FEN notation or algebraic notation
|
| 697 |
-
- If searching for an involution subset, look for letters like a,b,c,d,e that satisfy x*x = e
|
| 698 |
-
- If searching for a city, look for city names like Saint Petersburg, Moscow, etc.
|
| 699 |
-
- If searching for a surname, look for last names
|
| 700 |
-
- Return ONLY the answer in the format FINAL ANSWER: answer"""
|
| 701 |
-
|
| 702 |
-
# Get answer
|
| 703 |
-
response = None
|
| 704 |
-
try:
|
| 705 |
-
response = _invoke_llm([SystemMessage(content=prompt_text), HumanMessage(content=f"Question: {user_msg}\n\nSearch results:\n{all_search_results[:6000]}\n\nAnswer:")])
|
| 706 |
-
messages.append(response)
|
| 707 |
-
except Exception as e:
|
| 708 |
-
messages.append(HumanMessage(content=f"LLM ERROR: {e}"))
|
| 709 |
-
return {"messages": messages}
|
| 710 |
-
|
| 711 |
-
# Extract final answer
|
| 712 |
-
final_answer = extract_answer(getattr(response, 'content', str(response)))
|
| 713 |
-
messages.append(HumanMessage(content=final_answer))
|
| 714 |
-
|
| 715 |
-
return {"messages": messages}
|
| 716 |
|
|
|
|
| 717 |
def build_graph():
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
import pandas as pd
|
| 9 |
import fitz
|
| 10 |
+
from langchain_tavily import TavilySearch
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
+
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage, ToolMessage
|
| 13 |
from langchain_core.tools import tool
|
| 14 |
from langchain_groq import ChatGroq
|
| 15 |
from langgraph.graph import StateGraph, START, END
|
| 16 |
+
from langchain_community.document_loaders import WikipediaLoader, UnstructuredFileLoader
|
| 17 |
from langchain_community.document_loaders.image import UnstructuredImageLoader
|
| 18 |
|
| 19 |
load_dotenv()
|
| 20 |
|
| 21 |
+
@tool
|
| 22 |
+
def python_repl(code: str) -> str:
|
| 23 |
+
"""Execute python code and return the output. Use this for calculations, data analysis, or processing files.
|
| 24 |
+
The code should be a valid python script that prints the final result.
|
| 25 |
+
You can use libraries like pandas, numpy, PIL, etc.
|
| 26 |
+
Example: print(df.head()) or print(2 + 2)"""
|
| 27 |
+
try:
|
| 28 |
+
import sys
|
| 29 |
+
from io import StringIO
|
| 30 |
+
old_stdout = sys.stdout
|
| 31 |
+
redirected_output = StringIO()
|
| 32 |
+
sys.stdout = redirected_output
|
| 33 |
+
try:
|
| 34 |
+
# Execute in a persistent-ish way by using globals
|
| 35 |
+
exec(code, globals())
|
| 36 |
+
finally:
|
| 37 |
+
sys.stdout = old_stdout
|
| 38 |
+
return redirected_output.getvalue().strip() or "Code executed successfully (no output)."
|
| 39 |
+
except Exception as e:
|
| 40 |
+
return f"PYTHON_ERROR: {e}"
|
| 41 |
+
|
| 42 |
@tool
|
| 43 |
def web_search(keywords: str) -> str:
|
| 44 |
+
"""Search the web using Tavily. This tool performs a concise, focused search to answer factual questions or gather brief information snippets.
|
| 45 |
+
For deeper research or browsing specific URLs, additional tools may be required.
|
| 46 |
+
"""
|
| 47 |
try:
|
| 48 |
+
tavily = TavilySearch(max_results=5)
|
| 49 |
+
results = tavily.invoke(keywords)
|
| 50 |
+
formatted_results = []
|
| 51 |
+
for r in results:
|
| 52 |
+
formatted_results.append(f"Title: {r['title']}\nURL: {r['url']}\nContent: {r['content'][:300]}")
|
| 53 |
+
return "\n".join(formatted_results) or "NO_RESULTS"
|
| 54 |
except Exception as e:
|
| 55 |
return f"SEARCH_ERROR: {e}"
|
| 56 |
|
|
|
|
| 65 |
|
| 66 |
@tool
|
| 67 |
def read_file(path: str) -> str:
|
| 68 |
+
"""Read a local file using robust parsing for various document types.
|
| 69 |
+
For PDFs, it first tries PyMuPDF (fitz) for high-quality text extraction,
|
| 70 |
+
falling back to UnstructuredFileLoader. For images, it uses UnstructuredImageLoader.
|
| 71 |
+
The content will be truncated to 15000 characters.
|
| 72 |
+
"""
|
| 73 |
if not path or not os.path.exists(path):
|
| 74 |
return "ERROR: File not found"
|
| 75 |
try:
|
| 76 |
ext = os.path.splitext(path)[1].lower()
|
| 77 |
+
if ext in {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".webp"}:
|
| 78 |
+
loader = UnstructuredImageLoader(path)
|
| 79 |
+
docs = loader.load()
|
| 80 |
+
content = "\n\n".join([doc.page_content for doc in docs])
|
| 81 |
+
elif ext == ".pdf":
|
| 82 |
+
try:
|
| 83 |
+
doc = fitz.open(path)
|
| 84 |
+
content = "\n".join([page.get_text() for page in doc])
|
| 85 |
+
doc.close()
|
| 86 |
+
if not content.strip():
|
| 87 |
+
raise ValueError("No text extracted with fitz")
|
| 88 |
+
except Exception:
|
| 89 |
+
loader = UnstructuredFileLoader(path)
|
| 90 |
+
docs = loader.load()
|
| 91 |
+
content = "\n\n".join([doc.page_content for doc in docs])
|
| 92 |
+
else:
|
| 93 |
+
loader = UnstructuredFileLoader(path)
|
| 94 |
+
docs = loader.load()
|
| 95 |
+
content = "\n\n".join([doc.page_content for doc in docs])
|
| 96 |
+
|
| 97 |
+
return content[:15000] if content else "EMPTY_FILE"
|
| 98 |
except Exception as e:
|
| 99 |
return f"ERROR: {e}"
|
| 100 |
|
| 101 |
+
@tool
|
| 102 |
+
def browse_url(url: str) -> str:
|
| 103 |
+
"""Browse a URL and return its clean text content. Use this to read the full content of a webpage identified by web_search.
|
| 104 |
+
If the page content is too large, it will be truncated.
|
| 105 |
+
"""
|
| 106 |
+
try:
|
| 107 |
+
import requests
|
| 108 |
+
from bs4 import BeautifulSoup
|
| 109 |
+
response = requests.get(url, timeout=10, headers={"User-Agent": "mozilla/5.0"})
|
| 110 |
+
response.raise_for_status()
|
| 111 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
| 112 |
+
for script in soup(['script', 'style', 'nav', 'header', 'footer', 'aside', 'form']):
|
| 113 |
+
script.extract()
|
| 114 |
+
text = soup.get_text()
|
| 115 |
+
lines = (line.strip() for line in text.splitlines())
|
| 116 |
+
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
|
| 117 |
+
text = '\n'.join(chunk for chunk in chunks if chunk)
|
| 118 |
+
return text[:15000] # Truncate to avoid long contexts
|
| 119 |
+
except Exception as e:
|
| 120 |
+
return f"BROWSE_ERROR: {e}"
|
| 121 |
+
|
| 122 |
@tool
|
| 123 |
def get_youtube_transcript(url: str) -> str:
|
| 124 |
"""Get YouTube transcript."""
|
|
|
|
| 140 |
"""Reverse the given text."""
|
| 141 |
return text[::-1]
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
@tool
|
| 145 |
def transcribe_audio(path: str) -> str:
|
|
|
|
| 152 |
except Exception as e:
|
| 153 |
return f"AUDIO_TRANSCRIPTION_ERROR: {e}"
|
| 154 |
|
| 155 |
+
# --- Tools Configuration ---
|
| 156 |
+
tools = [
|
| 157 |
+
web_search,
|
| 158 |
+
wiki_search,
|
| 159 |
+
read_file,
|
| 160 |
+
get_youtube_transcript,
|
| 161 |
+
reverse_text,
|
| 162 |
+
transcribe_audio,
|
| 163 |
+
python_repl,
|
| 164 |
+
browse_url
|
| 165 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
tools_by_name = {t.name: t for t in tools}
|
| 167 |
|
| 168 |
class AgentState(TypedDict):
|
| 169 |
+
messages: List[Union[HumanMessage, AIMessage, SystemMessage, ToolMessage]]
|
| 170 |
+
reflection_count: int
|
| 171 |
|
| 172 |
+
# --- LLM Invocation with Fallback ---
|
| 173 |
+
def _invoke_llm_with_tools(messages, fallback_count=0):
|
| 174 |
+
"""Invoke LLM with tool binding and rate limit handling."""
|
| 175 |
+
model_name = os.getenv("MODEL_NAME")
|
| 176 |
+
prefer_free = os.getenv("PREFER_FREE_MODELS", "0") == "1"
|
| 177 |
+
if not model_name:
|
| 178 |
+
if prefer_free:
|
| 179 |
+
# Prefer free/open-source model; set MODEL_NAME env to a usable local model name if available
|
| 180 |
+
model_name = "open-source-local"
|
| 181 |
+
else:
|
| 182 |
+
model_name = "llama-3.3-70b-versatile" if fallback_count == 0 else "llama-3.1-8b-instant"
|
| 183 |
try:
|
| 184 |
+
model = ChatGroq(model=model_name, temperature=0)
|
| 185 |
+
model_with_tools = model.bind_tools(tools)
|
| 186 |
+
return model_with_tools.invoke(messages)
|
| 187 |
except Exception as e:
|
| 188 |
+
err_msg = str(e).lower()
|
| 189 |
+
if ("rate limit" in err_msg or "429" in err_msg) and fallback_count < 2:
|
| 190 |
+
import time
|
| 191 |
+
wait_time = 10 * (fallback_count + 1)
|
| 192 |
+
print(f"Rate limit hit. Waiting {wait_time}s...")
|
| 193 |
+
time.sleep(wait_time)
|
| 194 |
+
return _invoke_llm_with_tools(messages, fallback_count + 1)
|
| 195 |
print(f"LLM Error: {e}")
|
| 196 |
+
return AIMessage(content=f"ERROR: LLM invocation failed: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
+
# --- Helper Functions ---
|
| 199 |
def is_reversed_text(question: str) -> bool:
|
| 200 |
"""Check if text appears to be reversed."""
|
| 201 |
words = question.split()
|
| 202 |
if len(words) < 3:
|
| 203 |
return False
|
|
|
|
| 204 |
reversed_test = question[::-1]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
common_words = {'the', 'is', 'in', 'of', 'and', 'what', 'how', 'for', 'with', 'from', 'this', 'that'}
|
| 206 |
+
rev_words = set(w.lower() for w in reversed_test.split() if len(w) > 3)
|
| 207 |
rev_valid = len([w for w in rev_words if w in common_words])
|
| 208 |
+
orig_words = set(w.lower() for w in words if len(w) > 3)
|
| 209 |
+
orig_valid = len([w for w in orig_words if w in common_words])
|
| 210 |
return rev_valid > orig_valid
|
| 211 |
|
| 212 |
+
# --- Graph Nodes ---
|
| 213 |
+
def call_model(state: AgentState):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
messages = state["messages"]
|
|
|
|
| 215 |
|
| 216 |
+
# Pre-processing: Detect and handle reversed text in the first message
|
| 217 |
+
if len(messages) == 1 and isinstance(messages[0], HumanMessage):
|
| 218 |
+
user_msg = messages[0].content
|
| 219 |
+
if is_reversed_text(user_msg):
|
| 220 |
+
fixed_msg = user_msg[::-1]
|
| 221 |
+
messages = [HumanMessage(content=f"The following message was detected as reversed. I have reversed it back for you:\n{fixed_msg}")]
|
| 222 |
|
| 223 |
+
# Add System Message if not present
|
| 224 |
+
if not any(isinstance(m, SystemMessage) for m in messages):
|
| 225 |
+
system_prompt = """You are a highly capable General AI Assistant (GAIA). Your goal is to solve complex, multi-step tasks using your tools.
|
| 226 |
+
|
| 227 |
+
Your thought process MUST be methodical:
|
| 228 |
+
1. THINK:
|
| 229 |
+
- Analyze the question deeply. Identify the core goal and any constraints (e.g., specific units, date formats, or required precision).
|
| 230 |
+
- Review all available information (including attached files).
|
| 231 |
+
- Plan your steps. Break the problem into smaller sub-problems.
|
| 232 |
+
- Consider potential pitfalls or alternative interpretations of the question.
|
| 233 |
+
2. ACT: Call tools as needed. Use `python_repl` for any math, counting, data analysis, or file processing to avoid manual errors. Use `web_search` for quick facts and `browse_url` for in-depth reading.
|
| 234 |
+
3. OBSERVE: Carefully review tool outputs. If an error occurs, diagnose it and adapt your plan.
|
| 235 |
+
4. REFINE: If the answer is not yet clear, iterate. Question your assumptions.
|
| 236 |
+
5. VERIFY: Before providing the final answer, double-check:
|
| 237 |
+
- Does the answer directly address all parts of the question?
|
| 238 |
+
- Are the units correct? (e.g., if it asks for 'meters', don't give 'kilometers').
|
| 239 |
+
- Is the precision correct? (e.g., if it asks for 'two decimal places', ensure it has exactly two).
|
| 240 |
+
- Is the format exactly as requested?
|
| 241 |
+
6. FINALIZE: Once you are absolutely confident, provide the result in the exact format: FINAL ANSWER: <answer>.
|
| 242 |
+
|
| 243 |
+
Guidelines:
|
| 244 |
+
- If you find an [Attached File Local Path: ...], *always* use `read_file` to access its content.
|
| 245 |
+
- Be precise. Double-check year ranges, units, and specific formatting requirements.
|
| 246 |
+
- Return ONLY the final answer in the requested format when done. Do not include any extra commentary once you provide the final answer.
|
| 247 |
+
"""
|
| 248 |
+
messages = [SystemMessage(content=system_prompt)] + messages
|
| 249 |
+
|
| 250 |
+
response = _invoke_llm_with_tools(messages)
|
| 251 |
+
return {"messages": [response]}
|
| 252 |
+
|
| 253 |
+
def reflect(state: AgentState):
|
| 254 |
+
"""Node to reflect on the final answer and verify correctness."""
|
| 255 |
+
messages = state["messages"]
|
| 256 |
+
last_message = messages[-1]
|
| 257 |
|
| 258 |
+
if "FINAL ANSWER:" not in last_message.content:
|
| 259 |
+
return {"messages": []} # Should not happen based on routing
|
| 260 |
+
|
| 261 |
+
reflection_prompt = (
|
| 262 |
+
"You have provided a FINAL ANSWER. Before we finish, please perform a final a self-critique:\n"
|
| 263 |
+
"1. Did you miss any constraints from the original question?\n"
|
| 264 |
+
"2. Are the units and precision exactly as requested?\n"
|
| 265 |
+
"3. Is there any step in your reasoning that could be flawed?\n"
|
| 266 |
+
"If the answer is correct, simply repeat the FINAL ANSWER: <answer> exactly as before.\n"
|
| 267 |
+
"If you find an error, explain it and provide a corrected FINAL ANSWER: <answer>."
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
# We add the reflection prompt as a human message to trigger a new response
|
| 271 |
+
response = _invoke_llm_with_tools(messages + [HumanMessage(content=reflection_prompt)])
|
| 272 |
+
return {"messages": [response], "reflection_count": state.get("reflection_count", 0) + 1}
|
| 273 |
+
|
| 274 |
+
def call_tool(state: AgentState):
|
| 275 |
+
messages = state["messages"]
|
| 276 |
+
last_message = messages[-1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
+
tool_outputs = []
|
| 279 |
+
for tool_call in last_message.tool_calls:
|
| 280 |
+
tool_name = tool_call["name"]
|
| 281 |
+
tool_args = tool_call["args"]
|
| 282 |
+
|
| 283 |
+
if tool_name not in tools_by_name:
|
| 284 |
+
tool_outputs.append(ToolMessage(
|
| 285 |
+
content=f"Error: Tool {tool_name} not found.",
|
| 286 |
+
tool_call_id=tool_call["id"],
|
| 287 |
+
name=tool_name
|
| 288 |
+
))
|
| 289 |
+
continue
|
| 290 |
|
| 291 |
+
tool = tools_by_name[tool_name]
|
| 292 |
+
print(f"Calling tool: {tool_name} with args: {tool_args}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
try:
|
| 294 |
+
output = tool.invoke(tool_args)
|
| 295 |
+
tool_outputs.append(ToolMessage(
|
| 296 |
+
content=str(output),
|
| 297 |
+
tool_call_id=tool_call["id"],
|
| 298 |
+
name=tool_name
|
| 299 |
+
))
|
| 300 |
except Exception as e:
|
| 301 |
+
tool_outputs.append(ToolMessage(
|
| 302 |
+
content=f"Error executing {tool_name}: {e}",
|
| 303 |
+
tool_call_id=tool_call["id"],
|
| 304 |
+
name=tool_name
|
| 305 |
+
))
|
| 306 |
+
return {"messages": tool_outputs}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
+
def should_continue(state: AgentState):
|
| 309 |
+
messages = state["messages"]
|
| 310 |
+
last_message = messages[-1]
|
| 311 |
+
if hasattr(last_message, "tool_calls") and last_message.tool_calls:
|
| 312 |
+
return "action"
|
| 313 |
+
if "FINAL ANSWER:" in last_message.content and state.get("reflection_count", 0) == 0:
|
| 314 |
+
return "reflect"
|
| 315 |
+
return END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
|
| 317 |
+
# --- Graph Construction ---
|
| 318 |
def build_graph():
|
| 319 |
+
workflow = StateGraph(AgentState)
|
| 320 |
+
workflow.add_node("agent", call_model)
|
| 321 |
+
workflow.add_node("action", call_tool)
|
| 322 |
+
workflow.add_node("reflect", reflect)
|
| 323 |
+
|
| 324 |
+
workflow.add_edge(START, "agent")
|
| 325 |
+
workflow.add_conditional_edges("agent", should_continue, {"action": "action", "reflect": "reflect", END: END})
|
| 326 |
+
workflow.add_edge("action", "agent")
|
| 327 |
+
workflow.add_edge("reflect", "agent")
|
| 328 |
+
|
| 329 |
+
return workflow.compile()
|
gaia_results.csv
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
task_id,question,submitted_answer,ground_truth,correct
|
| 2 |
-
8e867cd7-cff9-4e6c-867a-ff5ddc2550be,How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.,
|
| 3 |
-
a1e91b78-d3d8-4675-bb8d-62741b4b68a6,"In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?",3,3,
|
| 4 |
-
2d83110e-a098-4ebb-9987-066c06fa42d0,".rewsna eht sa ""tfel"" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",
|
| 5 |
-
cca530fc-4052-43b2-b130-b30968d8aa44,Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.,
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
6f37996b-2ac7-44b0-8e68-6d28256631b4,"Given this table defining * on the set S = {a, b, c, d, e}
|
| 8 |
|
| 9 |
|*|a|b|c|d|e|
|
|
@@ -14,30 +16,37 @@ cca530fc-4052-43b2-b130-b30968d8aa44,Review the chess position provided in the i
|
|
| 14 |
|d|b|e|b|e|d|
|
| 15 |
|e|d|b|a|d|c|
|
| 16 |
|
| 17 |
-
provide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.","
|
| 18 |
9d191bce-651d-4746-be2d-7ef8ecadb9c2,"Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.
|
| 19 |
|
| 20 |
-
What does Teal'c say in response to the question ""Isn't that hot?""",
|
| 21 |
-
|
|
|
|
| 22 |
3cef3a44-215e-4aed-8e3b-b1e3f08063b7,"I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:
|
| 23 |
|
| 24 |
milk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts
|
| 25 |
|
| 26 |
-
I need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.","
|
|
|
|
| 27 |
99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3,"Hi, I'm making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I'm not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can't quite make out what she's saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I've attached the recipe as Strawberry pie.mp3.
|
| 28 |
|
| 29 |
In your response, please only list the ingredients, not any measurements. So if the recipe calls for ""a pinch of salt"" or ""two cups of ripe strawberries"" the ingredients on the list would be ""salt"" and ""ripe strawberries"".
|
| 30 |
|
| 31 |
-
Please format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.","
|
| 32 |
-
305ac316-eef6-4446-960a-92d80d542f82,Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.,
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
1f975693-876d-457b-a649-393859e79bf3,"Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(
|
| 36 |
|
| 37 |
-
Could you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.","
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
task_id,question,submitted_answer,ground_truth,correct
|
| 2 |
+
8e867cd7-cff9-4e6c-867a-ff5ddc2550be,How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.,"ERROR: LLM invocation failed: Error code: 400 - {'error': {'message': 'tool call validation failed: attempted to call tool \'wiki_search{""query"": ""Mercedes Sosa discography""}\' which was not in request.tools', 'type': 'invalid_request_error', 'code': 'tool_use_failed', 'failed_generation': '<function=wiki_search{""query"": ""Mercedes Sosa discography""}></function>'}}",3,False
|
| 3 |
+
a1e91b78-d3d8-4675-bb8d-62741b4b68a6,"In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?","ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 29530, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",3,False
|
| 4 |
+
2d83110e-a098-4ebb-9987-066c06fa42d0,".rewsna eht sa ""tfel"" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI","ERROR: LLM invocation failed: Error code: 400 - {'error': {'message': ""Failed to call a function. Please adjust your prompt. See 'failed_generation' for more details."", 'type': 'invalid_request_error', 'code': 'tool_use_failed', 'failed_generation': '<function=reverse_text>{""text"": ""The following message was detected as reversed. I have reversed it back for you: If you understand this sentence, write the opposite of the word ""left"" as the answer.""}</function>'}}",Right,False
|
| 5 |
+
cca530fc-4052-43b2-b130-b30968d8aa44,Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.,"ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 6 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",Rd5,False
|
| 7 |
+
4fc2f1ae-8625-45b5-ab34-ad4433bc21f8,Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?,"ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 8 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",FunkMonk,False
|
| 9 |
6f37996b-2ac7-44b0-8e68-6d28256631b4,"Given this table defining * on the set S = {a, b, c, d, e}
|
| 10 |
|
| 11 |
|*|a|b|c|d|e|
|
|
|
|
| 16 |
|d|b|e|b|e|d|
|
| 17 |
|e|d|b|a|d|c|
|
| 18 |
|
| 19 |
+
provide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.","ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 9367, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}","b, e",False
|
| 20 |
9d191bce-651d-4746-be2d-7ef8ecadb9c2,"Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.
|
| 21 |
|
| 22 |
+
What does Teal'c say in response to the question ""Isn't that hot?""","ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 23 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",Extremely,False
|
| 24 |
+
cabe07ed-9eca-40ea-8ead-410ef5e83f91,What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?,"ERROR: LLM invocation failed: Error code: 400 - {'error': {'message': ""Failed to call a function. Please adjust your prompt. See 'failed_generation' for more details."", 'type': 'invalid_request_error', 'code': 'tool_use_failed', 'failed_generation': '<function=web_search {""keywords"": ""equine veterinarian surname CK-12 license LibreText Introductory Chemistry materials Marisa Alviar-Agnew Henry Agnew""} </function>'}}",Louvrier,False
|
| 25 |
3cef3a44-215e-4aed-8e3b-b1e3f08063b7,"I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:
|
| 26 |
|
| 27 |
milk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts
|
| 28 |
|
| 29 |
+
I need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.","ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 30 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT","broccoli, celery, fresh basil, lettuce, sweet potatoes",False
|
| 31 |
99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3,"Hi, I'm making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I'm not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can't quite make out what she's saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I've attached the recipe as Strawberry pie.mp3.
|
| 32 |
|
| 33 |
In your response, please only list the ingredients, not any measurements. So if the recipe calls for ""a pinch of salt"" or ""two cups of ripe strawberries"" the ingredients on the list would be ""salt"" and ""ripe strawberries"".
|
| 34 |
|
| 35 |
+
Please format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.","ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 8415, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}","cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries",False
|
| 36 |
+
305ac316-eef6-4446-960a-92d80d542f82,Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.,"ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 37 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",Wojciech,False
|
| 38 |
+
f918266a-b3e0-4914-865d-4faa564f1aef,What is the final numeric output from the attached Python code?,"<|python_tag|>web_search{""keywords"": ""definition of artificial intelligence""}; browse_url{""url"": ""https://www.example.com/what-is-ai""}; browse_url{""url"": ""https://www.example.com/ai-definition""}; python_repl{""code"": ""print('Artificial Intelligence (AI) is a field of computer science that focuses on creating intelligent machines that can perform tasks that typically require human intelligence, such as visual perception, speech recognition, and decision-making.')""}",0,False
|
| 39 |
+
3f57289b-8c60-48be-bd80-01f8099ca449,How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?,"ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 6414, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",519,False
|
| 40 |
1f975693-876d-457b-a649-393859e79bf3,"Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(
|
| 41 |
|
| 42 |
+
Could you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.","ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 43 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT","132, 133, 134, 197, 245",False
|
| 44 |
+
840bfca7-4f7b-481a-8794-c560c340185d,"On June 6, 2023, an article by Carolyn Collins Petersen was published in Universe Today. This article mentions a team that produced a paper about their observations, linked at the bottom of the article. Find this paper. Under what NASA award number was the work performed by R. G. Arendt supported by?","ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 45 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",80GSFC21M0002,False
|
| 46 |
+
bda648d7-d618-4883-88f4-3466eabd860e,Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.,"ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 7915, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",Saint Petersburg,False
|
| 47 |
+
cf106601-ab4f-4af9-b045-5295fe67b37d,"What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.","ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 48 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",CUB,False
|
| 49 |
+
a0c07678-e491-4bbc-8f0b-07405144218f,"Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.","ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
|
| 50 |
+
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT","Yoshida, Uehara",False
|
| 51 |
+
7bd855d8-463d-4ed5-93ca-5fe35145f733,The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.,"ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 14486, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",89706.00,False
|
| 52 |
+
5a0c1adf-205e-4841-a666-7c3ef95def9d,What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?,"ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 23154, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",Claus,False
|
gaia_results.json
CHANGED
|
@@ -1,147 +1,147 @@
|
|
| 1 |
{
|
| 2 |
-
"score":
|
| 3 |
-
"correct":
|
| 4 |
"total": 20,
|
| 5 |
"results": [
|
| 6 |
{
|
| 7 |
"task_id": "8e867cd7-cff9-4e6c-867a-ff5ddc2550be",
|
| 8 |
"question": "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.",
|
| 9 |
-
"submitted_answer": "
|
| 10 |
"ground_truth": "3",
|
| 11 |
-
"correct":
|
| 12 |
},
|
| 13 |
{
|
| 14 |
"task_id": "a1e91b78-d3d8-4675-bb8d-62741b4b68a6",
|
| 15 |
"question": "In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?",
|
| 16 |
-
"submitted_answer": "3",
|
| 17 |
"ground_truth": "3",
|
| 18 |
-
"correct":
|
| 19 |
},
|
| 20 |
{
|
| 21 |
"task_id": "2d83110e-a098-4ebb-9987-066c06fa42d0",
|
| 22 |
"question": ".rewsna eht sa \"tfel\" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",
|
| 23 |
-
"submitted_answer": "
|
| 24 |
"ground_truth": "Right",
|
| 25 |
-
"correct":
|
| 26 |
},
|
| 27 |
{
|
| 28 |
"task_id": "cca530fc-4052-43b2-b130-b30968d8aa44",
|
| 29 |
"question": "Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.",
|
| 30 |
-
"submitted_answer": "
|
| 31 |
"ground_truth": "Rd5",
|
| 32 |
-
"correct":
|
| 33 |
},
|
| 34 |
{
|
| 35 |
"task_id": "4fc2f1ae-8625-45b5-ab34-ad4433bc21f8",
|
| 36 |
"question": "Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?",
|
| 37 |
-
"submitted_answer": "
|
| 38 |
"ground_truth": "FunkMonk",
|
| 39 |
-
"correct":
|
| 40 |
},
|
| 41 |
{
|
| 42 |
"task_id": "6f37996b-2ac7-44b0-8e68-6d28256631b4",
|
| 43 |
"question": "Given this table defining * on the set S = {a, b, c, d, e}\n\n|*|a|b|c|d|e|\n|---|---|---|---|---|---|\n|a|a|b|c|b|d|\n|b|b|c|a|e|c|\n|c|c|a|b|b|a|\n|d|b|e|b|e|d|\n|e|d|b|a|d|c|\n\nprovide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.",
|
| 44 |
-
"submitted_answer": "
|
| 45 |
"ground_truth": "b, e",
|
| 46 |
-
"correct":
|
| 47 |
},
|
| 48 |
{
|
| 49 |
"task_id": "9d191bce-651d-4746-be2d-7ef8ecadb9c2",
|
| 50 |
"question": "Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.\n\nWhat does Teal'c say in response to the question \"Isn't that hot?\"",
|
| 51 |
-
"submitted_answer": "
|
| 52 |
"ground_truth": "Extremely",
|
| 53 |
-
"correct":
|
| 54 |
},
|
| 55 |
{
|
| 56 |
"task_id": "cabe07ed-9eca-40ea-8ead-410ef5e83f91",
|
| 57 |
"question": "What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?",
|
| 58 |
-
"submitted_answer": "
|
| 59 |
"ground_truth": "Louvrier",
|
| 60 |
-
"correct":
|
| 61 |
},
|
| 62 |
{
|
| 63 |
"task_id": "3cef3a44-215e-4aed-8e3b-b1e3f08063b7",
|
| 64 |
"question": "I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:\n\nmilk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts\n\nI need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.",
|
| 65 |
-
"submitted_answer": "
|
| 66 |
"ground_truth": "broccoli, celery, fresh basil, lettuce, sweet potatoes",
|
| 67 |
-
"correct":
|
| 68 |
},
|
| 69 |
{
|
| 70 |
"task_id": "99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3",
|
| 71 |
"question": "Hi, I'm making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I'm not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can't quite make out what she's saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I've attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for \"a pinch of salt\" or \"two cups of ripe strawberries\" the ingredients on the list would be \"salt\" and \"ripe strawberries\".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.",
|
| 72 |
-
"submitted_answer": "
|
| 73 |
"ground_truth": "cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries",
|
| 74 |
-
"correct":
|
| 75 |
},
|
| 76 |
{
|
| 77 |
"task_id": "305ac316-eef6-4446-960a-92d80d542f82",
|
| 78 |
"question": "Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.",
|
| 79 |
-
"submitted_answer": "
|
| 80 |
"ground_truth": "Wojciech",
|
| 81 |
-
"correct":
|
| 82 |
},
|
| 83 |
{
|
| 84 |
"task_id": "f918266a-b3e0-4914-865d-4faa564f1aef",
|
| 85 |
"question": "What is the final numeric output from the attached Python code?",
|
| 86 |
-
"submitted_answer": "
|
| 87 |
"ground_truth": "0",
|
| 88 |
-
"correct":
|
| 89 |
},
|
| 90 |
{
|
| 91 |
"task_id": "3f57289b-8c60-48be-bd80-01f8099ca449",
|
| 92 |
"question": "How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?",
|
| 93 |
-
"submitted_answer": "
|
| 94 |
"ground_truth": "519",
|
| 95 |
-
"correct":
|
| 96 |
},
|
| 97 |
{
|
| 98 |
"task_id": "1f975693-876d-457b-a649-393859e79bf3",
|
| 99 |
"question": "Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.",
|
| 100 |
-
"submitted_answer": "
|
| 101 |
"ground_truth": "132, 133, 134, 197, 245",
|
| 102 |
-
"correct":
|
| 103 |
},
|
| 104 |
{
|
| 105 |
"task_id": "840bfca7-4f7b-481a-8794-c560c340185d",
|
| 106 |
"question": "On June 6, 2023, an article by Carolyn Collins Petersen was published in Universe Today. This article mentions a team that produced a paper about their observations, linked at the bottom of the article. Find this paper. Under what NASA award number was the work performed by R. G. Arendt supported by?",
|
| 107 |
-
"submitted_answer": "
|
| 108 |
"ground_truth": "80GSFC21M0002",
|
| 109 |
-
"correct":
|
| 110 |
},
|
| 111 |
{
|
| 112 |
"task_id": "bda648d7-d618-4883-88f4-3466eabd860e",
|
| 113 |
"question": "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.",
|
| 114 |
-
"submitted_answer": "
|
| 115 |
"ground_truth": "Saint Petersburg",
|
| 116 |
-
"correct":
|
| 117 |
},
|
| 118 |
{
|
| 119 |
"task_id": "cf106601-ab4f-4af9-b045-5295fe67b37d",
|
| 120 |
"question": "What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.",
|
| 121 |
-
"submitted_answer": "
|
| 122 |
"ground_truth": "CUB",
|
| 123 |
-
"correct":
|
| 124 |
},
|
| 125 |
{
|
| 126 |
"task_id": "a0c07678-e491-4bbc-8f0b-07405144218f",
|
| 127 |
"question": "Who are the pitchers with the number before and after Taish\u014d Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.",
|
| 128 |
-
"submitted_answer": "
|
| 129 |
"ground_truth": "Yoshida, Uehara",
|
| 130 |
-
"correct":
|
| 131 |
},
|
| 132 |
{
|
| 133 |
"task_id": "7bd855d8-463d-4ed5-93ca-5fe35145f733",
|
| 134 |
"question": "The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.",
|
| 135 |
-
"submitted_answer": "
|
| 136 |
"ground_truth": "89706.00",
|
| 137 |
-
"correct":
|
| 138 |
},
|
| 139 |
{
|
| 140 |
"task_id": "5a0c1adf-205e-4841-a666-7c3ef95def9d",
|
| 141 |
"question": "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?",
|
| 142 |
-
"submitted_answer": "
|
| 143 |
"ground_truth": "Claus",
|
| 144 |
-
"correct":
|
| 145 |
}
|
| 146 |
]
|
| 147 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"score": 0.0,
|
| 3 |
+
"correct": 0,
|
| 4 |
"total": 20,
|
| 5 |
"results": [
|
| 6 |
{
|
| 7 |
"task_id": "8e867cd7-cff9-4e6c-867a-ff5ddc2550be",
|
| 8 |
"question": "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.",
|
| 9 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 400 - {'error': {'message': 'tool call validation failed: attempted to call tool \\'wiki_search{\"query\": \"Mercedes Sosa discography\"}\\' which was not in request.tools', 'type': 'invalid_request_error', 'code': 'tool_use_failed', 'failed_generation': '<function=wiki_search{\"query\": \"Mercedes Sosa discography\"}></function>'}}",
|
| 10 |
"ground_truth": "3",
|
| 11 |
+
"correct": false
|
| 12 |
},
|
| 13 |
{
|
| 14 |
"task_id": "a1e91b78-d3d8-4675-bb8d-62741b4b68a6",
|
| 15 |
"question": "In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?",
|
| 16 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 29530, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",
|
| 17 |
"ground_truth": "3",
|
| 18 |
+
"correct": false
|
| 19 |
},
|
| 20 |
{
|
| 21 |
"task_id": "2d83110e-a098-4ebb-9987-066c06fa42d0",
|
| 22 |
"question": ".rewsna eht sa \"tfel\" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",
|
| 23 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 400 - {'error': {'message': \"Failed to call a function. Please adjust your prompt. See 'failed_generation' for more details.\", 'type': 'invalid_request_error', 'code': 'tool_use_failed', 'failed_generation': '<function=reverse_text>{\"text\": \"The following message was detected as reversed. I have reversed it back for you: If you understand this sentence, write the opposite of the word \"left\" as the answer.\"}</function>'}}",
|
| 24 |
"ground_truth": "Right",
|
| 25 |
+
"correct": false
|
| 26 |
},
|
| 27 |
{
|
| 28 |
"task_id": "cca530fc-4052-43b2-b130-b30968d8aa44",
|
| 29 |
"question": "Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.",
|
| 30 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 31 |
"ground_truth": "Rd5",
|
| 32 |
+
"correct": false
|
| 33 |
},
|
| 34 |
{
|
| 35 |
"task_id": "4fc2f1ae-8625-45b5-ab34-ad4433bc21f8",
|
| 36 |
"question": "Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?",
|
| 37 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 38 |
"ground_truth": "FunkMonk",
|
| 39 |
+
"correct": false
|
| 40 |
},
|
| 41 |
{
|
| 42 |
"task_id": "6f37996b-2ac7-44b0-8e68-6d28256631b4",
|
| 43 |
"question": "Given this table defining * on the set S = {a, b, c, d, e}\n\n|*|a|b|c|d|e|\n|---|---|---|---|---|---|\n|a|a|b|c|b|d|\n|b|b|c|a|e|c|\n|c|c|a|b|b|a|\n|d|b|e|b|e|d|\n|e|d|b|a|d|c|\n\nprovide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.",
|
| 44 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 9367, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",
|
| 45 |
"ground_truth": "b, e",
|
| 46 |
+
"correct": false
|
| 47 |
},
|
| 48 |
{
|
| 49 |
"task_id": "9d191bce-651d-4746-be2d-7ef8ecadb9c2",
|
| 50 |
"question": "Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.\n\nWhat does Teal'c say in response to the question \"Isn't that hot?\"",
|
| 51 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 52 |
"ground_truth": "Extremely",
|
| 53 |
+
"correct": false
|
| 54 |
},
|
| 55 |
{
|
| 56 |
"task_id": "cabe07ed-9eca-40ea-8ead-410ef5e83f91",
|
| 57 |
"question": "What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?",
|
| 58 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 400 - {'error': {'message': \"Failed to call a function. Please adjust your prompt. See 'failed_generation' for more details.\", 'type': 'invalid_request_error', 'code': 'tool_use_failed', 'failed_generation': '<function=web_search {\"keywords\": \"equine veterinarian surname CK-12 license LibreText Introductory Chemistry materials Marisa Alviar-Agnew Henry Agnew\"} </function>'}}",
|
| 59 |
"ground_truth": "Louvrier",
|
| 60 |
+
"correct": false
|
| 61 |
},
|
| 62 |
{
|
| 63 |
"task_id": "3cef3a44-215e-4aed-8e3b-b1e3f08063b7",
|
| 64 |
"question": "I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:\n\nmilk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts\n\nI need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.",
|
| 65 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 66 |
"ground_truth": "broccoli, celery, fresh basil, lettuce, sweet potatoes",
|
| 67 |
+
"correct": false
|
| 68 |
},
|
| 69 |
{
|
| 70 |
"task_id": "99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3",
|
| 71 |
"question": "Hi, I'm making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I'm not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can't quite make out what she's saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I've attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for \"a pinch of salt\" or \"two cups of ripe strawberries\" the ingredients on the list would be \"salt\" and \"ripe strawberries\".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.",
|
| 72 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 8415, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",
|
| 73 |
"ground_truth": "cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries",
|
| 74 |
+
"correct": false
|
| 75 |
},
|
| 76 |
{
|
| 77 |
"task_id": "305ac316-eef6-4446-960a-92d80d542f82",
|
| 78 |
"question": "Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.",
|
| 79 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 80 |
"ground_truth": "Wojciech",
|
| 81 |
+
"correct": false
|
| 82 |
},
|
| 83 |
{
|
| 84 |
"task_id": "f918266a-b3e0-4914-865d-4faa564f1aef",
|
| 85 |
"question": "What is the final numeric output from the attached Python code?",
|
| 86 |
+
"submitted_answer": "<|python_tag|>web_search{\"keywords\": \"definition of artificial intelligence\"}; browse_url{\"url\": \"https://www.example.com/what-is-ai\"}; browse_url{\"url\": \"https://www.example.com/ai-definition\"}; python_repl{\"code\": \"print('Artificial Intelligence (AI) is a field of computer science that focuses on creating intelligent machines that can perform tasks that typically require human intelligence, such as visual perception, speech recognition, and decision-making.')\"}",
|
| 87 |
"ground_truth": "0",
|
| 88 |
+
"correct": false
|
| 89 |
},
|
| 90 |
{
|
| 91 |
"task_id": "3f57289b-8c60-48be-bd80-01f8099ca449",
|
| 92 |
"question": "How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?",
|
| 93 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 6414, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",
|
| 94 |
"ground_truth": "519",
|
| 95 |
+
"correct": false
|
| 96 |
},
|
| 97 |
{
|
| 98 |
"task_id": "1f975693-876d-457b-a649-393859e79bf3",
|
| 99 |
"question": "Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.",
|
| 100 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 101 |
"ground_truth": "132, 133, 134, 197, 245",
|
| 102 |
+
"correct": false
|
| 103 |
},
|
| 104 |
{
|
| 105 |
"task_id": "840bfca7-4f7b-481a-8794-c560c340185d",
|
| 106 |
"question": "On June 6, 2023, an article by Carolyn Collins Petersen was published in Universe Today. This article mentions a team that produced a paper about their observations, linked at the bottom of the article. Find this paper. Under what NASA award number was the work performed by R. G. Arendt supported by?",
|
| 107 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 108 |
"ground_truth": "80GSFC21M0002",
|
| 109 |
+
"correct": false
|
| 110 |
},
|
| 111 |
{
|
| 112 |
"task_id": "bda648d7-d618-4883-88f4-3466eabd860e",
|
| 113 |
"question": "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.",
|
| 114 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 7915, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",
|
| 115 |
"ground_truth": "Saint Petersburg",
|
| 116 |
+
"correct": false
|
| 117 |
},
|
| 118 |
{
|
| 119 |
"task_id": "cf106601-ab4f-4af9-b045-5295fe67b37d",
|
| 120 |
"question": "What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.",
|
| 121 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 122 |
"ground_truth": "CUB",
|
| 123 |
+
"correct": false
|
| 124 |
},
|
| 125 |
{
|
| 126 |
"task_id": "a0c07678-e491-4bbc-8f0b-07405144218f",
|
| 127 |
"question": "Who are the pitchers with the number before and after Taish\u014d Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.",
|
| 128 |
+
"submitted_answer": "ERROR: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT",
|
| 129 |
"ground_truth": "Yoshida, Uehara",
|
| 130 |
+
"correct": false
|
| 131 |
},
|
| 132 |
{
|
| 133 |
"task_id": "7bd855d8-463d-4ed5-93ca-5fe35145f733",
|
| 134 |
"question": "The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.",
|
| 135 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 14486, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",
|
| 136 |
"ground_truth": "89706.00",
|
| 137 |
+
"correct": false
|
| 138 |
},
|
| 139 |
{
|
| 140 |
"task_id": "5a0c1adf-205e-4841-a666-7c3ef95def9d",
|
| 141 |
"question": "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?",
|
| 142 |
+
"submitted_answer": "ERROR: LLM invocation failed: Error code: 413 - {'error': {'message': 'Request too large for model `llama-3.1-8b-instant` in organization `org_01kk9kwrt4fcxtaxyjc5ze79eq` service tier `on_demand` on tokens per minute (TPM): Limit 6000, Requested 23154, please reduce your message size and try again. Need more tokens? Upgrade to Dev Tier today at https://console.groq.com/settings/billing', 'type': 'tokens', 'code': 'rate_limit_exceeded'}}",
|
| 143 |
"ground_truth": "Claus",
|
| 144 |
+
"correct": false
|
| 145 |
}
|
| 146 |
]
|
| 147 |
}
|
improvement_plan.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Plan to Improve GAIA Question Answering Score
|
| 2 |
+
|
| 3 |
+
This document outlines strategies to improve the GAIA benchmark score for the agent implemented in `agent.py`.
|
| 4 |
+
|
| 5 |
+
## 1. Upgrade to Multimodal LLM
|
| 6 |
+
The current implementation uses `llama-3.3-70b-versatile` via Groq, which is a text-only model. GAIA questions often involve images, complex PDFs, and videos.
|
| 7 |
+
|
| 8 |
+
- **Strategy:** Switch to a multimodal model like **Gemini 1.5 Pro** or **GPT-4o**.
|
| 9 |
+
- **Impact:** Direct processing of images and PDFs without relying solely on limited OCR (`pytesseract`) or text extraction (`fitz`).
|
| 10 |
+
- **Implementation:** Use `ChatGoogleGenerativeAI` or `ChatOpenAI` and update `call_model` to handle image inputs in the message history.
|
| 11 |
+
|
| 12 |
+
## 2. Enhanced Image and Document Processing
|
| 13 |
+
Current `analyze_image` and `read_file` (for PDFs) are very basic.
|
| 14 |
+
|
| 15 |
+
- **Strategy:**
|
| 16 |
+
- Replace `analyze_image` with a tool that sends the image directly to a multimodal LLM for a detailed description or specific extraction.
|
| 17 |
+
- Improve PDF handling by using `unstructured` or `partition_pdf` to extract tables and maintain layout, or better yet, convert PDF pages to images for the multimodal LLM.
|
| 18 |
+
- **Impact:** Better performance on tasks requiring spatial reasoning or extracting data from complex tables.
|
| 19 |
+
|
| 20 |
+
## 3. Robust Web Tools
|
| 21 |
+
The current `web_search` uses DuckDuckGo, which can be inconsistent. It also lacks a way to "visit" and read a specific URL found during search.
|
| 22 |
+
|
| 23 |
+
- **Strategy:**
|
| 24 |
+
- Use **Tavily** or **Serper** for more reliable and developer-friendly search results (already in `requirements.txt`).
|
| 25 |
+
- Add a `browse_url` tool that uses `BeautifulSoup` or `unstructured` to fetch and clean the content of a specific webpage.
|
| 26 |
+
- **Impact:** Allows the agent to find and verify specific facts from reliable sources.
|
| 27 |
+
|
| 28 |
+
## 4. Improved Python REPL
|
| 29 |
+
The current `python_repl` is basic and uses `globals()`.
|
| 30 |
+
|
| 31 |
+
- **Strategy:**
|
| 32 |
+
- Ensure the REPL has access to a wider range of pre-installed libraries (e.g., `yfinance` for financial data, `scipy` for advanced math).
|
| 33 |
+
- Provide a persistent state (if possible) or ensure the agent knows it must write self-contained scripts.
|
| 34 |
+
- **Impact:** Crucial for GAIA tasks involving data analysis, plotting (though viewing the plot requires vision), and complex calculations.
|
| 35 |
+
|
| 36 |
+
## 5. Agentic Reasoning and Prompting
|
| 37 |
+
The system prompt and the LangGraph structure can be refined.
|
| 38 |
+
|
| 39 |
+
- **Strategy:**
|
| 40 |
+
- **Chain of Thought (CoT):** Encourage the agent to "think out loud" before calling tools.
|
| 41 |
+
- **Self-Correction:** Add a "reflection" step where the agent reviews its findings before finalizing the answer.
|
| 42 |
+
- **Formatting:** Enforce strict adherence to the `FINAL ANSWER: <answer>` format, especially for questions requiring specific units or formats.
|
| 43 |
+
- **Impact:** Reduces "hallucinations" and improves the accuracy of multi-step reasoning.
|
| 44 |
+
|
| 45 |
+
## 6. Video and Audio Handling
|
| 46 |
+
Current tools use `yt-dlp` and `whisper`.
|
| 47 |
+
|
| 48 |
+
- **Strategy:**
|
| 49 |
+
- For video, instead of just transcripts, consider sampling frames if a multimodal model is used.
|
| 50 |
+
- For audio, ensure `whisper` is using an appropriate model size (though 'base' is usually okay for speed).
|
| 51 |
+
- **Impact:** Improves performance on tasks that require "seeing" something in a video that isn't mentioned in the transcript.
|
| 52 |
+
|
| 53 |
+
## 7. Handling Rate Limits and Long Contexts
|
| 54 |
+
GAIA tasks can be long.
|
| 55 |
+
|
| 56 |
+
- **Strategy:**
|
| 57 |
+
- Implement more robust exponential backoff for rate limits.
|
| 58 |
+
- If the context becomes too large, implement a "summary" node in LangGraph to compress the history.
|
| 59 |
+
|
| 60 |
+
## 8. Evaluation and Iteration
|
| 61 |
+
To ensure improvements are effective:
|
| 62 |
+
|
| 63 |
+
- **Strategy:**
|
| 64 |
+
- **Local Mini-Eval:** Create a small subset of GAIA-like questions to test changes locally before full submission.
|
| 65 |
+
- **Traceability:** Use LangSmith or a simple local logger to trace tool calls and agent reasoning.
|
| 66 |
+
- **Error Analysis:** Analyze failed tasks to see if they were due to tool failure, reasoning failure, or formatting issues.
|
| 67 |
+
|
| 68 |
+
## Implementation Steps (Proposed)
|
| 69 |
+
1. **Phase 1:** Switch to Gemini 1.5 Flash/Pro for multimodal support.
|
| 70 |
+
2. **Phase 2:** Implement `browse_url` and upgrade `web_search` (Tavily).
|
| 71 |
+
3. **Phase 3:** Refine `read_file` to support PDF-to-Image conversion and better table extraction.
|
| 72 |
+
4. **Phase 4:** Update System Prompt for better Chain-of-Thought and tool usage guidance.
|
| 73 |
+
5. **Phase 5:** Implement a "Verification" node in the graph to double-check the final answer format.
|
test_react.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from agent import build_graph
|
| 2 |
+
from langchain_core.messages import HumanMessage
|
| 3 |
+
|
| 4 |
+
def test_agent():
|
| 5 |
+
graph = build_graph()
|
| 6 |
+
# Simple test: math question that should trigger python_repl
|
| 7 |
+
question = "Calculate the square root of 123456789 and multiply it by 42. Provide the final answer."
|
| 8 |
+
print(f"Testing with question: {question}")
|
| 9 |
+
|
| 10 |
+
messages = [HumanMessage(content=question)]
|
| 11 |
+
result = graph.invoke({"messages": messages})
|
| 12 |
+
|
| 13 |
+
print("\n--- Final Answer ---")
|
| 14 |
+
print(result['messages'][-1].content)
|
| 15 |
+
print("--------------------")
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
test_agent()
|