polyMoe commited on
Commit
1e030e6
·
1 Parent(s): cb20efa

update tools.py, use of gpt 5.2 instead of 4.1-nano

Browse files
Files changed (5) hide show
  1. app.py +2 -6
  2. cached_answers.json +15 -14
  3. graph.py +2 -1
  4. requirements.txt +2 -1
  5. 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": 50},
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": "4",
3
- "a1e91b78-d3d8-4675-bb8d-62741b4b68a6": "I cannot directly access or analyze the content of the video link provided. To determine the highest number of bird species on camera simultaneously, I would need either a description of the video content or a summary of relevant information. Alternatively, I can try to find a description or discussion about this specific video if available online. Would you like me to search for any details or summaries related to this video?",
4
- "2d83110e-a098-4ebb-9987-066c06fa42d0": "The sentence written in reverse is: \".right\"",
5
- "cca530fc-4052-43b2-b130-b30968d8aa44": "The image contains a chessboard with coordinates labeled from a to h horizontally and 1 to 8 vertically. To identify the best move for black, I need to analyze the position. Since I cannot see the actual pieces from the text alone, I will rely on the extracted text and the typical context of such puzzles.\n\nHowever, the image's text only shows the coordinate labels, not the pieces or their positions. To accurately determine the winning move, I need to see the actual arrangement of the pieces on the board.\n\nPlease provide a detailed description of the position or upload an image showing the pieces on the board.",
6
  "6f37996b-2ac7-44b0-8e68-6d28256631b4": "b,e",
7
- "9d191bce-651d-4746-be2d-7ef8ecadb9c2": "I don't have the capability to directly access or view videos, including YouTube links. However, I can help if you provide a transcript or more context about the scene. Alternatively, I can try to find a script or quote from that episode if you tell me which Stargate SG-1 episode it is from. Please specify or provide more details.",
8
- "cabe07ed-9eca-40ea-8ead-410ef5e83f91": "None",
9
- "3cef3a44-215e-4aed-8e3b-b1e3f08063b7": "broccoli, celery, green beans, lettuce, sweet potatoes",
10
- "99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3": "It appears I am unable to directly listen to or process audio files. However, if you can provide a transcript or the key details from the voice memo, I can help identify the ingredients for the filling. Please share any text or details you have.",
11
- "305ac316-eef6-4446-960a-92d80d542f82": "Bartłomiej",
12
  "f918266a-b3e0-4914-865d-4faa564f1aef": "0",
13
- "3f57289b-8c60-48be-bd80-01f8099ca449": "I need to verify the player with the most walks for the Yankees in 1977. Based on the search results, Derek Jeter is a notable Yankees player, but he played in the late 1990s and 2000s, so he is unlikely to be the player with the most walks in 1977. \n\nThe search results do not clearly indicate the player with the most walks in 1977. I will now look for specific statistics for Yankees players in 1977 to identify who had the most walks and at-bats.\n\nI'll search for Yankees 1977 player stats to find the player with the most walks and then check their at-bats.",
14
- "1f975693-876d-457b-a649-393859e79bf3": "It appears that I am unable to directly process audio files. However, I can guide you on how to transcribe the audio using available tools or software such as speech recognition libraries or online transcription services. Would you like me to provide a step-by-step guide on how to do this?",
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": "Ohtani, Kondoh.",
19
- "5a0c1adf-205e-4841-a666-7c3ef95def9d": "Let's analyze the question step-by-step:\n\n1. The question asks for the first name of a specific individual: the only Malko Competition recipient from the 20th century (after 1977).\n2. This individual’s nationality is from a country that no longer exists.\n3. The recipient must have received the Malko Competition award after 1977, which is in the late 20th century.\n4. The country of nationality must be a defunct country.\n\nFirst, I need to identify the recipients of the Malko Competition (also known as the Malko Competition for Young Conductors). I will search for a list of recipients and their nationalities, focusing on those after 1977.\n\nI will use the Tavily search to find relevant information about the Malko Competition winners.\n\nLet's proceed with the search.\n\ntavily_search: \"Malko Competition winners list\""
 
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 [extract_text_from_image]
 
 
 
 
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,