From 03a1331cf7d5b5a5543520b4d433fab4abbfc7e4 Mon Sep 17 00:00:00 2001 From: Kye Date: Thu, 13 Jul 2023 13:31:49 -0400 Subject: [PATCH] chat agent abstract class Former-commit-id: 1d36cd9c45dd5875458a3e4d01e846cb6b4a687d --- swarms/agents/utils/AgentBuilder.py | 4 ++-- swarms/agents/utils/ConversationalChatAgent.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/swarms/agents/utils/AgentBuilder.py b/swarms/agents/utils/AgentBuilder.py index fb8ef625..cce4c3b4 100644 --- a/swarms/agents/utils/AgentBuilder.py +++ b/swarms/agents/utils/AgentBuilder.py @@ -9,7 +9,7 @@ from langchain.chat_models.base import BaseChatModel from langchain.schema import BaseOutputParser from langchain.callbacks.base import BaseCallbackManager -from .ConversationalChatAgent import ConversationalChatAgent +from .ConversationalChatAgent import ChatAgent # from .ChatOpenAI import ChatOpenAI from langchain.chat_models import ChatOpenAI from .EvalOutputParser import EvalOutputParser @@ -79,7 +79,7 @@ class AgentBuilder: if self.global_tools is None: raise ValueError("Global tools must be initialized before agent") - return ConversationalChatAgent.from_llm_and_tools( + return ChatAgent.from_llm_and_tools( llm=self.llm, tools=[ *self.global_tools, diff --git a/swarms/agents/utils/ConversationalChatAgent.py b/swarms/agents/utils/ConversationalChatAgent.py index 03d1919a..1e2b96ac 100644 --- a/swarms/agents/utils/ConversationalChatAgent.py +++ b/swarms/agents/utils/ConversationalChatAgent.py @@ -140,4 +140,9 @@ class ConversationalChatAgent(Agent): ) except Exception as e: logging.error(f"Error while creating agent from LLM and tools: {str(e)}") - raise e \ No newline at end of file + raise e + + +class ChatAgent(ConversationalChatAgent): + def _get_default_output_parser(self): + """Get default output parser for this class."""