Source code for langchain.agents.format_scratchpad.log
from typing import List, Tuple
from langchain_core.agents import AgentAction
[docs]def format_log_to_str(
intermediate_steps: List[Tuple[AgentAction, str]],
observation_prefix: str = "Observation: ",
llm_prefix: str = "Thought: ",
) -> str:
"""构建一个草稿本,让代理继续其思考过程。"""
thoughts = ""
for action, observation in intermediate_steps:
thoughts += action.log
thoughts += f"\n{observation_prefix}{observation}\n{llm_prefix}"
return thoughts