🐛 fix(Metaphor.py): ignore type error for importing Metaphor from metaphor_python

🐛 fix(Metaphor.py): ignore type error for returning a list with mixed types
🐛 fix(Vectara.py): add condition to check if documents and embedding are not None before creating Vectara instance
🐛 fix(CustomComponent.py): change return type of get_function_entrypoint_return_type to List[str] to match the actual return value
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-09 15:53:18 -03:00
commit 29766ecaf0
3 changed files with 8 additions and 8 deletions

View file

@ -1,7 +1,7 @@
from typing import List, Union
from langflow import CustomComponent
from metaphor_python import Metaphor
from metaphor_python import Metaphor # type: ignore
from langchain.tools import Tool
from langchain.agents import tool
from langchain.agents.agent_toolkits.base import BaseToolkit
@ -48,4 +48,4 @@ class MetaphorToolkit(CustomComponent):
"""
return client.find_similar(url, num_results=5)
return [search, get_contents, find_similar]
return [search, get_contents, find_similar] # type: ignore

View file

@ -34,9 +34,9 @@ class VectaraComponent(CustomComponent):
documents: Optional[Document] = None,
) -> Union[VectorStore, BaseRetriever]:
# If documents, then we need to create a Vectara instance using .from_documents
if documents:
if documents is not None and embedding is not None:
return Vectara.from_documents(
documents=documents,
documents=documents, # type: ignore
vectara_customer_id=vectara_customer_id,
vectara_corpus_id=vectara_corpus_id,
vectara_api_key=vectara_api_key,

View file

@ -92,9 +92,9 @@ class CustomComponent(Component, extra=Extra.allow):
return build_method["args"]
@property
def get_function_entrypoint_return_type(self) -> str:
def get_function_entrypoint_return_type(self) -> List[str]:
if not self.code:
return ""
return []
tree = self.get_code_tree(self.code)
component_classes = [
@ -103,7 +103,7 @@ class CustomComponent(Component, extra=Extra.allow):
if self.code_class_base_inheritance in cls["bases"]
]
if not component_classes:
return ""
return []
# Assume the first Component class is the one we're interested in
component_class = component_classes[0]
@ -114,7 +114,7 @@ class CustomComponent(Component, extra=Extra.allow):
]
if not build_methods:
return ""
return []
build_method = build_methods[0]
return_type = build_method["return_type"]