feat: get_signature can return the FrontendNode directly now
This commit is contained in:
parent
5a231ae941
commit
43c4fe7dfc
4 changed files with 10 additions and 12 deletions
|
|
@ -1,14 +1,12 @@
|
|||
from langflow.template import nodes
|
||||
|
||||
CUSTOM_NODES = {
|
||||
"prompts": {
|
||||
**nodes.ZeroShotPromptNode().to_dict(),
|
||||
},
|
||||
"tools": {**nodes.PythonFunctionNode().to_dict(), **nodes.ToolNode().to_dict()},
|
||||
"prompts": {"ZeroShotPrompt": nodes.ZeroShotPromptNode()},
|
||||
"tools": {"PythonFunction": nodes.PythonFunctionNode(), "Tool": nodes.ToolNode()},
|
||||
"agents": {
|
||||
**nodes.JsonAgentNode().to_dict(),
|
||||
**nodes.CSVAgentNode().to_dict(),
|
||||
**nodes.InitializeAgentNode().to_dict(),
|
||||
"JsonAgent": nodes.JsonAgentNode(),
|
||||
"CSVAgent": nodes.CSVAgentNode(),
|
||||
"InitializeAgent": nodes.InitializeAgentNode(),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class LangChainTypeCreator(BaseModel, ABC):
|
|||
return self.type_dict
|
||||
|
||||
@abstractmethod
|
||||
def get_signature(self, name: str) -> Optional[Dict[Any, Any]]:
|
||||
def get_signature(self, name: str) -> Union[Optional[Dict[Any, Any]], FrontendNode]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
|
@ -42,6 +42,8 @@ class LangChainTypeCreator(BaseModel, ABC):
|
|||
signature = self.get_signature(name)
|
||||
if signature is None:
|
||||
raise ValueError(f"{name} not found")
|
||||
if isinstance(signature, FrontendNode):
|
||||
return signature
|
||||
fields = [
|
||||
TemplateField(
|
||||
name=key,
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ class TemplateFieldCreator(BaseModel, ABC):
|
|||
if "List" in _type:
|
||||
_type = _type.replace("List[", "")[:-1]
|
||||
self.is_list = True
|
||||
else:
|
||||
self.is_list = False
|
||||
|
||||
# Replace 'Mapping' with 'dict'
|
||||
if "Mapping" in _type:
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class JsonAgentNode(FrontendNode):
|
|||
|
||||
|
||||
class InitializeAgentNode(FrontendNode):
|
||||
name: str = "InializeAgent"
|
||||
name: str = "InitializeAgent"
|
||||
template: Template = Template(
|
||||
type_name="initailize_agent",
|
||||
fields=[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue