Spaces:
Sleeping
Sleeping
Update model
Browse files1 unmodified line23456789 unmodified lines18192021222317 unmodified lines4142434445464748495051525354555657585960616263646566676869707172737475767778793 unmodified lines8384858687888990165 unmodified lines2562572582592602612622632642652661 unmodified lineimport osimport reimport tempfilefrom pathlib import Pathfrom typing import TypedDict, Annotated, Optionalimport pandas as pdimport requests9 unmodified linesfrom mediawikiapi import MediaWikiAPIfrom wikipedia_tool import WikipediaToolfrom yt_tool import speech_recognition_pipe, yt_transcribe@tool17 unmodified linesexcept Exception as e:return f"Error analyzing CSV file: {str(e)}"@tooldef addition(a: int, b: int) -> int:"""Add two int numbers.Args:a: intb intReturns:a + b"""return a + b@tooldef multiple(a: int, b: int) -> float:"""Multiple two float numbers.Args:a: intb intReturns:a * b"""return a * bclass Agent:def __init__(self):llm = ChatGoogleGenerativeAI(model="gemini-2.5-flash-preview-04-17",# model="gemini-2.0-flash",# model="gemini-1.5-pro",temperature=03 unmodified linesWikipediaTool(api_wrapper=WikipediaAPIWrapper(wiki_client=MediaWikiAPI())),TavilySearch(),read_xlsx_file,addition,multiple,yt_transcribe]165 unmodified linesreturn builder.compile()def run(self, question: str, task_id: str, file_name: str | None):system_prompt = SystemMessage(content="You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, use digit not letter, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.")messages = [system_prompt, HumanMessage(content=question)]response = self.graph.invoke({"messages": messages, "task_id": task_id, "file_name": file_name}, debug=True)answer = response['messages'][-1].content1 unmodified line23456789109 unmodified lines2021222324252617 unmodified lines44454647484950515253543 unmodified lines58596061626364656667165 unmodified lines2332342352362372382392402412422432442452462472482491 unmodified lineimport osimport reimport tempfileimport timefrom pathlib import Pathfrom time import sleepfrom typing import TypedDict, Annotated, Optionalimport pandas as pdimport requests9 unmodified linesfrom mediawikiapi import MediaWikiAPIfrom wikipedia_tool import WikipediaToolfrom yt_tool import speech_recognition_pipe, yt_transcribefrom calculus_tools import add, substract, multiple, divide@tool17 unmodified linesexcept Exception as e:return f"Error analyzing CSV file: {str(e)}"class Agent:def __init__(self):llm = ChatGoogleGenerativeAI(model="gemini-2.5-flash-preview-05-20",# model="gemini-2.0-flash",# model="gemini-1.5-pro",temperature=03 unmodified linesWikipediaTool(api_wrapper=WikipediaAPIWrapper(wiki_client=MediaWikiAPI())),TavilySearch(),read_xlsx_file,add,substract,multiple,divide,yt_transcribe]165 unmodified linesreturn builder.compile()def run(self, question: str, task_id: str, file_name: str | None):system_prompt = SystemMessage(content="""You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, use digit not letter, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.If you are asked a list of items separated by coma, add a space after each coma.If you are asked a list in alphabetical order, it is the first word of each item that matters.""")messages = [system_prompt, HumanMessage(content=question)]response = self.graph.invoke({"messages": messages, "task_id": task_id, "file_name": file_name})answer = response['messages'][-1].content
92 unmodified lines939495969798116 unmodified lines21521621721892 unmodified linesanswers_payload = []print(f"Running agent on {len(questions_data)} questions...")for item in questions_data:task_id = item.get("task_id")question_text = item.get("question")file_name = item.get("file_name")116 unmodified linesprint("-"*(60 + len(" App Starting ")) + "\n")print("Launching Gradio Interface for Basic Agent Evaluation...")demo.launch(debug=True, share=False)92 unmodified lines93949596979899116 unmodified lines21621721821992 unmodified linesanswers_payload = []print(f"Running agent on {len(questions_data)} questions...")for item in questions_data:time.sleep(60)task_id = item.get("task_id")question_text = item.get("question")file_name = item.get("file_name")116 unmodified linesprint("-"*(60 + len(" App Starting ")) + "\n")print("Launching Gradio Interface for Basic Agent Evaluation...")demo.launch(share=False)
agent.py+15-32
app.py+2-1