Spaces:
Runtime error
Runtime error
Update langgraph_agent.py
Browse files4 unmodified lines5678910111213141512 unmodified lines28293031323310 unmodified lines4445464748494 unmodified linesfrom langchain_core.runnables import RunnableConfigfrom langgraph.prebuilt import create_react_agentfrom langgraph.prebuilt.chat_agent_executor import AgentStatefrom langchain_community.tools import DuckDuckGoSearchRunfrom langchain_experimental.utilities import PythonREPLfrom langchain_community.tools import WikipediaQueryRunfrom langchain_community.utilities import WikipediaAPIWrapperload_dotenv()12 unmodified linespython_repl = PythonREPL()wikipedia = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper())def prompt(state: AgentState, config: RunnableConfig) -> list[AnyMessage]:file_path = config["configurable"].get("file_path", "")system_msg = (10 unmodified linesreact_agent = create_react_agent(model=chat,tools=[duckduckgo, wikipedia],prompt=prompt,)4 unmodified lines567891011121314151612 unmodified lines29303132333435363738394041424344454647484950515253545556575859606162636465666768697071727310 unmodified lines8485868788894 unmodified linesfrom langchain_core.runnables import RunnableConfigfrom langgraph.prebuilt import create_react_agentfrom langgraph.prebuilt.chat_agent_executor import AgentStatefrom smolagents import VisitWebpageTool, PythonInterpreterTool, SpeechToTextToolfrom langchain_community.tools import DuckDuckGoSearchRunfrom langchain_experimental.utilities import PythonREPLfrom langchain_community.tools import WikipediaQueryRunfrom langchain_community.utilities import WikipediaAPIWrapperfrom langchain_core.tools import toolload_dotenv()12 unmodified linespython_repl = PythonREPL()wikipedia = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper())# Instantiate smolagents toolsvisit_webpage_tool = VisitWebpageTool()python_interpreter_tool = PythonInterpreterTool()speech_to_text_tool = SpeechToTextTool()@tooldef visit_webpage(url: str) -> str:"""Visit a webpage and return its content as a string.Args:url (str): The URL of the webpage to visit.Returns:str: The content of the webpage."""return visit_webpage_tool(url=url)@tooldef python_interpreter(code: str) -> str:"""Execute Python code and return the output as a string.Args:code (str): The Python code to execute.Returns:str: The output of the executed code."""return python_interpreter_tool(code=code)@tooldef speech_to_text(audio_path: str) -> str:"""Convert speech in an audio file to text.Args:audio_path (str): The path to the audio file.Returns:str: The transcribed text from the audio."""return speech_to_text_tool(audio_path=audio_path)def prompt(state: AgentState, config: RunnableConfig) -> list[AnyMessage]:file_path = config["configurable"].get("file_path", "")system_msg = (10 unmodified linesreact_agent = create_react_agent(model=chat,tools=[duckduckgo, wikipedia, visit_webpage, python_interpreter, speech_to_text],prompt=prompt,)
langgraph_agent.py+42-2