Source code for langchain.agents.format_scratchpad.xml

from typing import List, Tuple

from langchain_core.agents import AgentAction


[docs]def format_xml( intermediate_steps: List[Tuple[AgentAction, str]], ) -> str: """将中间步骤格式化为XML。 参数: intermediate_steps: 中间步骤。 返回: 中间步骤的XML格式。 """ log = "" for action, observation in intermediate_steps: log += ( f"<tool>{action.tool}</tool><tool_input>{action.tool_input}" f"</tool_input><observation>{observation}</observation>" ) return log