Spaces:
Sleeping
Sleeping
Download src/langgraph/multi_agent/planner/utils.py from ABAO77/TriVenture-BE: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/spaces/ABAO77/TriVenture-BE/resolve/main/src/langgraph/multi_agent/planner/utils.py
- Command line
-
hf download hf://spaces/ABAO77/TriVenture-BE/src/langgraph/multi_agent/planner/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/ABAO77/TriVenture-BE/resolve/main/src/langgraph/multi_agent/planner/utils.py
876 Bytes
| from typing import List, Tuple | |
| from langchain_core.agents import AgentAction | |
| def format_log_to_str( | |
| intermediate_steps: List[Tuple[AgentAction, str]], | |
| observation_prefix: str = "Observation: ", | |
| llm_prefix: str = "Thought: ", | |
| ) -> str: | |
| """Construct the scratchpad that lets the agent continue its thought process. | |
| Args: | |
| intermediate_steps: List of tuples of AgentAction and observation strings. | |
| observation_prefix: Prefix to append the observation with. | |
| Defaults to "Observation: ". | |
| llm_prefix: Prefix to append the llm call with. | |
| Defaults to "Thought: ". | |
| Returns: | |
| str: The scratchpad. | |
| """ | |
| thoughts = "" | |
| for action, observation in intermediate_steps: | |
| thoughts += action.log | |
| thoughts += f"\n{observation_prefix}{observation}\n{llm_prefix}" | |
| return thoughts | |