update tools.py, use of gpt 5.2 instead of 4.1-nano
Browse files- app.py +2 -6
- cached_answers.json +15 -14
- graph.py +2 -1
- requirements.txt +2 -1
- tools.py +20 -1
app.py
CHANGED
|
@@ -47,7 +47,7 @@ def _invoke_react_graph(task_id: str) -> str:
|
|
| 47 |
|
| 48 |
messages = react_graph.invoke(
|
| 49 |
{"messages": messages, "input_file": input_file},
|
| 50 |
-
config={"recursion_limit":
|
| 51 |
)
|
| 52 |
|
| 53 |
final_message = messages["messages"][-1]
|
|
@@ -86,11 +86,6 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 86 |
submit_url = f"{api_url}/submit"
|
| 87 |
|
| 88 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 89 |
-
# try:
|
| 90 |
-
# agent = BasicAgent()
|
| 91 |
-
# except Exception as e:
|
| 92 |
-
# print(f"Error instantiating agent: {e}")
|
| 93 |
-
# return f"Error initializing agent: {e}", None
|
| 94 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 95 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 96 |
print(agent_code)
|
|
@@ -192,6 +187,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 192 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 193 |
for item in questions_data:
|
| 194 |
task_id = item.get("task_id")
|
|
|
|
| 195 |
question_text = item.get("question")
|
| 196 |
|
| 197 |
if not task_id or question_text is None:
|
|
|
|
| 47 |
|
| 48 |
messages = react_graph.invoke(
|
| 49 |
{"messages": messages, "input_file": input_file},
|
| 50 |
+
config={"recursion_limit": 100},
|
| 51 |
)
|
| 52 |
|
| 53 |
final_message = messages["messages"][-1]
|
|
|
|
| 86 |
submit_url = f"{api_url}/submit"
|
| 87 |
|
| 88 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 90 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 91 |
print(agent_code)
|
|
|
|
| 187 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 188 |
for item in questions_data:
|
| 189 |
task_id = item.get("task_id")
|
| 190 |
+
# task_id = "a1e91b78-d3d8-4675-bb8d-62741b4b68a6" # TEMPORARY HARDCODED TASK_ID FOR TESTING
|
| 191 |
question_text = item.get("question")
|
| 192 |
|
| 193 |
if not task_id or question_text is None:
|
cached_answers.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
| 1 |
{
|
| 2 |
-
"8e867cd7-cff9-4e6c-867a-ff5ddc2550be": "
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
"
|
| 6 |
"6f37996b-2ac7-44b0-8e68-6d28256631b4": "b,e",
|
| 7 |
-
"9d191bce-651d-4746-be2d-7ef8ecadb9c2": "
|
| 8 |
-
"cabe07ed-9eca-40ea-8ead-410ef5e83f91": "
|
| 9 |
-
"3cef3a44-215e-4aed-8e3b-b1e3f08063b7": "broccoli, celery, green beans, lettuce
|
| 10 |
-
"99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3": "
|
| 11 |
-
"305ac316-eef6-4446-960a-92d80d542f82": "
|
| 12 |
"f918266a-b3e0-4914-865d-4faa564f1aef": "0",
|
| 13 |
-
"3f57289b-8c60-48be-bd80-01f8099ca449": "
|
| 14 |
-
"1f975693-876d-457b-a649-393859e79bf3": "
|
| 15 |
-
"840bfca7-4f7b-481a-8794-c560c340185d": "",
|
| 16 |
"bda648d7-d618-4883-88f4-3466eabd860e": "Saint Petersburg",
|
| 17 |
"cf106601-ab4f-4af9-b045-5295fe67b37d": "CUB",
|
| 18 |
-
"a0c07678-e491-4bbc-8f0b-07405144218f": "
|
| 19 |
-
"
|
|
|
|
| 20 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"8e867cd7-cff9-4e6c-867a-ff5ddc2550be": "3",
|
| 3 |
+
"2d83110e-a098-4ebb-9987-066c06fa42d0": "right",
|
| 4 |
+
"cca530fc-4052-43b2-b130-b30968d8aa44": "Qc1+",
|
| 5 |
+
"4fc2f1ae-8625-45b5-ab34-ad4433bc21f8": "FunkMonk",
|
| 6 |
"6f37996b-2ac7-44b0-8e68-6d28256631b4": "b,e",
|
| 7 |
+
"9d191bce-651d-4746-be2d-7ef8ecadb9c2": "extremely",
|
| 8 |
+
"cabe07ed-9eca-40ea-8ead-410ef5e83f91": "Louvrier",
|
| 9 |
+
"3cef3a44-215e-4aed-8e3b-b1e3f08063b7": "Bell pepper, broccoli, celery, fresh basil, green beans, lettuce",
|
| 10 |
+
"99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3": "cornstarch, granulated sugar, lemon juice, ripe strawberries, vanilla extract",
|
| 11 |
+
"305ac316-eef6-4446-960a-92d80d542f82": "Wojciech",
|
| 12 |
"f918266a-b3e0-4914-865d-4faa564f1aef": "0",
|
| 13 |
+
"3f57289b-8c60-48be-bd80-01f8099ca449": "525",
|
| 14 |
+
"1f975693-876d-457b-a649-393859e79bf3": "132, 133, 134, 197, 245",
|
| 15 |
+
"840bfca7-4f7b-481a-8794-c560c340185d": "80GSFC21M0002",
|
| 16 |
"bda648d7-d618-4883-88f4-3466eabd860e": "Saint Petersburg",
|
| 17 |
"cf106601-ab4f-4af9-b045-5295fe67b37d": "CUB",
|
| 18 |
+
"a0c07678-e491-4bbc-8f0b-07405144218f": "Yamasaki, Uehara",
|
| 19 |
+
"7bd855d8-463d-4ed5-93ca-5fe35145f733": "89706.00",
|
| 20 |
+
"5a0c1adf-205e-4841-a666-7c3ef95def9d": "Claus"
|
| 21 |
}
|
graph.py
CHANGED
|
@@ -17,7 +17,8 @@ from tools import (
|
|
| 17 |
|
| 18 |
openai_token = os.getenv("HF_FINAL_ASSIGNMENT_OPENAI")
|
| 19 |
|
| 20 |
-
llm = ChatOpenAI(model="gpt-4.1-nano", api_key=openai_token, temperature=0)
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
class AgentState(TypedDict):
|
|
|
|
| 17 |
|
| 18 |
openai_token = os.getenv("HF_FINAL_ASSIGNMENT_OPENAI")
|
| 19 |
|
| 20 |
+
# llm = ChatOpenAI(model="gpt-4.1-nano", api_key=openai_token, temperature=0)
|
| 21 |
+
llm = ChatOpenAI(model="gpt-5.2", api_key=openai_token, temperature=0)
|
| 22 |
|
| 23 |
|
| 24 |
class AgentState(TypedDict):
|
requirements.txt
CHANGED
|
@@ -8,4 +8,5 @@ langchain-openai
|
|
| 8 |
langgraph
|
| 9 |
tavily-python
|
| 10 |
wikipedia
|
| 11 |
-
youtube-transcript-api
|
|
|
|
|
|
| 8 |
langgraph
|
| 9 |
tavily-python
|
| 10 |
wikipedia
|
| 11 |
+
youtube-transcript-api
|
| 12 |
+
openpyxl
|
tools.py
CHANGED
|
@@ -464,9 +464,23 @@ def select_tools_for_input(input_file: Optional[str]):
|
|
| 464 |
divide,
|
| 465 |
]
|
| 466 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
# Cas image
|
| 468 |
if suffix in [".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif"]:
|
| 469 |
-
return [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
|
| 471 |
# Fallback général
|
| 472 |
return [
|
|
@@ -475,7 +489,12 @@ def select_tools_for_input(input_file: Optional[str]):
|
|
| 475 |
wikipedia_search_pages,
|
| 476 |
wikipedia_get_page_summary,
|
| 477 |
wikipedia_get_page_full_content,
|
|
|
|
|
|
|
|
|
|
| 478 |
execute_python_code_with_subprocess,
|
|
|
|
|
|
|
| 479 |
add,
|
| 480 |
subtract,
|
| 481 |
multiply,
|
|
|
|
| 464 |
divide,
|
| 465 |
]
|
| 466 |
|
| 467 |
+
if suffix in [".py"]:
|
| 468 |
+
print("Selecting tools for Python code input.")
|
| 469 |
+
return [
|
| 470 |
+
execute_python_code_with_subprocess,
|
| 471 |
+
add,
|
| 472 |
+
subtract,
|
| 473 |
+
multiply,
|
| 474 |
+
divide,
|
| 475 |
+
]
|
| 476 |
+
|
| 477 |
# Cas image
|
| 478 |
if suffix in [".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif"]:
|
| 479 |
+
return [
|
| 480 |
+
extract_text_from_image,
|
| 481 |
+
chessboard_image_to_text_description_to_fen_notation,
|
| 482 |
+
get_best_next_move_from_fen,
|
| 483 |
+
]
|
| 484 |
|
| 485 |
# Fallback général
|
| 486 |
return [
|
|
|
|
| 489 |
wikipedia_search_pages,
|
| 490 |
wikipedia_get_page_summary,
|
| 491 |
wikipedia_get_page_full_content,
|
| 492 |
+
youtube_get_transcript_of_video,
|
| 493 |
+
get_best_next_move_from_fen,
|
| 494 |
+
chessboard_image_to_text_description_to_fen_notation,
|
| 495 |
execute_python_code_with_subprocess,
|
| 496 |
+
transcribe_audio_file,
|
| 497 |
+
read_excel_file,
|
| 498 |
add,
|
| 499 |
subtract,
|
| 500 |
multiply,
|