Cleanup AgentInitializer component

This commit is contained in:
Yassine Selmi 2023-12-19 20:39:53 +00:00
commit 85fc2c1013
3 changed files with 0 additions and 88 deletions

View file

@ -13,7 +13,6 @@ CUSTOM_NODES = {
"agents": {
"JsonAgent": frontend_node.agents.JsonAgentNode(),
"CSVAgent": frontend_node.agents.CSVAgentNode(),
"AgentInitializer": frontend_node.agents.InitializeAgentNode(),
"VectorStoreAgent": frontend_node.agents.VectorStoreAgentNode(),
"VectorStoreRouterAgent": frontend_node.agents.VectorStoreRouterAgentNode(),
"SQLAgent": frontend_node.agents.SQLAgentNode(),

View file

@ -264,45 +264,9 @@ class VectorStoreRouterAgent(CustomAgentExecutor):
return super().run(*args, **kwargs)
class InitializeAgent(CustomAgentExecutor):
"""Implementation of AgentInitializer function"""
@staticmethod
def function_name():
return "AgentInitializer"
@classmethod
def initialize(
cls,
llm: BaseLanguageModel,
tools: List[Tool],
agent: str,
memory: Optional[BaseChatMemory] = None,
):
# Find which value in the AgentType enum corresponds to the string
# passed in as agent
agent = AgentType(agent)
return initialize_agent(
tools=tools,
llm=llm,
# LangChain now uses Enum for agent, but we still support string
agent=agent, # type: ignore
memory=memory,
return_intermediate_steps=True,
handle_parsing_errors=True,
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def run(self, *args, **kwargs):
return super().run(*args, **kwargs)
CUSTOM_AGENTS = {
"JsonAgent": JsonAgent,
"CSVAgent": CSVAgent,
"AgentInitializer": InitializeAgent,
"VectorStoreAgent": VectorStoreAgent,
"VectorStoreRouterAgent": VectorStoreRouterAgent,
"SQLAgent": SQLAgent,

View file

@ -146,57 +146,6 @@ class CSVAgentNode(FrontendNode):
base_classes: list[str] = ["AgentExecutor"]
class InitializeAgentNode(FrontendNode):
name: str = "AgentInitializer"
display_name: str = "AgentInitializer"
template: Template = Template(
type_name="initialize_agent",
fields=[
TemplateField(
field_type="str", # pyright: ignore
required=True,
is_list=True, # pyright: ignore
show=True,
multiline=False,
options=list(NON_CHAT_AGENTS.keys()),
value=list(NON_CHAT_AGENTS.keys())[0],
name="agent",
advanced=False,
),
TemplateField(
field_type="BaseChatMemory", # pyright: ignore
required=False,
show=True,
name="memory",
advanced=False,
),
TemplateField(
field_type="Tool", # pyright: ignore
required=True,
show=True,
name="tools",
is_list=True, # pyright: ignore
advanced=False,
),
TemplateField(
field_type="BaseLanguageModel", # pyright: ignore
required=True,
show=True,
name="llm",
display_name="LLM",
advanced=False,
),
],
)
description: str = """Construct a zero shot agent from an LLM and tools."""
base_classes: list[str] = ["AgentExecutor", "Callable"]
@staticmethod
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
# do nothing and don't return anything
pass
class JsonAgentNode(FrontendNode):
name: str = "JsonAgent"
template: Template = Template(