Spaces:
Runtime error
Runtime error
Download utils/react.py from ankush-003/MahaNeta: direct link, hf CLI and curl.
- Browser
- Download file 762 Bytes
-
https://huggingface.co/spaces/ankush-003/MahaNeta/resolve/main/utils/react.py
- Command line
-
hf download hf://spaces/ankush-003/MahaNeta/utils/react.py
-
curl -L -o react.py https://huggingface.co/spaces/ankush-003/MahaNeta/resolve/main/utils/react.py
762 Bytes
| 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("---") |