🐛 fix(base.py): fix method name in build_template_from_method call for MultiQueryRetriever
✨ feat(base.py): add support for ZepRetriever in from_method_nodes dictionary
The build_template_from_method call for the MultiQueryRetriever in the get_signature method was using the incorrect method name "from_llm". It has been fixed to use the correct method name "from_method_nodes". Additionally, support for the ZepRetriever has been added to the from_method_nodes dictionary to allow for its usage in the RetrieverCreator class.
This commit is contained in:
parent
e24ad0513b
commit
77cc23bf5f
1 changed files with 12 additions and 5 deletions
|
|
@ -7,13 +7,13 @@ from langflow.interface.importing.utils import import_class
|
||||||
from langflow.settings import settings
|
from langflow.settings import settings
|
||||||
from langflow.template.frontend_node.retrievers import RetrieverFrontendNode
|
from langflow.template.frontend_node.retrievers import RetrieverFrontendNode
|
||||||
from langflow.utils.logger import logger
|
from langflow.utils.logger import logger
|
||||||
from langflow.utils.util import build_template_from_method
|
from langflow.utils.util import build_template_from_method, build_template_from_class
|
||||||
|
|
||||||
|
|
||||||
class RetrieverCreator(LangChainTypeCreator):
|
class RetrieverCreator(LangChainTypeCreator):
|
||||||
type_name: str = "retrievers"
|
type_name: str = "retrievers"
|
||||||
|
|
||||||
from_method_nodes = {"MultiQueryRetriever": "from_llm"}
|
from_method_nodes = {"MultiQueryRetriever": "from_llm", "ZepRetriever": "__init__"}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def frontend_node_class(self) -> Type[RetrieverFrontendNode]:
|
def frontend_node_class(self) -> Type[RetrieverFrontendNode]:
|
||||||
|
|
@ -31,8 +31,15 @@ class RetrieverCreator(LangChainTypeCreator):
|
||||||
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:
|
||||||
|
if name in self.from_method_nodes:
|
||||||
return build_template_from_method(
|
return build_template_from_method(
|
||||||
name, type_to_cls_dict=self.type_to_loader_dict, method_name="from_llm"
|
name,
|
||||||
|
type_to_cls_dict=self.type_to_loader_dict,
|
||||||
|
method_name=self.from_method_nodes[name],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return build_template_from_class(
|
||||||
|
name, type_to_cls_dict=self.type_to_loader_dict
|
||||||
)
|
)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise ValueError(f"Retriever {name} not found") from exc
|
raise ValueError(f"Retriever {name} not found") from exc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue