From 5c9205d5f421a8b529afdbea94c1f59f9364b1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Ahlb=C3=A4ck?= Date: Thu, 18 May 2023 02:23:08 +0200 Subject: [PATCH] ConversationalChatAgent: Allow customizing `TEMPLATE_TOOL_RESPONSE` (#2361) It's currently not possible to change the `TEMPLATE_TOOL_RESPONSE` prompt for ConversationalChatAgent, this PR changes that. --------- Co-authored-by: Dev 2049 --- langchain/agents/conversational_chat/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/langchain/agents/conversational_chat/base.py b/langchain/agents/conversational_chat/base.py index 17128543..0e103720 100644 --- a/langchain/agents/conversational_chat/base.py +++ b/langchain/agents/conversational_chat/base.py @@ -37,6 +37,7 @@ class ConversationalChatAgent(Agent): """An agent designed to hold a conversation in addition to using tools.""" output_parser: AgentOutputParser = Field(default_factory=ConvoOutputParser) + template_tool_response: str = TEMPLATE_TOOL_RESPONSE @classmethod def _get_default_output_parser(cls, **kwargs: Any) -> AgentOutputParser: @@ -99,7 +100,7 @@ class ConversationalChatAgent(Agent): for action, observation in intermediate_steps: thoughts.append(AIMessage(content=action.log)) human_message = HumanMessage( - content=TEMPLATE_TOOL_RESPONSE.format(observation=observation) + content=self.template_tool_response.format(observation=observation) ) thoughts.append(human_message) return thoughts