Spaces:
Runtime error
Runtime error
| from langchain import hub | |
| from langchain.agents import AgentExecutor, create_react_agent | |
| def run_agent_executor(agent_executor: AgentExecutor, input_data: dict): | |
| for chunk in agent_executor.stream(input_data): | |
| if "actions" in chunk: | |
| for action in chunk["actions"]: | |
| print(f"Calling Tool: `{action.tool}` with input `{action.tool_input}`") | |
| # Observation | |
| elif "steps" in chunk: | |
| for step in chunk["steps"]: | |
| print(f"Tool Result: `{step.observation}`") | |
| # Final result | |
| elif "output" in chunk: | |
| print(f'Final Output: {chunk["output"]}') | |
| else: | |
| raise ValueError() | |
| print("---") |