From 3be8ac0d72e26fdae5a88d53cea34721c7f5fc2c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 24 Jun 2023 16:31:39 -0300 Subject: [PATCH 01/21] Update settings structure --- src/backend/langflow/config.yaml | 358 ++++++++++++++++++++----------- src/backend/langflow/settings.py | 27 ++- 2 files changed, 243 insertions(+), 142 deletions(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index d8cd4a325..a8f4f6b53 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -1,141 +1,243 @@ ---- agents: - - ZeroShotAgent - - JsonAgent - - CSVAgent - - AgentInitializer - - VectorStoreAgent - - VectorStoreRouterAgent - - SQLAgent + ZeroShotAgent: + documentation: "https://python.langchain.com/docs/modules/agents/how_to/custom_mrkl_agent" + JsonAgent: + documentation: "https://python.langchain.com/docs/modules/agents/toolkits/openapi" + CSVAgent: + documentation: "https://python.langchain.com/docs/modules/agents/toolkits/csv" + AgentInitializer: + documentation: "https://python.langchain.com/docs/modules/agents/agent_types/" + VectorStoreAgent: + documentation: "https://example.com/VectorStoreAgent" + VectorStoreRouterAgent: + documentation: "https://example.com/VectorStoreRouterAgent" + SQLAgent: + documentation: "https://example.com/SQLAgent" chains: - - LLMChain - - LLMMathChain - - LLMCheckerChain - - ConversationChain - - SeriesCharacterChain - - MidJourneyPromptChain - - TimeTravelGuideChain - - SQLDatabaseChain - - RetrievalQA - - RetrievalQAWithSourcesChain - - ConversationalRetrievalChain - - CombineDocsChain + LLMChain: + documentation: "https://python.langchain.com/docs/modules/chains/foundational/llm_chain" + LLMMathChain: + documentation: "https://python.langchain.com/docs/modules/chains/additional/llm_math" + LLMCheckerChain: + documentation: "https://python.langchain.com/docs/modules/chains/additional/llm_checker" + ConversationChain: + documentation: "https://example.com/ConversationChain" + SeriesCharacterChain: + documentation: "https://example.com/SeriesCharacterChain" + MidJourneyPromptChain: + documentation: "https://example.com/MidJourneyPromptChain" + TimeTravelGuideChain: + documentation: "https://example.com/TimeTravelGuideChain" + SQLDatabaseChain: + documentation: "https://example.com/SQLDatabaseChain" + RetrievalQA: + documentation: "https://python.langchain.com/docs/modules/chains/popular/vector_db_qa" + RetrievalQAWithSourcesChain: + documentation: "https://example.com/RetrievalQAWithSourcesChain" + ConversationalRetrievalChain: + documentation: "https://python.langchain.com/docs/modules/chains/popular/chat_vector_db" + CombineDocsChain: + documentation: "https://example.com/CombineDocsChain" documentloaders: - - AirbyteJSONLoader - - CoNLLULoader - - CSVLoader - - UnstructuredEmailLoader - - EverNoteLoader - - FacebookChatLoader - - GutenbergLoader - - BSHTMLLoader - - UnstructuredHTMLLoader - # - UnstructuredImageLoader # Issue with Python 3.11 (https://github.com/Unstructured-IO/unstructured-inference/issues/83) - - UnstructuredMarkdownLoader - - PyPDFLoader - - UnstructuredPowerPointLoader - - SRTLoader - - TelegramChatLoader - - TextLoader - - UnstructuredWordDocumentLoader - - WebBaseLoader - - AZLyricsLoader - - CollegeConfidentialLoader - - HNLoader - - IFixitLoader - - IMSDbLoader - - GitbookLoader - - ReadTheDocsLoader - - SlackDirectoryLoader - - NotionDirectoryLoader - - DirectoryLoader - - GitLoader + AirbyteJSONLoader: + documentation: "https://example.com/AirbyteJSONLoader" + CoNLLULoader: + documentation: "https://example.com/CoNLLULoader" + CSVLoader: + documentation: "https://example.com/CSVLoader" + UnstructuredEmailLoader: + documentation: "https://example.com/UnstructuredEmailLoader" + EverNoteLoader: + documentation: "https://example.com/EverNoteLoader" + FacebookChatLoader: + documentation: "https://example.com/FacebookChatLoader" + GutenbergLoader: + documentation: "https://example.com/GutenbergLoader" + BSHTMLLoader: + documentation: "https://example.com/BSHTMLLoader" + UnstructuredHTMLLoader: + documentation: "https://example.com/UnstructuredHTMLLoader" + UnstructuredMarkdownLoader: + documentation: "https://example.com/UnstructuredMarkdownLoader" + PyPDFLoader: + documentation: "https://example.com/PyPDFLoader" + UnstructuredPowerPointLoader: + documentation: "https://example.com/UnstructuredPowerPointLoader" + SRTLoader: + documentation: "https://example.com/SRTLoader" + TelegramChatLoader: + documentation: "https://example.com/TelegramChatLoader" + TextLoader: + documentation: "https://example.com/TextLoader" + UnstructuredWordDocumentLoader: + documentation: "https://example.com/UnstructuredWordDocumentLoader" + WebBaseLoader: + documentation: "https://example.com/WebBaseLoader" + AZLyricsLoader: + documentation: "https://example.com/AZLyricsLoader" + CollegeConfidentialLoader: + documentation: "https://example.com/CollegeConfidentialLoader" + HNLoader: + documentation: "https://example.com/HNLoader" + IFixitLoader: + documentation: "https://example.com/IFixitLoader" + IMSDbLoader: + documentation: "https://example.com/IMSDbLoader" + GitbookLoader: + documentation: "https://example.com/GitbookLoader" + ReadTheDocsLoader: + documentation: "https://example.com/ReadTheDocsLoader" + SlackDirectoryLoader: + documentation: "https://example.com/SlackDirectoryLoader" + NotionDirectoryLoader: + documentation: "https://example.com/NotionDirectoryLoader" + DirectoryLoader: + documentation: "https://example.com/DirectoryLoader" + GitLoader: + documentation: "https://example.com/GitLoader" embeddings: - - OpenAIEmbeddings - - HuggingFaceEmbeddings - - CohereEmbeddings + OpenAIEmbeddings: + documentation: "https://example.com/OpenAIEmbeddings" + HuggingFaceEmbeddings: + documentation: "https://example.com/HuggingFaceEmbeddings" + CohereEmbeddings: + documentation: "https://example.com/CohereEmbeddings" llms: - - OpenAI - # - AzureOpenAI - # - AzureChatOpenAI - - ChatOpenAI - - LlamaCpp - - CTransformers - - Cohere - - Anthropic - - ChatAnthropic - - HuggingFaceHub + OpenAI: + documentation: "https://example.com/OpenAI" + ChatOpenAI: + documentation: "https://example.com/ChatOpenAI" + LlamaCpp: + documentation: "https://example.com/LlamaCpp" + CTransformers: + documentation: "https://example.com/CTransformers" + Cohere: + documentation: "https://example.com/Cohere" + Anthropic: + documentation: "https://example.com/Anthropic" + ChatAnthropic: + documentation: "https://example.com/ChatAnthropic" + HuggingFaceHub: + documentation: "https://example.com/HuggingFaceHub" memories: - - ConversationBufferMemory - - ConversationSummaryMemory - - ConversationKGMemory + ConversationBufferMemory: + documentation: "https://example.com/ConversationBufferMemory" + ConversationSummaryMemory: + documentation: "https://example.com/ConversationSummaryMemory" + ConversationKGMemory: + documentation: "https://example.com/ConversationKGMemory" prompts: - - PromptTemplate - - FewShotPromptTemplate - - ZeroShotPrompt + PromptTemplate: + documentation: "https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/" + ZeroShotPrompt: + documentation: "https://python.langchain.com/docs/modules/agents/how_to/custom_mrkl_agent" textsplitters: - - CharacterTextSplitter - - RecursiveCharacterTextSplitter - # - LatexTextSplitter - # - PythonCodeTextSplitter + CharacterTextSplitter: + documentation: "https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/character_text_splitter" + RecursiveCharacterTextSplitter: + documentation: "https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/recursive_text_splitter" toolkits: - - OpenAPIToolkit - - JsonToolkit - - VectorStoreInfo - - VectorStoreRouterToolkit - - VectorStoreToolkit + OpenAPIToolkit: + documentation: "https://example.com/OpenAPIToolkit" + JsonToolkit: + documentation: "https://example.com/JsonToolkit" + VectorStoreInfo: + documentation: "https://example.com/VectorStoreInfo" + VectorStoreRouterToolkit: + documentation: "https://example.com/VectorStoreRouterToolkit" + VectorStoreToolkit: + documentation: "https://example.com/VectorStoreToolkit" tools: - - Search - - PAL-MATH - - Calculator - - Serper Search - - Tool - - PythonFunctionTool - - PythonFunction - - JsonSpec - - News API - - TMDB API - - Podcast API - - QuerySQLDataBaseTool - - InfoSQLDatabaseTool - - ListSQLDatabaseTool - # - QueryCheckerTool - - BingSearchRun - - GoogleSearchRun - - GoogleSearchResults - - GoogleSerperRun - - JsonListKeysTool - - JsonGetValueTool - - PythonREPLTool - - PythonAstREPLTool - - RequestsGetTool - - RequestsPostTool - - RequestsPatchTool - - RequestsPutTool - - RequestsDeleteTool - - WikipediaQueryRun - - WolframAlphaQueryRun + Search: + documentation: "https://example.com/Search" + PAL-MATH: + documentation: "https://example.com/PAL-MATH" + Calculator: + documentation: "https://example.com/Calculator" + Serper Search: + documentation: "https://example.com/SerperSearch" + Tool: + documentation: "https://example.com/Tool" + PythonFunctionTool: + documentation: "https://example.com/PythonFunctionTool" + PythonFunction: + documentation: "https://example.com/PythonFunction" + JsonSpec: + documentation: "https://example.com/JsonSpec" + News API: + documentation: "https://example.com/NewsAPI" + TMDB API: + documentation: "https://example.com/TMDBAPI" + Podcast API: + documentation: "https://example.com/PodcastAPI" + QuerySQLDataBaseTool: + documentation: "https://example.com/QuerySQLDataBaseTool" + InfoSQLDatabaseTool: + documentation: "https://example.com/InfoSQLDatabaseTool" + ListSQLDatabaseTool: + documentation: "https://example.com/ListSQLDatabaseTool" + BingSearchRun: + documentation: "https://example.com/BingSearchRun" + GoogleSearchRun: + documentation: "https://example.com/GoogleSearchRun" + GoogleSearchResults: + documentation: "https://example.com/GoogleSearchResults" + GoogleSerperRun: + documentation: "https://example.com/GoogleSerperRun" + JsonListKeysTool: + documentation: "https://example.com/JsonListKeysTool" + JsonGetValueTool: + documentation: "https://example.com/JsonGetValueTool" + PythonREPLTool: + documentation: "https://example.com/PythonREPLTool" + PythonAstREPLTool: + documentation: "https://example.com/PythonAstREPLTool" + RequestsGetTool: + documentation: "https://example.com/RequestsGetTool" + RequestsPostTool: + documentation: "https://example.com/RequestsPostTool" + RequestsPatchTool: + documentation: "https://example.com/RequestsPatchTool" + RequestsPutTool: + documentation: "https://example.com/RequestsPutTool" + RequestsDeleteTool: + documentation: "https://example.com/RequestsDeleteTool" + WikipediaQueryRun: + documentation: "https://example.com/WikipediaQueryRun" + WolframAlphaQueryRun: + documentation: "https://example.com/WolframAlphaQueryRun" utilities: - - BingSearchAPIWrapper - - GoogleSearchAPIWrapper - - GoogleSerperAPIWrapper - - SearxResults - - SearxSearchWrapper - - SerpAPIWrapper - - WikipediaAPIWrapper - - WolframAlphaAPIWrapper - # - ZapierNLAWrapper - - SQLDatabase + BingSearchAPIWrapper: + documentation: "https://example.com/BingSearchAPIWrapper" + GoogleSearchAPIWrapper: + documentation: "https://example.com/GoogleSearchAPIWrapper" + GoogleSerperAPIWrapper: + documentation: "https://example.com/GoogleSerperAPIWrapper" + SearxResults: + documentation: "https://example.com/SearxResults" + SearxSearchWrapper: + documentation: "https://example.com/SearxSearchWrapper" + SerpAPIWrapper: + documentation: "https://example.com/SerpAPIWrapper" + WikipediaAPIWrapper: + documentation: "https://example.com/WikipediaAPIWrapper" + WolframAlphaAPIWrapper: + documentation: "https://example.com/WolframAlphaAPIWrapper" vectorstores: - - Chroma - - Qdrant - - Weaviate - - FAISS - - Pinecone - - SupabaseVectorStore - - MongoDBAtlasVectorSearch + Chroma: + documentation: "https://example.com/Chroma" + Qdrant: + documentation: "https://example.com/Qdrant" + Weaviate: + documentation: "https://example.com/Weaviate" + FAISS: + documentation: "https://example.com/FAISS" + Pinecone: + documentation: "https://example.com/Pinecone" + SupabaseVectorStore: + documentation: "https://example.com/SupabaseVectorStore" + MongoDBAtlasVectorSearch: + documentation: "https://example.com/MongoDBAtlasVectorSearch" wrappers: - - RequestsWrapper - # - ChatPromptTemplate - # - SystemMessagePromptTemplate - # - HumanMessagePromptTemplate + RequestsWrapper: + documentation: "https://example.com/RequestsWrapper" diff --git a/src/backend/langflow/settings.py b/src/backend/langflow/settings.py index 9d6ac3fa9..fac0dab8b 100644 --- a/src/backend/langflow/settings.py +++ b/src/backend/langflow/settings.py @@ -1,24 +1,23 @@ import os -from typing import List import yaml from pydantic import BaseSettings, root_validator class Settings(BaseSettings): - chains: List[str] = [] - agents: List[str] = [] - prompts: List[str] = [] - llms: List[str] = [] - tools: List[str] = [] - memories: List[str] = [] - embeddings: List[str] = [] - vectorstores: List[str] = [] - documentloaders: List[str] = [] - wrappers: List[str] = [] - toolkits: List[str] = [] - textsplitters: List[str] = [] - utilities: List[str] = [] + chains: dict = {} + agents: dict = {} + prompts: dict = {} + llms: dict = {} + tools: dict = {} + memories: dict = {} + embeddings: dict = {} + vectorstores: dict = {} + documentloaders: dict = {} + wrappers: dict = {} + toolkits: dict = {} + textsplitters: dict = {} + utilities: dict = {} dev: bool = False database_url: str = "sqlite:///./langflow.db" remove_api_keys: bool = False From 08cdc15d98bc850680584503be74218333beaa7b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 24 Jun 2023 16:31:47 -0300 Subject: [PATCH 02/21] =?UTF-8?q?=F0=9F=94=8D=20refactor(base.py):=20add?= =?UTF-8?q?=20documentation=20support=20to=20LangChainTypeCreator=20This?= =?UTF-8?q?=20commit=20adds=20a=20new=20property=20to=20the=20LangChainTyp?= =?UTF-8?q?eCreator=20class=20called=20docs=5Fmap,=20which=20is=20a=20dict?= =?UTF-8?q?ionary=20that=20maps=20the=20name=20of=20the=20component=20to?= =?UTF-8?q?=20its=20documentation=20link.=20The=20docs=5Fmap=20property=20?= =?UTF-8?q?is=20used=20to=20set=20the=20documentation=20of=20the=20compone?= =?UTF-8?q?nt=20in=20the=20signature=20of=20the=20component.=20This=20chan?= =?UTF-8?q?ge=20improves=20the=20readability=20and=20maintainability=20of?= =?UTF-8?q?=20the=20code=20by=20making=20it=20easier=20to=20add=20and=20up?= =?UTF-8?q?date=20documentation=20for=20components.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/base.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/base.py b/src/backend/langflow/interface/base.py index df0c2c50c..6e1522dd2 100644 --- a/src/backend/langflow/interface/base.py +++ b/src/backend/langflow/interface/base.py @@ -8,6 +8,7 @@ from langflow.template.field.base import TemplateField from langflow.template.frontend_node.base import FrontendNode from langflow.template.template.base import Template from langflow.utils.logger import logger +from langflow.settings import settings # Assuming necessary imports for Field, Template, and FrontendNode classes @@ -15,12 +16,29 @@ from langflow.utils.logger import logger class LangChainTypeCreator(BaseModel, ABC): type_name: str type_dict: Optional[Dict] = None + name_docs_dict: Optional[Dict[str, str]] = None @property def frontend_node_class(self) -> Type[FrontendNode]: """The class type of the FrontendNode created in frontend_node.""" return FrontendNode + @property + def docs_map(self) -> Dict[str, str]: + """A dict with the name of the component as key and the documentation link as value.""" + if self.name_docs_dict is None: + try: + type_settings = getattr(settings, self.type_name) + self.name_docs_dict = { + name: value_dict["documentation"] + for name, value_dict in type_settings.items() + } + except AttributeError as exc: + logger.error(exc) + + self.name_docs_dict = {} + return self.name_docs_dict + @property @abstractmethod def type_to_loader_dict(self) -> Dict: @@ -83,7 +101,7 @@ class LangChainTypeCreator(BaseModel, ABC): signature.add_extra_fields() signature.add_extra_base_classes() - + signature.set_documentation(self.docs_map.get(name, "")) return signature From 2de86cbac4ac74792f631d53108788d012dd69c6 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 24 Jun 2023 16:32:00 -0300 Subject: [PATCH 03/21] =?UTF-8?q?=F0=9F=93=9D=20docs(frontend=5Fnode):=20a?= =?UTF-8?q?dd=20set=5Fdocumentation=20method=20to=20set=20the=20documentat?= =?UTF-8?q?ion=20of=20the=20frontend=20node=20=E2=9C=A8=20feat(frontend=5F?= =?UTF-8?q?node):=20add=20documentation=20field=20to=20the=20frontend=20no?= =?UTF-8?q?de=20dict=20representation=20The=20`set=5Fdocumentation`=20meth?= =?UTF-8?q?od=20is=20added=20to=20the=20`FrontendNode`=20class=20to=20allo?= =?UTF-8?q?w=20setting=20the=20documentation=20of=20the=20frontend=20node.?= =?UTF-8?q?=20The=20`to=5Fdict`=20method=20is=20updated=20to=20include=20t?= =?UTF-8?q?he=20`documentation`=20field=20in=20the=20dict=20representation?= =?UTF-8?q?=20of=20the=20frontend=20node.=20This=20improves=20the=20readab?= =?UTF-8?q?ility=20and=20usability=20of=20the=20frontend=20node=20by=20pro?= =?UTF-8?q?viding=20documentation=20for=20the=20node.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/template/frontend_node/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/langflow/template/frontend_node/base.py b/src/backend/langflow/template/frontend_node/base.py index 4801da086..751ecb709 100644 --- a/src/backend/langflow/template/frontend_node/base.py +++ b/src/backend/langflow/template/frontend_node/base.py @@ -15,14 +15,21 @@ class FrontendNode(BaseModel): base_classes: List[str] name: str = "" display_name: str = "" + documentation: str = "" + + def set_documentation(self, documentation: str) -> None: + """Sets the documentation of the frontend node.""" + self.documentation = documentation def to_dict(self) -> dict: + """Returns a dict representation of the frontend node.""" return { self.name: { "template": self.template.to_dict(self.format_field), "description": self.description, "base_classes": self.base_classes, "display_name": self.display_name or self.name, + "documentation": self.documentation, }, } From f52feac7e5bad32f396e189655d520e8edc8337f Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 24 Jun 2023 16:32:32 -0300 Subject: [PATCH 04/21] =?UTF-8?q?=F0=9F=8E=A8=20style(GenericNode/index.ts?= =?UTF-8?q?x):=20remove=20unused=20imports=20and=20add=20documentation=20l?= =?UTF-8?q?ink=20to=20node=20toolbar=20=F0=9F=9A=80=20feat(api/index.ts):?= =?UTF-8?q?=20add=20documentation=20field=20to=20APIClassType=20The=20unus?= =?UTF-8?q?ed=20imports=20were=20removed=20to=20improve=20code=20readabili?= =?UTF-8?q?ty.=20A=20documentation=20link=20was=20added=20to=20the=20node?= =?UTF-8?q?=20toolbar=20to=20allow=20users=20to=20easily=20access=20the=20?= =?UTF-8?q?documentation=20for=20the=20node.=20The=20documentation=20field?= =?UTF-8?q?=20was=20added=20to=20the=20APIClassType=20to=20allow=20for=20t?= =?UTF-8?q?he=20storage=20of=20a=20link=20to=20the=20documentation=20for?= =?UTF-8?q?=20the=20API=20class.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/CustomNodes/GenericNode/index.tsx | 25 ++++++++++--------- src/frontend/src/types/api/index.ts | 1 + 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 1668b1d4e..c2c58decf 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -6,16 +6,7 @@ import { } from "../../utils"; import ParameterComponent from "./components/parameterComponent"; import { typesContext } from "../../contexts/typesContext"; -import { - useContext, - useState, - useEffect, - useRef, - ForwardRefExoticComponent, - ComponentType, - SVGProps, - ReactNode, -} from "react"; +import { useContext, useState, useEffect, useRef } from "react"; import { NodeDataType } from "../../types/flow"; import { alertContext } from "../../contexts/alertContext"; import { PopUpContext } from "../../contexts/popUpContext"; @@ -23,10 +14,9 @@ import NodeModal from "../../modals/NodeModal"; import Tooltip from "../../components/TooltipComponent"; import { NodeToolbar } from "reactflow"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; - +import { Info } from "lucide-react"; import ShadTooltip from "../../components/ShadTooltipComponent"; import { useSSE } from "../../contexts/SSEContext"; -import { ReactElement } from "react-markdown/lib/react-markdown"; export default function GenericNode({ data, @@ -124,6 +114,17 @@ export default function GenericNode({ >
+
+ + + + + +
| string | APITemplateType; }; export type TemplateVariableType = { From 99f0b803e9b81ce0cffaf50840121edaaba400b2 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 24 Jun 2023 16:32:48 -0300 Subject: [PATCH 05/21] =?UTF-8?q?=F0=9F=94=A8=20refactor(tabsContext.tsx):?= =?UTF-8?q?=20improve=20code=20readability=20by=20adding=20whitespace=20an?= =?UTF-8?q?d=20consistent=20formatting=20The=20code=20has=20been=20refacto?= =?UTF-8?q?red=20to=20improve=20readability=20by=20adding=20whitespace=20a?= =?UTF-8?q?nd=20consistent=20formatting.=20The=20function=20names=20have?= =?UTF-8?q?=20been=20updated=20to=20use=20camelCase=20for=20consistency.?= =?UTF-8?q?=20The=20updateDisplay=5Fname=20function=20has=20been=20updated?= =?UTF-8?q?=20to=20use=20a=20logical=20OR=20operator=20instead=20of=20a=20?= =?UTF-8?q?ternary=20operator=20for=20better=20readability.=20The=20update?= =?UTF-8?q?NodeDocumentation=20function=20has=20been=20added=20to=20update?= =?UTF-8?q?=20the=20node=20documentation.=20The=20updateNodeBaseClasses,?= =?UTF-8?q?=20updateNodeEdges,=20updateNodeDescription,=20and=20updateNode?= =?UTF-8?q?Template=20functions=20have=20been=20updated=20to=20use=20consi?= =?UTF-8?q?stent=20parameter=20names=20and=20whitespace.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/contexts/tabsContext.tsx | 30 +++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 7637699e3..8a2e17465 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -192,39 +192,49 @@ export function TabsProvider({ children }: { children: ReactNode }) { } function processFlowEdges(flow) { - if(!flow.data || !flow.data.edges) return; + if (!flow.data || !flow.data.edges) return; flow.data.edges.forEach((edge) => { edge.className = ""; edge.style = { stroke: "#555555" }; }); } - function updateDisplay_name(node:NodeType,template:APIClassType) { - node.data.node.display_name = template["display_name"]?template["display_name"]:node.data.type; + + function updateDisplay_name(node: NodeType, template: APIClassType) { + node.data.node.display_name = template["display_name"] || node.data.type; + } + + function updateNodeDocumentation(node: NodeType, template: APIClassType) { + node.data.node.documentation = template["documentation"]; } function processFlowNodes(flow) { - if(!flow.data || !flow.data.nodes) return; - flow.data.nodes.forEach((node:NodeType) => { + if (!flow.data || !flow.data.nodes) return; + flow.data.nodes.forEach((node: NodeType) => { const template = templates[node.data.type]; if (!template) { setErrorData({ title: `Unknown node type: ${node.data.type}` }); return; } if (Object.keys(template["template"]).length > 0) { - updateDisplay_name(node,template); + updateDisplay_name(node, template); updateNodeBaseClasses(node, template); updateNodeEdges(flow, node, template); updateNodeDescription(node, template); updateNodeTemplate(node, template); + updateNodeDocumentation(node, template); } }); } - function updateNodeBaseClasses(node:NodeType,template:APIClassType) { + function updateNodeBaseClasses(node: NodeType, template: APIClassType) { node.data.node.base_classes = template["base_classes"]; } - function updateNodeEdges(flow:FlowType, node:NodeType,template:APIClassType) { + function updateNodeEdges( + flow: FlowType, + node: NodeType, + template: APIClassType + ) { flow.data.edges.forEach((edge) => { if (edge.source === node.id) { edge.sourceHandle = edge.sourceHandle @@ -236,11 +246,11 @@ export function TabsProvider({ children }: { children: ReactNode }) { }); } - function updateNodeDescription(node:NodeType,template:APIClassType) { + function updateNodeDescription(node: NodeType, template: APIClassType) { node.data.node.description = template["description"]; } - function updateNodeTemplate(node:NodeType,template:APIClassType) { + function updateNodeTemplate(node: NodeType, template: APIClassType) { node.data.node.template = updateTemplate( template["template"] as unknown as APITemplateType, node.data.node.template as APITemplateType From aa4b7bfc327f22191dc75df670610faabac354a0 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 24 Jun 2023 16:38:11 -0300 Subject: [PATCH 06/21] =?UTF-8?q?=F0=9F=90=9B=20fix(GenericNode):=20add=20?= =?UTF-8?q?conditional=20rendering=20to=20documentation=20link=20to=20prev?= =?UTF-8?q?ent=20empty=20href=20The=20documentation=20link=20was=20previou?= =?UTF-8?q?sly=20always=20rendered,=20even=20if=20the=20href=20was=20empty?= =?UTF-8?q?.=20This=20caused=20an=20issue=20where=20the=20link=20would=20b?= =?UTF-8?q?e=20clickable=20but=20lead=20to=20nowhere.=20The=20fix=20adds?= =?UTF-8?q?=20a=20conditional=20rendering=20to=20the=20link,=20so=20it=20i?= =?UTF-8?q?s=20only=20rendered=20if=20the=20href=20is=20not=20empty.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/CustomNodes/GenericNode/index.tsx | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index c2c58decf..0bab24969 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -115,15 +115,17 @@ export default function GenericNode({
- - - - - + {data.node.documentation !== "" && ( + + + + + + )}
Date: Sat, 24 Jun 2023 16:38:24 -0300 Subject: [PATCH 07/21] =?UTF-8?q?=F0=9F=90=9B=20fix(settings.py):=20change?= =?UTF-8?q?=20default=20values=20of=20settings=20attributes=20from=20list?= =?UTF-8?q?=20to=20dictionary=20The=20default=20values=20of=20the=20settin?= =?UTF-8?q?gs=20attributes=20were=20changed=20from=20an=20empty=20list=20t?= =?UTF-8?q?o=20an=20empty=20dictionary.=20This=20change=20was=20made=20to?= =?UTF-8?q?=20avoid=20errors=20that=20could=20occur=20when=20trying=20to?= =?UTF-8?q?=20access=20a=20non-existent=20key=20in=20the=20dictionary.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/settings.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/langflow/settings.py b/src/backend/langflow/settings.py index fac0dab8b..0a50a907f 100644 --- a/src/backend/langflow/settings.py +++ b/src/backend/langflow/settings.py @@ -36,16 +36,16 @@ class Settings(BaseSettings): def update_from_yaml(self, file_path: str, dev: bool = False): new_settings = load_settings_from_yaml(file_path) - self.chains = new_settings.chains or [] - self.agents = new_settings.agents or [] - self.prompts = new_settings.prompts or [] - self.llms = new_settings.llms or [] - self.tools = new_settings.tools or [] - self.memories = new_settings.memories or [] - self.wrappers = new_settings.wrappers or [] - self.toolkits = new_settings.toolkits or [] - self.textsplitters = new_settings.textsplitters or [] - self.utilities = new_settings.utilities or [] + self.chains = new_settings.chains or {} + self.agents = new_settings.agents or {} + self.prompts = new_settings.prompts or {} + self.llms = new_settings.llms or {} + self.tools = new_settings.tools or {} + self.memories = new_settings.memories or {} + self.wrappers = new_settings.wrappers or {} + self.toolkits = new_settings.toolkits or {} + self.textsplitters = new_settings.textsplitters or {} + self.utilities = new_settings.utilities or {} self.dev = dev def update_settings(self, **kwargs): From d0893d2eb79913bb10400c57be31951b83d031f2 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 24 Jun 2023 16:53:13 -0300 Subject: [PATCH 08/21] =?UTF-8?q?=F0=9F=94=A5=20chore(test=5Fprompts=5Ftem?= =?UTF-8?q?plate.py):=20remove=20unused=20test=5Ffew=5Fshot=5Fprompt=5Ftem?= =?UTF-8?q?plate=20function=20The=20test=5Ffew=5Fshot=5Fprompt=5Ftemplate?= =?UTF-8?q?=20function=20is=20not=20being=20used=20and=20is=20not=20necess?= =?UTF-8?q?ary=20for=20the=20tests.=20Removing=20it=20will=20make=20the=20?= =?UTF-8?q?code=20cleaner=20and=20easier=20to=20maintain.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_prompts_template.py | 79 ---------------------------------- 1 file changed, 79 deletions(-) diff --git a/tests/test_prompts_template.py b/tests/test_prompts_template.py index a8562898c..5094f50f0 100644 --- a/tests/test_prompts_template.py +++ b/tests/test_prompts_template.py @@ -88,85 +88,6 @@ def test_prompt_template(client: TestClient): } -def test_few_shot_prompt_template(client: TestClient): - response = client.get("api/v1/all") - assert response.status_code == 200 - json_response = response.json() - prompts = json_response["prompts"] - - prompt = prompts["FewShotPromptTemplate"] - template = prompt["template"] - # Test other fields in the template similar to PromptTemplate - assert template["examples"] == { - "required": False, - "placeholder": "", - "show": True, - "multiline": True, - "password": False, - "name": "examples", - "type": "prompt", - "list": True, - "advanced": False, - } - assert template["example_selector"] == { - "required": False, - "placeholder": "", - "show": False, - "multiline": False, - "password": False, - "name": "example_selector", - "type": "BaseExampleSelector", - "list": False, - "advanced": False, - } - assert template["example_prompt"] == { - "required": True, - "placeholder": "", - "show": True, - "multiline": False, - "password": False, - "name": "example_prompt", - "type": "PromptTemplate", - "list": False, - "advanced": False, - } - assert template["suffix"] == { - "required": True, - "placeholder": "", - "show": True, - "multiline": True, - "password": False, - "name": "suffix", - "type": "prompt", - "list": False, - "advanced": False, - } - assert template["example_separator"] == { - "required": False, - "placeholder": "", - "show": False, - "multiline": False, - "value": "\n\n", - "password": False, - "name": "example_separator", - "type": "str", - "list": False, - "advanced": False, - } - assert template["prefix"] == { - "required": False, - "placeholder": "", - "show": True, - "multiline": True, - "value": "", - "password": False, - "name": "prefix", - "type": "prompt", - "list": False, - "advanced": False, - } - - def test_zero_shot_prompt(client: TestClient): response = client.get("api/v1/all") assert response.status_code == 200 From d523b7f8b07194a81a832f174a77ccb21b488182 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 09:26:13 -0300 Subject: [PATCH 09/21] fix: removing placeholders --- src/backend/langflow/config.yaml | 204 +++++++++++++++---------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index a8f4f6b53..0abeb7a7e 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -8,11 +8,11 @@ agents: AgentInitializer: documentation: "https://python.langchain.com/docs/modules/agents/agent_types/" VectorStoreAgent: - documentation: "https://example.com/VectorStoreAgent" + documentation: "" VectorStoreRouterAgent: - documentation: "https://example.com/VectorStoreRouterAgent" + documentation: "" SQLAgent: - documentation: "https://example.com/SQLAgent" + documentation: "" chains: LLMChain: documentation: "https://python.langchain.com/docs/modules/chains/foundational/llm_chain" @@ -21,111 +21,111 @@ chains: LLMCheckerChain: documentation: "https://python.langchain.com/docs/modules/chains/additional/llm_checker" ConversationChain: - documentation: "https://example.com/ConversationChain" + documentation: "" SeriesCharacterChain: - documentation: "https://example.com/SeriesCharacterChain" + documentation: "" MidJourneyPromptChain: - documentation: "https://example.com/MidJourneyPromptChain" + documentation: "" TimeTravelGuideChain: - documentation: "https://example.com/TimeTravelGuideChain" + documentation: "" SQLDatabaseChain: - documentation: "https://example.com/SQLDatabaseChain" + documentation: "" RetrievalQA: documentation: "https://python.langchain.com/docs/modules/chains/popular/vector_db_qa" RetrievalQAWithSourcesChain: - documentation: "https://example.com/RetrievalQAWithSourcesChain" + documentation: "" ConversationalRetrievalChain: documentation: "https://python.langchain.com/docs/modules/chains/popular/chat_vector_db" CombineDocsChain: - documentation: "https://example.com/CombineDocsChain" + documentation: "" documentloaders: AirbyteJSONLoader: - documentation: "https://example.com/AirbyteJSONLoader" + documentation: "" CoNLLULoader: - documentation: "https://example.com/CoNLLULoader" + documentation: "" CSVLoader: - documentation: "https://example.com/CSVLoader" + documentation: "" UnstructuredEmailLoader: - documentation: "https://example.com/UnstructuredEmailLoader" + documentation: "" EverNoteLoader: - documentation: "https://example.com/EverNoteLoader" + documentation: "" FacebookChatLoader: - documentation: "https://example.com/FacebookChatLoader" + documentation: "" GutenbergLoader: - documentation: "https://example.com/GutenbergLoader" + documentation: "" BSHTMLLoader: - documentation: "https://example.com/BSHTMLLoader" + documentation: "" UnstructuredHTMLLoader: - documentation: "https://example.com/UnstructuredHTMLLoader" + documentation: "" UnstructuredMarkdownLoader: - documentation: "https://example.com/UnstructuredMarkdownLoader" + documentation: "" PyPDFLoader: - documentation: "https://example.com/PyPDFLoader" + documentation: "" UnstructuredPowerPointLoader: - documentation: "https://example.com/UnstructuredPowerPointLoader" + documentation: "" SRTLoader: - documentation: "https://example.com/SRTLoader" + documentation: "" TelegramChatLoader: - documentation: "https://example.com/TelegramChatLoader" + documentation: "" TextLoader: - documentation: "https://example.com/TextLoader" + documentation: "" UnstructuredWordDocumentLoader: - documentation: "https://example.com/UnstructuredWordDocumentLoader" + documentation: "" WebBaseLoader: - documentation: "https://example.com/WebBaseLoader" + documentation: "" AZLyricsLoader: - documentation: "https://example.com/AZLyricsLoader" + documentation: "" CollegeConfidentialLoader: - documentation: "https://example.com/CollegeConfidentialLoader" + documentation: "" HNLoader: - documentation: "https://example.com/HNLoader" + documentation: "" IFixitLoader: - documentation: "https://example.com/IFixitLoader" + documentation: "" IMSDbLoader: - documentation: "https://example.com/IMSDbLoader" + documentation: "" GitbookLoader: - documentation: "https://example.com/GitbookLoader" + documentation: "" ReadTheDocsLoader: - documentation: "https://example.com/ReadTheDocsLoader" + documentation: "" SlackDirectoryLoader: - documentation: "https://example.com/SlackDirectoryLoader" + documentation: "" NotionDirectoryLoader: - documentation: "https://example.com/NotionDirectoryLoader" + documentation: "" DirectoryLoader: - documentation: "https://example.com/DirectoryLoader" + documentation: "" GitLoader: - documentation: "https://example.com/GitLoader" + documentation: "" embeddings: OpenAIEmbeddings: - documentation: "https://example.com/OpenAIEmbeddings" + documentation: "" HuggingFaceEmbeddings: - documentation: "https://example.com/HuggingFaceEmbeddings" + documentation: "" CohereEmbeddings: - documentation: "https://example.com/CohereEmbeddings" + documentation: "" llms: OpenAI: - documentation: "https://example.com/OpenAI" + documentation: "" ChatOpenAI: - documentation: "https://example.com/ChatOpenAI" + documentation: "" LlamaCpp: - documentation: "https://example.com/LlamaCpp" + documentation: "" CTransformers: - documentation: "https://example.com/CTransformers" + documentation: "" Cohere: - documentation: "https://example.com/Cohere" + documentation: "" Anthropic: - documentation: "https://example.com/Anthropic" + documentation: "" ChatAnthropic: - documentation: "https://example.com/ChatAnthropic" + documentation: "" HuggingFaceHub: - documentation: "https://example.com/HuggingFaceHub" + documentation: "" memories: ConversationBufferMemory: - documentation: "https://example.com/ConversationBufferMemory" + documentation: "" ConversationSummaryMemory: - documentation: "https://example.com/ConversationSummaryMemory" + documentation: "" ConversationKGMemory: - documentation: "https://example.com/ConversationKGMemory" + documentation: "" prompts: PromptTemplate: documentation: "https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/" @@ -138,106 +138,106 @@ textsplitters: documentation: "https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/recursive_text_splitter" toolkits: OpenAPIToolkit: - documentation: "https://example.com/OpenAPIToolkit" + documentation: "" JsonToolkit: - documentation: "https://example.com/JsonToolkit" + documentation: "" VectorStoreInfo: - documentation: "https://example.com/VectorStoreInfo" + documentation: "" VectorStoreRouterToolkit: - documentation: "https://example.com/VectorStoreRouterToolkit" + documentation: "" VectorStoreToolkit: - documentation: "https://example.com/VectorStoreToolkit" + documentation: "" tools: Search: - documentation: "https://example.com/Search" + documentation: "" PAL-MATH: - documentation: "https://example.com/PAL-MATH" + documentation: "" Calculator: - documentation: "https://example.com/Calculator" + documentation: "" Serper Search: - documentation: "https://example.com/SerperSearch" + documentation: "" Tool: - documentation: "https://example.com/Tool" + documentation: "" PythonFunctionTool: - documentation: "https://example.com/PythonFunctionTool" + documentation: "" PythonFunction: - documentation: "https://example.com/PythonFunction" + documentation: "" JsonSpec: - documentation: "https://example.com/JsonSpec" + documentation: "" News API: - documentation: "https://example.com/NewsAPI" + documentation: "" TMDB API: - documentation: "https://example.com/TMDBAPI" + documentation: "" Podcast API: - documentation: "https://example.com/PodcastAPI" + documentation: "" QuerySQLDataBaseTool: - documentation: "https://example.com/QuerySQLDataBaseTool" + documentation: "" InfoSQLDatabaseTool: - documentation: "https://example.com/InfoSQLDatabaseTool" + documentation: "" ListSQLDatabaseTool: - documentation: "https://example.com/ListSQLDatabaseTool" + documentation: "" BingSearchRun: - documentation: "https://example.com/BingSearchRun" + documentation: "" GoogleSearchRun: - documentation: "https://example.com/GoogleSearchRun" + documentation: "" GoogleSearchResults: - documentation: "https://example.com/GoogleSearchResults" + documentation: "" GoogleSerperRun: - documentation: "https://example.com/GoogleSerperRun" + documentation: "" JsonListKeysTool: - documentation: "https://example.com/JsonListKeysTool" + documentation: "" JsonGetValueTool: - documentation: "https://example.com/JsonGetValueTool" + documentation: "" PythonREPLTool: - documentation: "https://example.com/PythonREPLTool" + documentation: "" PythonAstREPLTool: - documentation: "https://example.com/PythonAstREPLTool" + documentation: "" RequestsGetTool: - documentation: "https://example.com/RequestsGetTool" + documentation: "" RequestsPostTool: - documentation: "https://example.com/RequestsPostTool" + documentation: "" RequestsPatchTool: - documentation: "https://example.com/RequestsPatchTool" + documentation: "" RequestsPutTool: - documentation: "https://example.com/RequestsPutTool" + documentation: "" RequestsDeleteTool: - documentation: "https://example.com/RequestsDeleteTool" + documentation: "" WikipediaQueryRun: - documentation: "https://example.com/WikipediaQueryRun" + documentation: "" WolframAlphaQueryRun: - documentation: "https://example.com/WolframAlphaQueryRun" + documentation: "" utilities: BingSearchAPIWrapper: - documentation: "https://example.com/BingSearchAPIWrapper" + documentation: "" GoogleSearchAPIWrapper: - documentation: "https://example.com/GoogleSearchAPIWrapper" + documentation: "" GoogleSerperAPIWrapper: - documentation: "https://example.com/GoogleSerperAPIWrapper" + documentation: "" SearxResults: - documentation: "https://example.com/SearxResults" + documentation: "" SearxSearchWrapper: - documentation: "https://example.com/SearxSearchWrapper" + documentation: "" SerpAPIWrapper: - documentation: "https://example.com/SerpAPIWrapper" + documentation: "" WikipediaAPIWrapper: - documentation: "https://example.com/WikipediaAPIWrapper" + documentation: "" WolframAlphaAPIWrapper: - documentation: "https://example.com/WolframAlphaAPIWrapper" + documentation: "" vectorstores: Chroma: - documentation: "https://example.com/Chroma" + documentation: "" Qdrant: - documentation: "https://example.com/Qdrant" + documentation: "" Weaviate: - documentation: "https://example.com/Weaviate" + documentation: "" FAISS: - documentation: "https://example.com/FAISS" + documentation: "" Pinecone: - documentation: "https://example.com/Pinecone" + documentation: "" SupabaseVectorStore: - documentation: "https://example.com/SupabaseVectorStore" + documentation: "" MongoDBAtlasVectorSearch: - documentation: "https://example.com/MongoDBAtlasVectorSearch" + documentation: "" wrappers: RequestsWrapper: - documentation: "https://example.com/RequestsWrapper" + documentation: "" From 02befe50526fa454cb24409c7d925d936716da72 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 09:27:44 -0300 Subject: [PATCH 10/21] =?UTF-8?q?=F0=9F=93=9D=20docs(config.yaml):=20add?= =?UTF-8?q?=20documentation=20links=20for=20LlamaCpp=20and=20CTransformers?= =?UTF-8?q?=20integrations=20This=20commit=20adds=20documentation=20links?= =?UTF-8?q?=20for=20the=20LlamaCpp=20and=20CTransformers=20integrations=20?= =?UTF-8?q?in=20the=20config.yaml=20file.=20The=20links=20point=20to=20the?= =?UTF-8?q?=20relevant=20documentation=20pages=20on=20the=20LangChain=20we?= =?UTF-8?q?bsite.=20This=20improves=20the=20accessibility=20of=20the=20doc?= =?UTF-8?q?umentation=20for=20these=20integrations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index 0abeb7a7e..0077b4ba1 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -108,9 +108,9 @@ llms: ChatOpenAI: documentation: "" LlamaCpp: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/llamacpp" CTransformers: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/ctransformers" Cohere: documentation: "" Anthropic: From a45947c01beb0da9c91e410e4122ca0882bca30b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:37:05 -0300 Subject: [PATCH 11/21] =?UTF-8?q?=F0=9F=9A=80=20feat(vectorstores.py):=20a?= =?UTF-8?q?dd=20VectorStoreRetriever=20as=20an=20extra=20base=20class=20to?= =?UTF-8?q?=20VectorStoreFrontendNode=20The=20VectorStoreFrontendNode=20cl?= =?UTF-8?q?ass=20now=20has=20VectorStoreRetriever=20as=20an=20extra=20base?= =?UTF-8?q?=20class=20in=20addition=20to=20BaseRetriever.=20This=20change?= =?UTF-8?q?=20was=20made=20to=20improve=20the=20functionality=20of=20the?= =?UTF-8?q?=20class=20by=20allowing=20it=20to=20inherit=20from=20VectorSto?= =?UTF-8?q?reRetriever.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/template/frontend_node/vectorstores.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/template/frontend_node/vectorstores.py b/src/backend/langflow/template/frontend_node/vectorstores.py index 01b6bfe53..58cfcdc34 100644 --- a/src/backend/langflow/template/frontend_node/vectorstores.py +++ b/src/backend/langflow/template/frontend_node/vectorstores.py @@ -200,7 +200,7 @@ class VectorStoreFrontendNode(FrontendNode): self.template.add_field(field) def add_extra_base_classes(self) -> None: - self.base_classes.append("BaseRetriever") + self.base_classes.extend(("BaseRetriever", "VectorStoreRetriever")) @staticmethod def format_field(field: TemplateField, name: Optional[str] = None) -> None: From d4599a52b352701288c6c8872cf41ba6a7a72122 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:37:18 -0300 Subject: [PATCH 12/21] =?UTF-8?q?=F0=9F=93=9D=20docs(config.yaml):=20add?= =?UTF-8?q?=20documentation=20links=20for=20new=20integrations=20and=20mem?= =?UTF-8?q?ories=20Added=20documentation=20links=20for=20new=20integration?= =?UTF-8?q?s=20and=20memories=20to=20improve=20the=20documentation=20of=20?= =?UTF-8?q?the=20project.=20The=20new=20integrations=20are=20Cohere=20and?= =?UTF-8?q?=20HuggingFaceHub,=20and=20the=20new=20memories=20are=20Convers?= =?UTF-8?q?ationBufferWindowMemory=20and=20VectorStoreRetrieverMemory.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/config.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index 0077b4ba1..65b470f21 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -112,20 +112,24 @@ llms: CTransformers: documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/ctransformers" Cohere: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/cohere" Anthropic: documentation: "" ChatAnthropic: documentation: "" HuggingFaceHub: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/huggingface_hub" memories: ConversationBufferMemory: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/memory/how_to/summary" ConversationSummaryMemory: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/memory/how_to/summary" ConversationKGMemory: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/memory/how_to/kg" + ConversationBufferWindowMemory: + documentation: "https://python.langchain.com/docs/modules/memory/how_to/buffer_window" + VectorStoreRetrieverMemory: + documentation: "https://python.langchain.com/docs/modules/memory/how_to/vectorstore_retriever_memory" prompts: PromptTemplate: documentation: "https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/" From 217225467f5f35395d3d9fc2627024213d6b340d Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:57:35 -0300 Subject: [PATCH 13/21] =?UTF-8?q?=F0=9F=94=A8=20refactor(loading.py):=20ad?= =?UTF-8?q?d=20type=20hints=20to=20function=20parameters=20and=20return=20?= =?UTF-8?q?types=20This=20commit=20adds=20type=20hints=20to=20the=20functi?= =?UTF-8?q?on=20parameters=20and=20return=20types=20in=20the=20loading.py?= =?UTF-8?q?=20file.=20This=20improves=20the=20readability=20and=20maintain?= =?UTF-8?q?ability=20of=20the=20codebase=20by=20making=20it=20easier=20to?= =?UTF-8?q?=20understand=20the=20expected=20types=20of=20the=20parameters?= =?UTF-8?q?=20and=20return=20values=20of=20the=20functions.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/initialize/loading.py | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index 88b981f9d..4acc21383 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -1,5 +1,5 @@ import json -from typing import Any, Callable, Dict, Sequence +from typing import Any, Callable, Dict, Sequence, Type from langchain.agents import ZeroShotAgent from langchain.agents import agent as agent_module @@ -16,6 +16,12 @@ from langflow.interface.toolkits.base import toolkits_creator from langflow.interface.chains.base import chain_creator from langflow.interface.utils import load_file_into_dict from langflow.utils import validate +from langchain.text_splitter import TextSplitter +from langchain.chains.base import Chain +from langchain.vectorstores.base import VectorStore +from langchain.document_loaders.base import BaseLoader +from langchain.embeddings.base import Embeddings +from langchain.prompts.base import BasePromptTemplate def instantiate_class(node_type: str, base_type: str, params: Dict) -> Any: @@ -76,7 +82,7 @@ def instantiate_based_on_type(class_object, base_type, node_type, params): return class_object(**params) -def instantiate_chains(node_type, class_object, params): +def instantiate_chains(node_type, class_object: Type[Chain], params: Dict): if "retriever" in params and hasattr(params["retriever"], "as_retriever"): params["retriever"] = params["retriever"].as_retriever() if node_type in chain_creator.from_method_nodes: @@ -88,11 +94,11 @@ def instantiate_chains(node_type, class_object, params): return class_object(**params) -def instantiate_agent(class_object, params): +def instantiate_agent(class_object: Type[Chain], params: Dict): return load_agent_executor(class_object, params) -def instantiate_prompt(node_type, class_object, params): +def instantiate_prompt(node_type, class_object: Type[BasePromptTemplate], params: Dict): if node_type == "ZeroShotPrompt": if "tools" not in params: params["tools"] = [] @@ -100,7 +106,7 @@ def instantiate_prompt(node_type, class_object, params): return class_object(**params) -def instantiate_tool(node_type, class_object, params): +def instantiate_tool(node_type, class_object: Type[BaseTool], params: Dict): if node_type == "JsonSpec": params["dict_"] = load_file_into_dict(params.pop("path")) return class_object(**params) @@ -118,7 +124,7 @@ def instantiate_tool(node_type, class_object, params): return class_object(**params) -def instantiate_toolkit(node_type, class_object, params): +def instantiate_toolkit(node_type, class_object: Type[BaseToolkit], params: Dict): loaded_toolkit = class_object(**params) # Commenting this out for now to use toolkits as normal tools # if toolkits_creator.has_create_function(node_type): @@ -128,7 +134,7 @@ def instantiate_toolkit(node_type, class_object, params): return loaded_toolkit -def instantiate_embedding(class_object, params): +def instantiate_embedding(class_object: Type[Embeddings], params: Dict): params.pop("model", None) params.pop("headers", None) try: @@ -142,7 +148,7 @@ def instantiate_embedding(class_object, params): return class_object(**params) -def instantiate_vectorstore(class_object, params): +def instantiate_vectorstore(class_object: Type[VectorStore], params: Dict): search_kwargs = params.pop("search_kwargs", {}) if initializer := vecstore_initializer.get(class_object.__name__): vecstore = initializer(class_object, params) @@ -158,7 +164,7 @@ def instantiate_vectorstore(class_object, params): return vecstore -def instantiate_documentloader(class_object, params): +def instantiate_documentloader(class_object: Type[BaseLoader], params: Dict): if "file_filter" in params: # file_filter will be a string but we need a function # that will be used to filter the files using file_filter @@ -187,7 +193,7 @@ def instantiate_documentloader(class_object, params): return docs -def instantiate_textsplitter(class_object, params): +def instantiate_textsplitter(class_object: Type[TextSplitter], params: Dict): try: documents = params.pop("documents") except KeyError as e: @@ -195,11 +201,17 @@ def instantiate_textsplitter(class_object, params): "The source you provided did not load correctly or was empty." "Try changing the chunk_size of the Text Splitter." ) from e - text_splitter = class_object(**params) + if "separator_type" in params and params["separator_type"] == "Text": + text_splitter = class_object(**params) + else: + params["language"] = params.pop("separator_type", None) + params.pop("separators", None) + text_splitter = class_object.from_language(**params) + return text_splitter.split_documents(documents) -def instantiate_utility(node_type, class_object, params): +def instantiate_utility(node_type, class_object, params: Dict): if node_type == "SQLDatabase": return class_object.from_uri(params.pop("uri")) return class_object(**params) From 005e7ec51ce88b6870a2b43b9c0482b1a38725dd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:57:45 -0300 Subject: [PATCH 14/21] =?UTF-8?q?=F0=9F=9A=80=20feat(textsplitters.py):=20?= =?UTF-8?q?add=20a=20field=20for=20separator=20type=20in=20RecursiveCharac?= =?UTF-8?q?terTextSplitter=20The=20RecursiveCharacterTextSplitter=20class?= =?UTF-8?q?=20in=20textsplitters.py=20now=20has=20a=20new=20field=20called?= =?UTF-8?q?=20separator=5Ftype.=20This=20field=20is=20used=20to=20specify?= =?UTF-8?q?=20the=20type=20of=20separator=20to=20be=20used=20in=20the=20sp?= =?UTF-8?q?litter.=20The=20separator=5Ftype=20field=20is=20a=20string=20an?= =?UTF-8?q?d=20can=20take=20any=20value=20from=20the=20Language=20enum=20o?= =?UTF-8?q?r=20"Text".=20This=20change=20was=20made=20to=20improve=20the?= =?UTF-8?q?=20flexibility=20of=20the=20RecursiveCharacterTextSplitter=20cl?= =?UTF-8?q?ass.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/frontend_node/textsplitters.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/backend/langflow/template/frontend_node/textsplitters.py b/src/backend/langflow/template/frontend_node/textsplitters.py index 03880379d..0a444ff08 100644 --- a/src/backend/langflow/template/frontend_node/textsplitters.py +++ b/src/backend/langflow/template/frontend_node/textsplitters.py @@ -1,5 +1,6 @@ from langflow.template.field.base import TemplateField from langflow.template.frontend_node.base import FrontendNode +from langchain.text_splitter import Language class TextSplittersFrontendNode(FrontendNode): @@ -17,6 +18,22 @@ class TextSplittersFrontendNode(FrontendNode): name = "separator" elif self.template.type_name == "RecursiveCharacterTextSplitter": name = "separators" + # Add a field for type of separator + # which will have Text or any value from the + # Language enum + self.template.add_field( + TemplateField( + field_type="str", + required=True, + show=True, + name="separator_type", + advanced=False, + is_list=True, + options=[x.value for x in Language], + value="Text", + display_name="Separator Type", + ) + ) self.template.add_field( TemplateField( field_type="str", From 9510474aa67dc30bf4a26a5789f965b58de51736 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:59:40 -0300 Subject: [PATCH 15/21] =?UTF-8?q?=F0=9F=93=9D=20docs(config.yaml):=20add?= =?UTF-8?q?=20documentation=20links=20to=20vectorstores=20integrations=20A?= =?UTF-8?q?dded=20documentation=20links=20to=20the=20vectorstores=20integr?= =?UTF-8?q?ations=20in=20the=20config.yaml=20file.=20This=20will=20make=20?= =?UTF-8?q?it=20easier=20for=20developers=20to=20access=20the=20documentat?= =?UTF-8?q?ion=20for=20each=20integration.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index 65b470f21..b0e5499b3 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -229,19 +229,19 @@ utilities: documentation: "" vectorstores: Chroma: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/chroma" Qdrant: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/qdrant" Weaviate: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/weaviate" FAISS: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/faiss" Pinecone: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/pinecone" SupabaseVectorStore: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/supabase" MongoDBAtlasVectorSearch: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/mongodb_atlas_vector_search" wrappers: RequestsWrapper: documentation: "" From 0c398fb6c59fc5a03456511b7a7be1ba7caa4807 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 19:34:25 -0300 Subject: [PATCH 16/21] =?UTF-8?q?=F0=9F=94=A8=20refactor(loading.py):=20ad?= =?UTF-8?q?d=20type=20hinting=20to=20instantiate=5Fagent=20function=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20fix=20type=20hinting=20in=20i?= =?UTF-8?q?nstantiate=5Fembedding=20function=20=F0=9F=94=A8=20refactor(loa?= =?UTF-8?q?ding.py):=20add=20type=20hinting=20to=20instantiate=5Ftextsplit?= =?UTF-8?q?ter=20function=20The=20changes=20in=20this=20commit=20add=20typ?= =?UTF-8?q?e=20hinting=20to=20the=20`instantiate=5Fagent`,=20`instantiate?= =?UTF-8?q?=5Fembedding`,=20and=20`instantiate=5Ftextsplitter`=20functions?= =?UTF-8?q?=20to=20improve=20code=20readability=20and=20maintainability.?= =?UTF-8?q?=20The=20`instantiate=5Fembedding`=20function=20had=20a=20bug?= =?UTF-8?q?=20in=20its=20type=20hinting=20which=20has=20been=20fixed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/initialize/loading.py | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index 4acc21383..a928ea586 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -16,11 +16,10 @@ from langflow.interface.toolkits.base import toolkits_creator from langflow.interface.chains.base import chain_creator from langflow.interface.utils import load_file_into_dict from langflow.utils import validate -from langchain.text_splitter import TextSplitter +from langchain.text_splitter import TextSplitter, RecursiveCharacterTextSplitter from langchain.chains.base import Chain from langchain.vectorstores.base import VectorStore from langchain.document_loaders.base import BaseLoader -from langchain.embeddings.base import Embeddings from langchain.prompts.base import BasePromptTemplate @@ -94,7 +93,7 @@ def instantiate_chains(node_type, class_object: Type[Chain], params: Dict): return class_object(**params) -def instantiate_agent(class_object: Type[Chain], params: Dict): +def instantiate_agent(class_object: Type[agent_module.Agent], params: Dict): return load_agent_executor(class_object, params) @@ -134,7 +133,7 @@ def instantiate_toolkit(node_type, class_object: Type[BaseToolkit], params: Dict return loaded_toolkit -def instantiate_embedding(class_object: Type[Embeddings], params: Dict): +def instantiate_embedding(class_object, params: Dict): params.pop("model", None) params.pop("headers", None) try: @@ -193,20 +192,25 @@ def instantiate_documentloader(class_object: Type[BaseLoader], params: Dict): return docs -def instantiate_textsplitter(class_object: Type[TextSplitter], params: Dict): +def instantiate_textsplitter( + class_object: Type[TextSplitter], + params: Dict, +): try: documents = params.pop("documents") - except KeyError as e: + except KeyError as exc: raise ValueError( "The source you provided did not load correctly or was empty." "Try changing the chunk_size of the Text Splitter." - ) from e - if "separator_type" in params and params["separator_type"] == "Text": - text_splitter = class_object(**params) - else: - params["language"] = params.pop("separator_type", None) - params.pop("separators", None) - text_splitter = class_object.from_language(**params) + ) from exc + + if type(class_object) == RecursiveCharacterTextSplitter: + if "separator_type" in params and params["separator_type"] == "Text": + text_splitter = class_object(**params) + else: + params["language"] = params.pop("separator_type", None) + params.pop("separators", None) + text_splitter = class_object.from_language(**params) return text_splitter.split_documents(documents) From 7d415e62df66ddeea0d86833cc02486a9166ec88 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 21:32:48 -0300 Subject: [PATCH 17/21] =?UTF-8?q?=F0=9F=8E=A8=20style(GenericNode):=20refa?= =?UTF-8?q?ctor=20tooltip=20to=20improve=20accessibility=20and=20user=20ex?= =?UTF-8?q?perience=20The=20tooltip=20now=20includes=20a=20link=20to=20the?= =?UTF-8?q?=20documentation=20of=20the=20node,=20which=20makes=20it=20more?= =?UTF-8?q?=20accessible=20and=20user-friendly.=20The=20link=20is=20now=20?= =?UTF-8?q?wrapped=20in=20the=20tooltip=20title,=20which=20improves=20the?= =?UTF-8?q?=20semantics=20of=20the=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/CustomNodes/GenericNode/index.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 0bab24969..a84a88093 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -116,14 +116,18 @@ export default function GenericNode({
{data.node.documentation !== "" && ( - - - - + + {`Open ${data.node.display_name} documentation`} + + } + > + )}
From 6459a27777deec92cda0028eb6319fd40c89a122 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 21:37:24 -0300 Subject: [PATCH 18/21] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20use=20'?= =?UTF-8?q?is'=20instead=20of=20'=3D=3D'=20to=20compare=20object=20types?= =?UTF-8?q?=20The=20commit=20changes=20the=20comparison=20operator=20from?= =?UTF-8?q?=20'=3D=3D'=20to=20'is'=20to=20compare=20object=20types.=20This?= =?UTF-8?q?=20is=20because=20'is'=20compares=20the=20object=20identity=20w?= =?UTF-8?q?hile=20'=3D=3D'=20compares=20the=20object=20value.=20In=20this?= =?UTF-8?q?=20case,=20we=20want=20to=20compare=20the=20object=20identity,?= =?UTF-8?q?=20so=20'is'=20is=20the=20correct=20operator=20to=20use.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/initialize/loading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index a928ea586..d362ab844 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -204,7 +204,7 @@ def instantiate_textsplitter( "Try changing the chunk_size of the Text Splitter." ) from exc - if type(class_object) == RecursiveCharacterTextSplitter: + if class_object is RecursiveCharacterTextSplitter: if "separator_type" in params and params["separator_type"] == "Text": text_splitter = class_object(**params) else: From 2d77aaaa15f4055d0e0325309a98e7ccc4c08abd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 26 Jun 2023 07:58:49 -0300 Subject: [PATCH 19/21] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20fix=20i?= =?UTF-8?q?nstantiation=20of=20TextSplitter=20by=20removing=20unnecessary?= =?UTF-8?q?=20check=20for=20RecursiveCharacterTextSplitter=20The=20import?= =?UTF-8?q?=20of=20RecursiveCharacterTextSplitter=20was=20removed=20as=20i?= =?UTF-8?q?t=20was=20not=20being=20used=20in=20the=20code.=20The=20instant?= =?UTF-8?q?iation=20of=20TextSplitter=20was=20fixed=20by=20removing=20the?= =?UTF-8?q?=20unnecessary=20check=20for=20RecursiveCharacterTextSplitter?= =?UTF-8?q?=20and=20simplifying=20the=20code.=20=F0=9F=94=A5=20refactor(lo?= =?UTF-8?q?ading.py):=20remove=20unused=20import=20of=20RecursiveCharacter?= =?UTF-8?q?TextSplitter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/initialize/loading.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index d362ab844..756588058 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -16,7 +16,6 @@ from langflow.interface.toolkits.base import toolkits_creator from langflow.interface.chains.base import chain_creator from langflow.interface.utils import load_file_into_dict from langflow.utils import validate -from langchain.text_splitter import TextSplitter, RecursiveCharacterTextSplitter from langchain.chains.base import Chain from langchain.vectorstores.base import VectorStore from langchain.document_loaders.base import BaseLoader @@ -193,7 +192,7 @@ def instantiate_documentloader(class_object: Type[BaseLoader], params: Dict): def instantiate_textsplitter( - class_object: Type[TextSplitter], + class_object, params: Dict, ): try: @@ -204,13 +203,12 @@ def instantiate_textsplitter( "Try changing the chunk_size of the Text Splitter." ) from exc - if class_object is RecursiveCharacterTextSplitter: - if "separator_type" in params and params["separator_type"] == "Text": - text_splitter = class_object(**params) - else: - params["language"] = params.pop("separator_type", None) - params.pop("separators", None) - text_splitter = class_object.from_language(**params) + if "separator_type" in params and params["separator_type"] == "Text": + text_splitter = class_object(**params) + else: + params["language"] = params.pop("separator_type", None) + params.pop("separators", None) + text_splitter = class_object.from_language(**params) return text_splitter.split_documents(documents) From 47fcdaef419d31956e56ea38b5b1013cb633f08d Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 26 Jun 2023 18:29:27 -0300 Subject: [PATCH 20/21] =?UTF-8?q?=F0=9F=8E=A8=20style(GenericNode/index.ts?= =?UTF-8?q?x):=20refactor=20GenericNode=20component=20to=20use=20a=20more?= =?UTF-8?q?=20readable=20and=20maintainable=20code=20structure=20=E2=9C=A8?= =?UTF-8?q?=20feat(GenericNode/index.tsx):=20add=20documentation=20link=20?= =?UTF-8?q?to=20GenericNode=20component=20and=20display=20it=20as=20a=20to?= =?UTF-8?q?oltip=20when=20hovering=20over=20the=20info=20icon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/CustomNodes/GenericNode/index.tsx | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index a84a88093..743339a48 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -14,7 +14,7 @@ import NodeModal from "../../modals/NodeModal"; import Tooltip from "../../components/TooltipComponent"; import { NodeToolbar } from "reactflow"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; -import { Info } from "lucide-react"; +import { FileText, Info } from "lucide-react"; import ShadTooltip from "../../components/ShadTooltipComponent"; import { useSSE } from "../../contexts/SSEContext"; @@ -36,6 +36,7 @@ export default function GenericNode({ const [validationStatus, setValidationStatus] = useState(null); // State for outline color const { sseData, isBuilding } = useSSE(); + const refHtml = useRef(null); // useEffect(() => { // if (reactFlowInstance) { @@ -69,6 +70,22 @@ export default function GenericNode({ useEffect(() => {}, [closePopUp, data.node.template]); + useEffect(() => { + refHtml.current = ( +
+ {`${data.node.display_name} Documentation`} + + + +
+ ); + }, []); + return ( <> @@ -93,7 +110,7 @@ export default function GenericNode({ color: nodeColors[types[data.type]] ?? nodeColors.unknown, }} /> -
+
+
+ {data.node.documentation !== "" && ( + + + + + + )} +
@@ -114,23 +154,6 @@ export default function GenericNode({ >
-
- {data.node.documentation !== "" && ( - - {`Open ${data.node.display_name} documentation`} - - } - > - - - )} -
Date: Mon, 26 Jun 2023 19:53:51 -0300 Subject: [PATCH 21/21] =?UTF-8?q?=F0=9F=93=9D=20docs(config.yaml):=20add?= =?UTF-8?q?=20documentation=20links=20for=20various=20document=20loaders,?= =?UTF-8?q?=20embeddings,=20and=20llms=20Added=20documentation=20links=20f?= =?UTF-8?q?or=20various=20document=20loaders,=20embeddings,=20and=20llms?= =?UTF-8?q?=20to=20improve=20the=20readability=20and=20usability=20of=20th?= =?UTF-8?q?e=20config.yaml=20file.=20These=20links=20provide=20a=20quick?= =?UTF-8?q?=20reference=20to=20the=20documentation=20for=20each=20of=20the?= =?UTF-8?q?=20modules,=20making=20it=20easier=20for=20developers=20to=20un?= =?UTF-8?q?derstand=20and=20use=20them.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/config.yaml | 68 ++++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index b0e5499b3..518ff7029 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -40,73 +40,73 @@ chains: documentation: "" documentloaders: AirbyteJSONLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/airbyte_json" CoNLLULoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/conll-u" CSVLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/csv" UnstructuredEmailLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/email" EverNoteLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/evernote" FacebookChatLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/facebook_chat" GutenbergLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/gutenberg" BSHTMLLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/how_to/html" UnstructuredHTMLLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/how_to/html" UnstructuredMarkdownLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/how_to/markdown" PyPDFLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/how_to/pdf" UnstructuredPowerPointLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/microsoft_powerpoint" SRTLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/subtitle" TelegramChatLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/telegram" TextLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/" UnstructuredWordDocumentLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/microsoft_word" WebBaseLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/web_base" AZLyricsLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/azlyrics" CollegeConfidentialLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/college_confidential" HNLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/hacker_news" IFixitLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/ifixit" IMSDbLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/imsdb" GitbookLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/gitbook" ReadTheDocsLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/readthedocs_documentation" SlackDirectoryLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/slack" NotionDirectoryLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/notion" DirectoryLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/how_to/file_directory" GitLoader: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/git" embeddings: OpenAIEmbeddings: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/openai" HuggingFaceEmbeddings: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/sentence_transformers" CohereEmbeddings: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/cohere" llms: OpenAI: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/openai" ChatOpenAI: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/chat/integrations/openai" LlamaCpp: documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/llamacpp" CTransformers: @@ -116,7 +116,7 @@ llms: Anthropic: documentation: "" ChatAnthropic: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/chat/integrations/anthropic" HuggingFaceHub: documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/huggingface_hub" memories: