back to importing agent

Former-commit-id: af8aa0fc9211b6c93c6fe7a46038773774f3d1c7
pull/160/head
Kye 2 years ago
parent 5c5a12fd8c
commit 1ef570f4c5

@ -9,7 +9,7 @@ from langchain.chat_models.base import BaseChatModel
from langchain.schema import BaseOutputParser from langchain.schema import BaseOutputParser
from langchain.callbacks.base import BaseCallbackManager from langchain.callbacks.base import BaseCallbackManager
from .ConversationalChatAgent import ChatAgent from .ConversationalChatAgent import ConversationalChatAgent
# from .ChatOpenAI import ChatOpenAI # from .ChatOpenAI import ChatOpenAI
from langchain.chat_models import ChatOpenAI from langchain.chat_models import ChatOpenAI
from .EvalOutputParser import EvalOutputParser from .EvalOutputParser import EvalOutputParser
@ -79,7 +79,7 @@ class AgentBuilder:
if self.global_tools is None: if self.global_tools is None:
raise ValueError("Global tools must be initialized before agent") raise ValueError("Global tools must be initialized before agent")
return ChatAgent.from_llm_and_tools( return ConversationalChatAgent.from_llm_and_tools(
llm=self.llm, llm=self.llm,
tools=[ tools=[
*self.global_tools, *self.global_tools,

@ -150,12 +150,12 @@ class ConversationalChatAgent(Agent):
logging.error(f"Error while creating agent from LLM and tools: {str(e)}") logging.error(f"Error while creating agent from LLM and tools: {str(e)}")
raise e raise e
class OutputParser(AgentOutputParser): # class OutputParser(AgentOutputParser):
def parse(self, full_output: str) -> AgentAction: # def parse(self, full_output: str) -> AgentAction:
return AgentAction(action="chat", details={'message': full_output}) # return AgentAction(action="chat", details={'message': full_output})
class ChatAgent(ConversationalChatAgent): # class ChatAgent(ConversationalChatAgent):
def _get_default_output_parser(self): # def _get_default_output_parser(self):
"""Get default output parser for this class.""" # """Get default output parser for this class."""
return OutputParser() # return OutputParser()

Loading…
Cancel
Save