From 5c5a12fd8c058d6fef5a38bd13b1c4d9bad57ad4 Mon Sep 17 00:00:00 2001 From: Kye Date: Thu, 13 Jul 2023 13:40:41 -0400 Subject: [PATCH] output parser Former-commit-id: 058550f04886f01fbd7650a5b29e5e96c2a9134c --- swarms/agents/utils/ConversationalChatAgent.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/swarms/agents/utils/ConversationalChatAgent.py b/swarms/agents/utils/ConversationalChatAgent.py index 1e2b96ac..9dbd886e 100644 --- a/swarms/agents/utils/ConversationalChatAgent.py +++ b/swarms/agents/utils/ConversationalChatAgent.py @@ -20,8 +20,16 @@ from langchain.schema import ( HumanMessage, ) from langchain.tools.base import BaseTool + + +from langchain.agents.agent import AgentOutputParser +from langchain.schema import AgentAction + + from swarms.prompts.prompts import EVAL_TOOL_RESPONSE + + logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') class ConversationalChatAgent(Agent): @@ -142,7 +150,12 @@ class ConversationalChatAgent(Agent): logging.error(f"Error while creating agent from LLM and tools: {str(e)}") raise e +class OutputParser(AgentOutputParser): + def parse(self, full_output: str) -> AgentAction: + return AgentAction(action="chat", details={'message': full_output}) + class ChatAgent(ConversationalChatAgent): def _get_default_output_parser(self): """Get default output parser for this class.""" + return OutputParser()