import os from smolagents import ( CodeAgent, DuckDuckGoSearchTool, InferenceClientModel, PythonInterpreterTool, ) from tools import ( arvix_search, extract_markdown_tables_from_markdown_content, get_audio_transcription, get_python_file_content, read_excel_content_to_markdown_content, read_pdf_content_to_markdown, visit_webpage_to_markdown, wiki_search, ) class MyAgent: def __init__(self): self.agent = CodeAgent( tools=[ PythonInterpreterTool(), wiki_search, visit_webpage_to_markdown, DuckDuckGoSearchTool(max_results=8), get_python_file_content, get_audio_transcription, read_pdf_content_to_markdown, read_excel_content_to_markdown_content, extract_markdown_tables_from_markdown_content, arvix_search, ], planning_interval=3, model=InferenceClientModel(), additional_authorized_imports=[ "datetime", "re", "os", "pandas", "numpy", "json", ], verbosity_level=2, # 0: no output, 1: minimal output, 2: detailed output ) print("MyAgent initialized.") def __call__(self, question: str) -> str: print(f"Agent received question (first 50 chars): {question[:50]}...") answer = self.agent.run(question, max_steps=11) print(f"Agent returning answer: {answer}") return answer if __name__ == "__main__": print("Running MyAgent in standalone mode...") agent = MyAgent() # answer = agent( # "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 KO # answer = agent( # "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." # ) # Wojciech KO # answer = agent( # "Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?" # ) # FunkMonk # answer = agent( # f"What is the final numeric output from the attached Python code? \n\nMentionned case sentitive file path is {os.getenv('GAIA_CONTENT_PATH')}/f918266a-b3e0-4914-865d-4faa564f1aef.py" # ) # 0 # answer = agent( # f'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. \n\nMentionned case sentitive file path is {os.getenv("GAIA_CONTENT_PATH")}/99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3 \n\ncorn starch right typo is cornstarch' # ) # "cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries" TO_TEST # answer = agent( # "How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?" # ) # 519 # answer = agent( # f"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.\n\nMentionned case sentitive file path is {os.getenv('GAIA_CONTENT_PATH')}/1f975693-876d-457b-a649-393859e79bf3.mp3" # ) # "132, 133, 134, 197, 245" / OK # "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations." # Saint Petersburg / PDF ? KO # answer = agent( # "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." # ) # CUB / OK 5 steps # answer = agent( # "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." # ) # Yoshida, Uehara / OK 6 steps answer = agent( f"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.\n\nMentionned case sentitive file path is {os.getenv('GAIA_CONTENT_PATH'), ''}7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx" ) # 89706.00 Excel xlsx TO_TEST # answer = agent( # "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?" # ) # Claus # answer = agent( # "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?\"" # ) # Extremely / OK # answer = agent( # "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?" # ) # Louvrier / OK 5 steps print(f"Answer: {answer}")