From 29766ecaf0044bdff053f843141d85bfdf9b194b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 9 Aug 2023 15:53:18 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(Metaphor.py):=20ignore=20typ?= =?UTF-8?q?e=20error=20for=20importing=20Metaphor=20from=20metaphor=5Fpyth?= =?UTF-8?q?on=20=F0=9F=90=9B=20fix(Metaphor.py):=20ignore=20type=20error?= =?UTF-8?q?=20for=20returning=20a=20list=20with=20mixed=20types=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(Vectara.py):=20add=20condition=20to=20check?= =?UTF-8?q?=20if=20documents=20and=20embedding=20are=20not=20None=20before?= =?UTF-8?q?=20creating=20Vectara=20instance=20=F0=9F=90=9B=20fix(CustomCom?= =?UTF-8?q?ponent.py):=20change=20return=20type=20of=20get=5Ffunction=5Fen?= =?UTF-8?q?trypoint=5Freturn=5Ftype=20to=20List[str]=20to=20match=20the=20?= =?UTF-8?q?actual=20return=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/components/toolkits/Metaphor.py | 4 ++-- src/backend/langflow/components/vectorstores/Vectara.py | 4 ++-- src/backend/langflow/interface/custom/custom_component.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/langflow/components/toolkits/Metaphor.py b/src/backend/langflow/components/toolkits/Metaphor.py index aff949312..567071278 100644 --- a/src/backend/langflow/components/toolkits/Metaphor.py +++ b/src/backend/langflow/components/toolkits/Metaphor.py @@ -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 diff --git a/src/backend/langflow/components/vectorstores/Vectara.py b/src/backend/langflow/components/vectorstores/Vectara.py index 6576d146d..6edc69822 100644 --- a/src/backend/langflow/components/vectorstores/Vectara.py +++ b/src/backend/langflow/components/vectorstores/Vectara.py @@ -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, diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 15a414050..d7dd280e6 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -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"]