refactor(embeddings/base.py): add EmbeddingFrontendNode as a property of EmbeddingCreator
fix(loading.py): remove headers from params before instantiating embedding refactor(nodes.py): add EmbeddingFrontendNode and hide headers field in it
This commit is contained in:
parent
f6d977f139
commit
1338fa3521
3 changed files with 16 additions and 1 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional, Type
|
||||||
|
|
||||||
from langflow.interface.base import LangChainTypeCreator
|
from langflow.interface.base import LangChainTypeCreator
|
||||||
from langflow.interface.custom_lists import embedding_type_to_cls_dict
|
from langflow.interface.custom_lists import embedding_type_to_cls_dict
|
||||||
from langflow.settings import settings
|
from langflow.settings import settings
|
||||||
|
from langflow.template.base import FrontendNode
|
||||||
|
from langflow.template.nodes import EmbeddingFrontendNode
|
||||||
from langflow.utils.logger import logger
|
from langflow.utils.logger import logger
|
||||||
from langflow.utils.util import build_template_from_class
|
from langflow.utils.util import build_template_from_class
|
||||||
|
|
||||||
|
|
@ -14,6 +16,10 @@ class EmbeddingCreator(LangChainTypeCreator):
|
||||||
def type_to_loader_dict(self) -> Dict:
|
def type_to_loader_dict(self) -> Dict:
|
||||||
return embedding_type_to_cls_dict
|
return embedding_type_to_cls_dict
|
||||||
|
|
||||||
|
@property
|
||||||
|
def frontend_node_class(self) -> Type[FrontendNode]:
|
||||||
|
return EmbeddingFrontendNode
|
||||||
|
|
||||||
def get_signature(self, name: str) -> Optional[Dict]:
|
def get_signature(self, name: str) -> Optional[Dict]:
|
||||||
"""Get the signature of an embedding."""
|
"""Get the signature of an embedding."""
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ def instantiate_toolkit(node_type, class_object, params):
|
||||||
|
|
||||||
def instantiate_embedding(class_object, params):
|
def instantiate_embedding(class_object, params):
|
||||||
params.pop("model", None)
|
params.pop("model", None)
|
||||||
|
params.pop("headers", None)
|
||||||
try:
|
try:
|
||||||
return class_object(**params)
|
return class_object(**params)
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
|
|
|
||||||
|
|
@ -614,3 +614,11 @@ class LLMFrontendNode(FrontendNode):
|
||||||
elif field.name in ["model_name", "temperature"]:
|
elif field.name in ["model_name", "temperature"]:
|
||||||
field.advanced = False
|
field.advanced = False
|
||||||
field.show = True
|
field.show = True
|
||||||
|
|
||||||
|
|
||||||
|
class EmbeddingFrontendNode(FrontendNode):
|
||||||
|
@staticmethod
|
||||||
|
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
|
||||||
|
FrontendNode.format_field(field, name)
|
||||||
|
if field.name == "headers":
|
||||||
|
field.show = False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue