commit
ce48f0c6f6
3 changed files with 0 additions and 88 deletions
|
|
@ -13,7 +13,6 @@ CUSTOM_NODES = {
|
||||||
"agents": {
|
"agents": {
|
||||||
"JsonAgent": frontend_node.agents.JsonAgentNode(),
|
"JsonAgent": frontend_node.agents.JsonAgentNode(),
|
||||||
"CSVAgent": frontend_node.agents.CSVAgentNode(),
|
"CSVAgent": frontend_node.agents.CSVAgentNode(),
|
||||||
"AgentInitializer": frontend_node.agents.InitializeAgentNode(),
|
|
||||||
"VectorStoreAgent": frontend_node.agents.VectorStoreAgentNode(),
|
"VectorStoreAgent": frontend_node.agents.VectorStoreAgentNode(),
|
||||||
"VectorStoreRouterAgent": frontend_node.agents.VectorStoreRouterAgentNode(),
|
"VectorStoreRouterAgent": frontend_node.agents.VectorStoreRouterAgentNode(),
|
||||||
"SQLAgent": frontend_node.agents.SQLAgentNode(),
|
"SQLAgent": frontend_node.agents.SQLAgentNode(),
|
||||||
|
|
|
||||||
|
|
@ -264,45 +264,9 @@ class VectorStoreRouterAgent(CustomAgentExecutor):
|
||||||
return super().run(*args, **kwargs)
|
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 = {
|
CUSTOM_AGENTS = {
|
||||||
"JsonAgent": JsonAgent,
|
"JsonAgent": JsonAgent,
|
||||||
"CSVAgent": CSVAgent,
|
"CSVAgent": CSVAgent,
|
||||||
"AgentInitializer": InitializeAgent,
|
|
||||||
"VectorStoreAgent": VectorStoreAgent,
|
"VectorStoreAgent": VectorStoreAgent,
|
||||||
"VectorStoreRouterAgent": VectorStoreRouterAgent,
|
"VectorStoreRouterAgent": VectorStoreRouterAgent,
|
||||||
"SQLAgent": SQLAgent,
|
"SQLAgent": SQLAgent,
|
||||||
|
|
|
||||||
|
|
@ -146,57 +146,6 @@ class CSVAgentNode(FrontendNode):
|
||||||
base_classes: list[str] = ["AgentExecutor"]
|
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):
|
class JsonAgentNode(FrontendNode):
|
||||||
name: str = "JsonAgent"
|
name: str = "JsonAgent"
|
||||||
template: Template = Template(
|
template: Template = Template(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue