🔧 chore(constants.py): clean up import statements and remove unnecessary whitespace to improve code readability
🐛 fix(custom_component.py): set the type of argument to "Data" if it is not specified to ensure consistency and prevent errors
This commit is contained in:
parent
4366b02c4f
commit
7bdf564170
2 changed files with 24 additions and 4 deletions
|
|
@ -1,15 +1,33 @@
|
||||||
DEFAULT_CUSTOM_COMPONENT_CODE = """from langflow import CustomComponent
|
DEFAULT_CUSTOM_COMPONENT_CODE = """from langflow import CustomComponent
|
||||||
|
|
||||||
from langflow.field_typing import *
|
from langflow.field_typing import (
|
||||||
|
Tool,
|
||||||
|
PromptTemplate,
|
||||||
|
Chain,
|
||||||
|
BaseChatMemory,
|
||||||
|
BaseLLM,
|
||||||
|
BaseLoader,
|
||||||
|
BaseMemory,
|
||||||
|
BaseOutputParser,
|
||||||
|
BaseRetriever,
|
||||||
|
VectorStore,
|
||||||
|
Embeddings,
|
||||||
|
TextSplitter,
|
||||||
|
Document,
|
||||||
|
AgentExecutor,
|
||||||
|
NestedDict,
|
||||||
|
Data,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Component(CustomComponent):
|
class Component(CustomComponent):
|
||||||
display_name: str = "Custom Component"
|
display_name: str = "Custom Component"
|
||||||
description: str = "Create any custom component you want!"
|
description: str = "Create any custom component you want!"
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return { "param": { "display_name": "Parameter" } }
|
return {"param": {"display_name": "Parameter"}}
|
||||||
|
|
||||||
def build(self, param: Data) -> Data:
|
def build(self, param: Data) -> Data:
|
||||||
return params
|
return param
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,9 @@ class CustomComponent(Component, extra=Extra.allow):
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
# TODO arg type should be Data if it is None
|
elif not arg.get("type"):
|
||||||
|
# Set the type to Data
|
||||||
|
arg["type"] = "Data"
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue