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 <dev.dev2049@gmail.com>
docker
Emil Ahlbäck 1 year ago committed by GitHub
parent 1ff7c958b0
commit 5c9205d5f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save