Merge remote-tracking branch 'origin/main' into dev
This commit is contained in:
commit
3a324ed45a
6 changed files with 536 additions and 18 deletions
|
|
@ -3,7 +3,7 @@ agents:
|
||||||
- ZeroShotAgent
|
- ZeroShotAgent
|
||||||
- JsonAgent
|
- JsonAgent
|
||||||
- CSVAgent
|
- CSVAgent
|
||||||
- initialize_agent
|
- AgentInitializer
|
||||||
- VectorStoreAgent
|
- VectorStoreAgent
|
||||||
- VectorStoreRouterAgent
|
- VectorStoreRouterAgent
|
||||||
- SQLAgent
|
- SQLAgent
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ CUSTOM_NODES = {
|
||||||
"agents": {
|
"agents": {
|
||||||
"JsonAgent": frontend_node.agents.JsonAgentNode(),
|
"JsonAgent": frontend_node.agents.JsonAgentNode(),
|
||||||
"CSVAgent": frontend_node.agents.CSVAgentNode(),
|
"CSVAgent": frontend_node.agents.CSVAgentNode(),
|
||||||
"initialize_agent": frontend_node.agents.InitializeAgentNode(),
|
"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(),
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,9 @@ class JsonAgent(CustomAgentExecutor):
|
||||||
llm=llm,
|
llm=llm,
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
)
|
)
|
||||||
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names) # type: ignore
|
agent = ZeroShotAgent(
|
||||||
|
llm_chain=llm_chain, allowed_tools=tool_names # type: ignore
|
||||||
|
)
|
||||||
return cls.from_agent_and_tools(agent=agent, tools=tools, verbose=True)
|
return cls.from_agent_and_tools(agent=agent, tools=tools, verbose=True)
|
||||||
|
|
||||||
def run(self, *args, **kwargs):
|
def run(self, *args, **kwargs):
|
||||||
|
|
@ -111,7 +113,9 @@ class CSVAgent(CustomAgentExecutor):
|
||||||
prompt=partial_prompt,
|
prompt=partial_prompt,
|
||||||
)
|
)
|
||||||
tool_names = {tool.name for tool in tools}
|
tool_names = {tool.name for tool in tools}
|
||||||
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs) # type: ignore
|
agent = ZeroShotAgent(
|
||||||
|
llm_chain=llm_chain, allowed_tools=tool_names, **kwargs # type: ignore
|
||||||
|
)
|
||||||
|
|
||||||
return cls.from_agent_and_tools(agent=agent, tools=tools, verbose=True)
|
return cls.from_agent_and_tools(agent=agent, tools=tools, verbose=True)
|
||||||
|
|
||||||
|
|
@ -148,7 +152,9 @@ class VectorStoreAgent(CustomAgentExecutor):
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
)
|
)
|
||||||
tool_names = {tool.name for tool in tools}
|
tool_names = {tool.name for tool in tools}
|
||||||
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs) # type: ignore
|
agent = ZeroShotAgent(
|
||||||
|
llm_chain=llm_chain, allowed_tools=tool_names, **kwargs # type: ignore
|
||||||
|
)
|
||||||
return AgentExecutor.from_agent_and_tools(
|
return AgentExecutor.from_agent_and_tools(
|
||||||
agent=agent, tools=tools, verbose=True
|
agent=agent, tools=tools, verbose=True
|
||||||
)
|
)
|
||||||
|
|
@ -216,7 +222,9 @@ class SQLAgent(CustomAgentExecutor):
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
)
|
)
|
||||||
tool_names = {tool.name for tool in tools} # type: ignore
|
tool_names = {tool.name for tool in tools} # type: ignore
|
||||||
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs) # type: ignore
|
agent = ZeroShotAgent(
|
||||||
|
llm_chain=llm_chain, allowed_tools=tool_names, **kwargs # type: ignore
|
||||||
|
)
|
||||||
return AgentExecutor.from_agent_and_tools(
|
return AgentExecutor.from_agent_and_tools(
|
||||||
agent=agent,
|
agent=agent,
|
||||||
tools=tools, # type: ignore
|
tools=tools, # type: ignore
|
||||||
|
|
@ -263,7 +271,9 @@ class VectorStoreRouterAgent(CustomAgentExecutor):
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
)
|
)
|
||||||
tool_names = {tool.name for tool in tools}
|
tool_names = {tool.name for tool in tools}
|
||||||
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs) # type: ignore
|
agent = ZeroShotAgent(
|
||||||
|
llm_chain=llm_chain, allowed_tools=tool_names, **kwargs # type: ignore
|
||||||
|
)
|
||||||
return AgentExecutor.from_agent_and_tools(
|
return AgentExecutor.from_agent_and_tools(
|
||||||
agent=agent, tools=tools, verbose=True
|
agent=agent, tools=tools, verbose=True
|
||||||
)
|
)
|
||||||
|
|
@ -273,11 +283,11 @@ class VectorStoreRouterAgent(CustomAgentExecutor):
|
||||||
|
|
||||||
|
|
||||||
class InitializeAgent(CustomAgentExecutor):
|
class InitializeAgent(CustomAgentExecutor):
|
||||||
"""Implementation of initialize_agent function"""
|
"""Implementation of AgentInitializer function"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def function_name():
|
def function_name():
|
||||||
return "initialize_agent"
|
return "AgentInitializer"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(
|
def initialize(
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ class TimeTravelGuideChain(BaseCustomConversationChain):
|
||||||
|
|
||||||
|
|
||||||
class CombineDocsChain(CustomChain):
|
class CombineDocsChain(CustomChain):
|
||||||
"""Implementation of initialize_agent function"""
|
"""Implementation of load_qa_chain function"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def function_name():
|
def function_name():
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ from langflow.interface.importing.utils import import_class
|
||||||
from langflow.interface.agents.custom import CUSTOM_AGENTS
|
from langflow.interface.agents.custom import CUSTOM_AGENTS
|
||||||
from langflow.interface.chains.custom import CUSTOM_CHAINS
|
from langflow.interface.chains.custom import CUSTOM_CHAINS
|
||||||
|
|
||||||
## LLMs
|
# LLMs
|
||||||
llm_type_to_cls_dict = llms.type_to_cls_dict
|
llm_type_to_cls_dict = llms.type_to_cls_dict
|
||||||
llm_type_to_cls_dict["anthropic-chat"] = ChatAnthropic # type: ignore
|
llm_type_to_cls_dict["anthropic-chat"] = ChatAnthropic # type: ignore
|
||||||
llm_type_to_cls_dict["azure-chat"] = AzureChatOpenAI # type: ignore
|
llm_type_to_cls_dict["azure-chat"] = AzureChatOpenAI # type: ignore
|
||||||
llm_type_to_cls_dict["openai-chat"] = ChatOpenAI # type: ignore
|
llm_type_to_cls_dict["openai-chat"] = ChatOpenAI # type: ignore
|
||||||
|
|
||||||
|
|
||||||
## Toolkits
|
# Toolkits
|
||||||
toolkit_type_to_loader_dict: dict[str, Any] = {
|
toolkit_type_to_loader_dict: dict[str, Any] = {
|
||||||
toolkit_name: import_class(f"langchain.agents.agent_toolkits.{toolkit_name}")
|
toolkit_name: import_class(f"langchain.agents.agent_toolkits.{toolkit_name}")
|
||||||
# if toolkit_name is lower case it is a loader
|
# if toolkit_name is lower case it is a loader
|
||||||
|
|
@ -39,25 +39,25 @@ toolkit_type_to_cls_dict: dict[str, Any] = {
|
||||||
if not toolkit_name.islower()
|
if not toolkit_name.islower()
|
||||||
}
|
}
|
||||||
|
|
||||||
## Memories
|
# Memories
|
||||||
memory_type_to_cls_dict: dict[str, Any] = {
|
memory_type_to_cls_dict: dict[str, Any] = {
|
||||||
memory_name: import_class(f"langchain.memory.{memory_name}")
|
memory_name: import_class(f"langchain.memory.{memory_name}")
|
||||||
for memory_name in memory.__all__
|
for memory_name in memory.__all__
|
||||||
}
|
}
|
||||||
|
|
||||||
## Wrappers
|
# Wrappers
|
||||||
wrapper_type_to_cls_dict: dict[str, Any] = {
|
wrapper_type_to_cls_dict: dict[str, Any] = {
|
||||||
wrapper.__name__: wrapper for wrapper in [requests.RequestsWrapper]
|
wrapper.__name__: wrapper for wrapper in [requests.RequestsWrapper]
|
||||||
}
|
}
|
||||||
|
|
||||||
## Embeddings
|
# Embeddings
|
||||||
embedding_type_to_cls_dict: dict[str, Any] = {
|
embedding_type_to_cls_dict: dict[str, Any] = {
|
||||||
embedding_name: import_class(f"langchain.embeddings.{embedding_name}")
|
embedding_name: import_class(f"langchain.embeddings.{embedding_name}")
|
||||||
for embedding_name in embeddings.__all__
|
for embedding_name in embeddings.__all__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## Document Loaders
|
# Document Loaders
|
||||||
documentloaders_type_to_cls_dict: dict[str, Any] = {
|
documentloaders_type_to_cls_dict: dict[str, Any] = {
|
||||||
documentloader_name: import_class(
|
documentloader_name: import_class(
|
||||||
f"langchain.document_loaders.{documentloader_name}"
|
f"langchain.document_loaders.{documentloader_name}"
|
||||||
|
|
@ -65,7 +65,7 @@ documentloaders_type_to_cls_dict: dict[str, Any] = {
|
||||||
for documentloader_name in document_loaders.__all__
|
for documentloader_name in document_loaders.__all__
|
||||||
}
|
}
|
||||||
|
|
||||||
## Text Splitters
|
# Text Splitters
|
||||||
textsplitter_type_to_cls_dict: dict[str, Any] = dict(
|
textsplitter_type_to_cls_dict: dict[str, Any] = dict(
|
||||||
inspect.getmembers(text_splitter, inspect.isclass)
|
inspect.getmembers(text_splitter, inspect.isclass)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue