Spaces:
Sleeping
Sleeping
feat: :sparkles: add googleapi
Browse filesFiles changed (5)
33 unmodified lines3435363738394041424344454640 unmodified lines87888990919224 unmodified lines11711811912012112212312412512612712812913013113213313497 unmodified lines23223323423523623733 unmodified linesdef ask_question(question: str, thread_id: str = "default") -> str:"""Ask the agent a question."""config = {"configurable": {"thread_id": thread_id}}try:response = general_agent.invoke({"messages": [{"role": "user", "content": question}]},config=config)return response["messages"][-1].contentexcept Exception as e:return f"Error: {str(e)}"40 unmodified linesreturn result["messages"][-1].contenttest = [# {# "task_id": "cca530fc-4052-43b2-b130-b30968d8aa44",# "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.",24 unmodified lines# "Level": "1",# "file_name": ""# },{"task_id": "9d191bce-651d-4746-be2d-7ef8ecadb9c2","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?\"","Level": "1","file_name": ""},{"task_id": "a1e91b78-d3d8-4675-bb8d-62741b4b68a6","question": "In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?","Level": "1","file_name": ""},]questions = [Question(**item) for item in test]97 unmodified lines"decision": "","answer": ""})print(f"Answer: {result['answer']}")print("-" * 50)33 unmodified lines343536373839404142434445464740 unmodified lines88899091929394959697989924 unmodified lines12412512612712812913013113213313413513613713813914014197 unmodified lines23924024124224324424533 unmodified linesdef ask_question(question: str, thread_id: str = "default") -> str:"""Ask the agent a question."""config = {"configurable": {"thread_id": thread_id}, "recursion_limit": 100}try:response = general_agent.invoke({"messages": [{"role": "user", "content": question}]},config=config)print(response["messages"])return response["messages"][-1].contentexcept Exception as e:return f"Error: {str(e)}"40 unmodified linesreturn result["messages"][-1].contenttest = [{"task_id": "8e867cd7-cff9-4e6c-867a-ff5ddc2550be","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.","Level": "1","file_name": ""},# {# "task_id": "cca530fc-4052-43b2-b130-b30968d8aa44",# "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.",24 unmodified lines# "Level": "1",# "file_name": ""# },# {# "task_id": "9d191bce-651d-4746-be2d-7ef8ecadb9c2",# "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?\"",# "Level": "1",# "file_name": ""# },# {# "task_id": "a1e91b78-d3d8-4675-bb8d-62741b4b68a6",# "question": "In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?",# "Level": "1",# "file_name": ""# },]questions = [Question(**item) for item in test]97 unmodified lines"decision": "","answer": ""})print(result)print(f"Answer: {result['answer']}")print("-" * 50)
10 unmodified lines11121310 unmodified linesopenpyxlultralyticsyoutube-transcript-api10 unmodified lines111213141510 unmodified linesopenpyxlultralyticsyoutube-transcript-apigoogle-api-python-clientlangchain-google-community
4 unmodified lines567891014 unmodified lines252627282930292 unmodified lines3233243253263273283293303313323334 unmodified linesWikipediaQueryRun,ArxivQueryRun)from langchain_community.utilities import WikipediaAPIWrapper, ArxivAPIWrapperfrom langchain_openai import ChatOpenAI14 unmodified linesfrom dotenv import load_dotenvload_dotenv()HF_TOKEN = os.getenv("HF_TOKEN")client = InferenceClient(provider="hf-inference",api_key=HF_TOKEN,292 unmodified linesexcept Exception as e:return f"Error analyzing video content: {str(e)}"def general_tools():tools = [DuckDuckGoSearchRun(),WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper()),ArxivQueryRun(api_wrapper=ArxivAPIWrapper()),analyze_image,read_python_file,transcribe_audio,4 unmodified lines56789101112131414 unmodified lines2930313233343536292 unmodified lines3293303313323333343353363373383393403413423433443453463473483493504 unmodified linesWikipediaQueryRun,ArxivQueryRun)from langchain_google_community.search import (GoogleSearchAPIWrapper,GoogleSearchRun)from langchain_community.utilities import WikipediaAPIWrapper, ArxivAPIWrapperfrom langchain_openai import ChatOpenAI14 unmodified linesfrom dotenv import load_dotenvload_dotenv()HF_TOKEN = os.getenv("HF_TOKEN")GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")GOOGLE_CSE_ID = os.getenv("GOOGLE_CSE_ID")client = InferenceClient(provider="hf-inference",api_key=HF_TOKEN,292 unmodified linesexcept Exception as e:return f"Error analyzing video content: {str(e)}"@tooldef google_search():"""Google search tool"""api_wrapper = GoogleSearchAPIWrapper(google_api_key=GOOGLE_API_KEY,google_cse_id=GOOGLE_CSE_ID,k=10, # Number of resultssiterestrict=False # Site restrictions)google_search = GoogleSearchRun(api_wrapper=api_wrapper)return google_searchdef general_tools():tools = [WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper()),ArxivQueryRun(api_wrapper=ArxivAPIWrapper()),google_search,analyze_image,read_python_file,transcribe_audio,
__pycache__/agents.cpython-312.pyc
__pycache__/tools.cpython-312.pyc
qa_graph.py+21-13
requirements.txt+2
tools.py+18-1