fix(langflow): return None when a node is not loaded in LangChainTypeCreator classes

This commit is contained in:
Gabriel Almeida 2023-04-13 15:54:40 -03:00
commit ce542e9337
12 changed files with 12 additions and 1 deletions

View file

@ -34,6 +34,7 @@ class AgentCreator(LangChainTypeCreator):
raise ValueError("Agent not found") from exc
except AttributeError as exc:
logger.error(f"Agent {name} not loaded: {exc}")
return None
# Now this is a generator
def to_list(self) -> List[str]:

View file

@ -51,7 +51,7 @@ class LangChainTypeCreator(BaseModel, ABC):
signature = self.get_signature(name)
if signature is None:
logger.error(f"Node {name} not loaded")
return
return None
if isinstance(signature, FrontendNode):
return signature
fields = [

View file

@ -42,6 +42,7 @@ class ChainCreator(LangChainTypeCreator):
raise ValueError("Chain not found") from exc
except AttributeError as exc:
logger.error(f"Chain {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
custom_chains = list(get_custom_nodes("chains").keys())

View file

@ -133,6 +133,7 @@ class DocumentLoaderCreator(LangChainTypeCreator):
raise ValueError(f"Documment Loader {name} not found") from exc
except AttributeError as exc:
logger.error(f"Documment Loader {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return [

View file

@ -23,6 +23,7 @@ class EmbeddingCreator(LangChainTypeCreator):
except AttributeError as exc:
logger.error(f"Embedding {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return [

View file

@ -30,6 +30,7 @@ class LLMCreator(LangChainTypeCreator):
except AttributeError as exc:
logger.error(f"LLM {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return [

View file

@ -31,6 +31,7 @@ class MemoryCreator(LangChainTypeCreator):
raise ValueError("Memory not found") from exc
except AttributeError as exc:
logger.error(f"Memory {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return [

View file

@ -48,6 +48,7 @@ class PromptCreator(LangChainTypeCreator):
logger.error(f"Prompt {name} not found: {exc}")
except AttributeError as exc:
logger.error(f"Prompt {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
custom_prompts = get_custom_nodes("prompts")

View file

@ -58,6 +58,7 @@ class TextSplitterCreator(LangChainTypeCreator):
raise ValueError(f"Text Splitter {name} not found") from exc
except AttributeError as exc:
logger.error(f"Text Splitter {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return [

View file

@ -47,6 +47,7 @@ class ToolkitCreator(LangChainTypeCreator):
raise ValueError("Prompt not found") from exc
except AttributeError as exc:
logger.error(f"Prompt {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return list(self.type_to_loader_dict.keys())

View file

@ -42,6 +42,7 @@ class VectorstoreCreator(LangChainTypeCreator):
raise ValueError(f"Vector Store {name} not found") from exc
except AttributeError as exc:
logger.error(f"Vector Store {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return [

View file

@ -25,6 +25,7 @@ class WrapperCreator(LangChainTypeCreator):
raise ValueError("Wrapper not found") from exc
except AttributeError as exc:
logger.error(f"Wrapper {name} not loaded: {exc}")
return None
def to_list(self) -> List[str]:
return list(self.type_to_loader_dict.keys())