From 01bc5e41bc17180566ee20242bc80c808059a7d5 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 23 Jun 2023 19:48:45 -0300 Subject: [PATCH 01/43] =?UTF-8?q?=F0=9F=94=96=20chore(pyproject.toml):=20b?= =?UTF-8?q?ump=20up=20version=20to=200.2.0=20The=20version=20number=20has?= =?UTF-8?q?=20been=20updated=20from=200.1.7=20to=200.2.0=20to=20reflect=20?= =?UTF-8?q?the=20changes=20made=20to=20the=20package.=20This=20is=20a=20ch?= =?UTF-8?q?ore=20commit=20as=20it=20does=20not=20add=20any=20new=20feature?= =?UTF-8?q?s=20or=20fix=20any=20bugs,=20but=20rather=20updates=20the=20ver?= =?UTF-8?q?sion=20number.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 97aa064fe..e504c74b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.1.7" +version = "0.2.0" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ 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 02/43] 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 03/43] =?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 04/43] =?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 05/43] =?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 06/43] =?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 07/43] =?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 08/43] =?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 09/43] =?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 29542f4cf87e5b4a52ef77feefee4d6cb0d51e39 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 09:12:41 -0300 Subject: [PATCH 10/43] =?UTF-8?q?=F0=9F=94=A7=20chore(utils.py):=20add=20s?= =?UTF-8?q?etup=5Fllm=5Fcaching=20function=20to=20set=20up=20LLM=20caching?= =?UTF-8?q?=20=E2=9C=A8=20feat(main.py):=20call=20setup=5Fllm=5Fcaching=20?= =?UTF-8?q?function=20on=20app=20startup=20The=20`setup=5Fllm=5Fcaching`?= =?UTF-8?q?=20function=20is=20added=20to=20`utils.py`=20to=20set=20up=20LL?= =?UTF-8?q?M=20caching.=20The=20function=20is=20then=20called=20on=20app?= =?UTF-8?q?=20startup=20in=20`main.py`=20using=20the=20`app.on=5Fevent("st?= =?UTF-8?q?artup")`=20method.=20This=20improves=20the=20performance=20of?= =?UTF-8?q?=20the=20application=20by=20caching=20LLM=20objects.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/utils.py | 10 ++++++++++ src/backend/langflow/main.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/backend/langflow/interface/utils.py b/src/backend/langflow/interface/utils.py index 2777025ab..668e1e6e4 100644 --- a/src/backend/langflow/interface/utils.py +++ b/src/backend/langflow/interface/utils.py @@ -7,6 +7,7 @@ import re import yaml from langchain.base_language import BaseLanguageModel from PIL.Image import Image +from langflow.utils.logger import logger def load_file_into_dict(file_path: str) -> dict: @@ -58,3 +59,12 @@ def try_setting_streaming_options(langchain_object, websocket): def extract_input_variables_from_prompt(prompt: str) -> list[str]: """Extract input variables from prompt.""" return re.findall(r"{(.*?)}", prompt) + + +def setup_llm_caching(): + """Setup LLM caching.""" + import langchain + from langchain.cache import SQLiteCache + + logger.debug("Setting up LLM caching") + langchain.llm_cache = SQLiteCache() diff --git a/src/backend/langflow/main.py b/src/backend/langflow/main.py index ad3217eb5..2a1293f2e 100644 --- a/src/backend/langflow/main.py +++ b/src/backend/langflow/main.py @@ -3,6 +3,7 @@ from fastapi.middleware.cors import CORSMiddleware from langflow.api import router from langflow.database.base import create_db_and_tables +from langflow.interface.utils import setup_llm_caching def create_app(): @@ -28,6 +29,7 @@ def create_app(): app.include_router(router) app.on_event("startup")(create_db_and_tables) + app.on_event("startup")(setup_llm_caching) return app 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 11/43] 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 12/43] =?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 1a318a82aeed1e930e5a722e02c660ccf3c23bad Mon Sep 17 00:00:00 2001 From: Rodrigo Nader Date: Sun, 25 Jun 2023 17:40:14 -0300 Subject: [PATCH 13/43] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 36ea5a20f..6d995e8c2 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,9 @@ Github License

+

-Discord Server +Discord Server HuggingFace Spaces

From 89c2e5b0649eea501c9a10338da487cdf7617bf5 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:19:59 -0300 Subject: [PATCH 14/43] =?UTF-8?q?=F0=9F=9A=80=20feat(utils.py):=20add=20su?= =?UTF-8?q?pport=20for=20configurable=20LLM=20caching=20This=20commit=20ad?= =?UTF-8?q?ds=20support=20for=20configurable=20LLM=20caching.=20The=20`set?= =?UTF-8?q?up=5Fllm=5Fcaching`=20function=20now=20imports=20the=20cache=20?= =?UTF-8?q?class=20from=20the=20`langchain.cache`=20module=20based=20on=20?= =?UTF-8?q?the=20`settings.cache`=20value.=20If=20the=20import=20is=20succ?= =?UTF-8?q?essful,=20the=20`langchain.llm=5Fcache`=20is=20set=20to=20an=20?= =?UTF-8?q?instance=20of=20the=20cache=20class.=20If=20the=20import=20fail?= =?UTF-8?q?s,=20a=20warning=20is=20logged.=20If=20an=20exception=20is=20ra?= =?UTF-8?q?ised=20during=20the=20setup,=20a=20warning=20is=20logged=20with?= =?UTF-8?q?=20the=20error=20message.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/utils.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/interface/utils.py b/src/backend/langflow/interface/utils.py index 668e1e6e4..1a37e89b4 100644 --- a/src/backend/langflow/interface/utils.py +++ b/src/backend/langflow/interface/utils.py @@ -64,7 +64,16 @@ def extract_input_variables_from_prompt(prompt: str) -> list[str]: def setup_llm_caching(): """Setup LLM caching.""" import langchain - from langchain.cache import SQLiteCache + from langflow.settings import settings + from langflow.interface.importing.utils import import_class - logger.debug("Setting up LLM caching") - langchain.llm_cache = SQLiteCache() + try: + cache_class = import_class(f"langchain.cache.{settings.cache}") + + logger.debug(f"Setting up LLM caching with {cache_class.__name__}") + langchain.llm_cache = cache_class() + logger.info(f"LLM caching setup with {cache_class.__name__}") + except ImportError: + logger.warning(f"Could not import {settings.cache}. ") + except Exception as exc: + logger.warning(f"Could not setup LLM caching. Error: {exc}") From a15da8eb0d1697cc194917606142597db260a4f9 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:20:13 -0300 Subject: [PATCH 15/43] =?UTF-8?q?=F0=9F=9A=80=20feat(settings.py):=20add?= =?UTF-8?q?=20cache=20configuration=20option=20The=20cache=20configuration?= =?UTF-8?q?=20option=20has=20been=20added=20to=20the=20settings=20file=20w?= =?UTF-8?q?ith=20a=20default=20value=20of=20"InMemoryCache".=20This=20allo?= =?UTF-8?q?ws=20the=20user=20to=20choose=20the=20cache=20implementation=20?= =?UTF-8?q?they=20want=20to=20use.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/langflow/settings.py b/src/backend/langflow/settings.py index 9d6ac3fa9..e3644e84c 100644 --- a/src/backend/langflow/settings.py +++ b/src/backend/langflow/settings.py @@ -21,6 +21,7 @@ class Settings(BaseSettings): utilities: List[str] = [] dev: bool = False database_url: str = "sqlite:///./langflow.db" + cache: str = "InMemoryCache" remove_api_keys: bool = False class Config: From 5f56384dce10d327ea29c6ea35ed7417a8c7d028 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:20:21 -0300 Subject: [PATCH 16/43] =?UTF-8?q?=F0=9F=9A=80=20feat(=5F=5Fmain=5F=5F.py):?= =?UTF-8?q?=20add=20support=20for=20cache=20configuration=20The=20`update?= =?UTF-8?q?=5Fsettings`=20function=20now=20accepts=20a=20`cache`=20paramet?= =?UTF-8?q?er=20that=20allows=20the=20user=20to=20specify=20the=20type=20o?= =?UTF-8?q?f=20cache=20to=20use.=20The=20`cache`=20parameter=20is=20set=20?= =?UTF-8?q?to=20a=20default=20value=20of=20`SQLiteCache`=20and=20can=20be?= =?UTF-8?q?=20overridden=20by=20setting=20the=20`LANGCHAIN=5FCACHE`=20envi?= =?UTF-8?q?ronment=20variable.=20This=20feature=20improves=20the=20flexibi?= =?UTF-8?q?lity=20of=20the=20application=20as=20it=20allows=20the=20user?= =?UTF-8?q?=20to=20choose=20the=20type=20of=20cache=20that=20best=20suits?= =?UTF-8?q?=20their=20needs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 29f60ed23..a3841ec93 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -30,6 +30,7 @@ def get_number_of_workers(workers=None): def update_settings( config: str, + cache: str, dev: bool = False, database_url: Optional[str] = None, remove_api_keys: bool = False, @@ -41,6 +42,8 @@ def update_settings( settings.update_settings(database_url=database_url) if remove_api_keys: settings.update_settings(remove_api_keys=remove_api_keys) + if cache: + settings.update_settings(cache=cache) def serve_on_jcloud(): @@ -102,6 +105,11 @@ def serve( ), log_level: str = typer.Option("critical", help="Logging level."), log_file: Path = typer.Option("logs/langflow.log", help="Path to the log file."), + cache: str = typer.Argument( + envvar="LANGCHAIN_CACHE", + help="Type of cache to use. (InMemoryCache, SQLiteCache)", + default="SQLiteCache", + ), jcloud: bool = typer.Option(False, help="Deploy on Jina AI Cloud"), dev: bool = typer.Option(False, help="Run in development mode (may contain bugs)"), database_url: str = typer.Option( @@ -130,7 +138,11 @@ def serve( configure(log_level=log_level, log_file=log_file) update_settings( - config, dev=dev, database_url=database_url, remove_api_keys=remove_api_keys + config, + dev=dev, + database_url=database_url, + remove_api_keys=remove_api_keys, + cache=cache, ) # get the directory of the current file if not path: 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 17/43] =?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 18/43] =?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 19/43] =?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 20/43] =?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 21/43] =?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 22/43] =?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 31f3b74c90317f5ede8ba76a229b42f3ca1d5b00 Mon Sep 17 00:00:00 2001 From: Naveen Choudhary Date: Thu, 15 Jun 2023 23:08:22 -0500 Subject: [PATCH 23/43] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e504c74b8..bd50b118e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ pymongo = "^4.4.0" certifi = "^2023.5.7" -[tool.poetry.group.dev.dependencies] +[tool.poetry.dev-dependencies] black = "^23.1.0" ipykernel = "^6.21.2" mypy = "^1.1.1" From a2197bfeb5df931909da3feb65928689186a4420 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 19:39:20 -0300 Subject: [PATCH 24/43] =?UTF-8?q?=F0=9F=90=9B=20fix(Midjorney):=20fix=20ty?= =?UTF-8?q?po=20in=20import=20statement=20and=20component=20name=20The=20i?= =?UTF-8?q?mport=20statement=20and=20component=20name=20were=20both=20miss?= =?UTF-8?q?pelled=20as=20"Midjorney"=20instead=20of=20"Midjourney".=20This?= =?UTF-8?q?=20commit=20fixes=20the=20typo=20in=20both=20places.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/icons/Midjorney/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/icons/Midjorney/index.tsx b/src/frontend/src/icons/Midjorney/index.tsx index fd09aa700..fc2daacb8 100644 --- a/src/frontend/src/icons/Midjorney/index.tsx +++ b/src/frontend/src/icons/Midjorney/index.tsx @@ -1,9 +1,9 @@ import React, { forwardRef } from "react"; -import { ReactComponent as MidjorneySVG } from "./Midjourney_Emblem.svg"; +import { ReactComponent as MidjourneySVG } from "./Midjourney_Emblem.svg"; -export const MidjorneyIcon = forwardRef< +export const MidjourneyIcon = forwardRef< SVGSVGElement, React.PropsWithChildren<{}> >((props, ref) => { - return ; + return ; }); From 263ca75fd57c430e901c24a5a4556f7ea012bee7 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 19:39:30 -0300 Subject: [PATCH 25/43] =?UTF-8?q?=E2=9C=A8=20feat(utils.ts):=20add=20new?= =?UTF-8?q?=20icons=20to=20nodeIconsLucide=20The=20import=20of=20Boxes=20a?= =?UTF-8?q?nd=20LayoutDashboard=20were=20removed=20as=20they=20were=20not?= =?UTF-8?q?=20being=20used=20in=20the=20file.=20New=20icons=20were=20added?= =?UTF-8?q?=20to=20nodeIconsLucide=20to=20improve=20the=20variety=20of=20i?= =?UTF-8?q?cons=20available=20for=20use.=20The=20new=20icons=20added=20are?= =?UTF-8?q?=20MongoDBAtlasVectorSearch,=20Pinecone,=20and=20SupabaseVector?= =?UTF-8?q?Store.=20=F0=9F=94=A5=20chore(utils.ts):=20remove=20unused=20im?= =?UTF-8?q?port=20of=20Boxes=20and=20LayoutDashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/utils.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 9e23d5342..a01acc137 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -45,7 +45,6 @@ import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./constants"; import { ComponentType, SVGProps } from "react"; import { - Boxes, Cpu, Fingerprint, Gift, @@ -53,7 +52,6 @@ import { HelpCircle, Laptop2, Layers, - LayoutDashboard, Lightbulb, Link, MessageCircle, @@ -189,7 +187,7 @@ export const nodeIcons: { HuggingFaceEmbeddings: HugginFaceIcon, IFixitLoader: IFixIcon, Meta: MetaIcon, - Midjorney: MidjorneyIcon, + Midjourney: MidjorneyIcon, NotionDirectoryLoader: NotionIcon, ChatOpenAI: OpenAiIcon, OpenAI: OpenAiIcon, @@ -290,6 +288,9 @@ export const nodeIconsLucide: { Midjorney: MidjorneyIcon as React.ForwardRefExoticComponent< ComponentType> >, + MongoDBAtlasVectorSearch: MongoDBIcon as React.ForwardRefExoticComponent< + ComponentType> + >, NotionDirectoryLoader: NotionIcon as React.ForwardRefExoticComponent< ComponentType> >, @@ -302,6 +303,9 @@ export const nodeIconsLucide: { OpenAIEmbeddings: OpenAiIcon as React.ForwardRefExoticComponent< ComponentType> >, + Pinecone: PineconeIcon as React.ForwardRefExoticComponent< + ComponentType> + >, Qdrant: QDrantIcon as React.ForwardRefExoticComponent< ComponentType> >, @@ -311,6 +315,9 @@ export const nodeIconsLucide: { SlackDirectoryLoader: SlackIcon as React.ForwardRefExoticComponent< ComponentType> >, + SupabaseVectorStore: SupabaseIcon as React.ForwardRefExoticComponent< + ComponentType> + >, agents: Rocket as React.ForwardRefExoticComponent< ComponentType> >, From 6f9e6922dfc7de9d9645e44df12a90979dee7f54 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 19:42:56 -0300 Subject: [PATCH 26/43] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.ts):=20correct?= =?UTF-8?q?=20typo=20in=20MidjourneyIcon=20import=20The=20import=20stateme?= =?UTF-8?q?nt=20for=20the=20MidjourneyIcon=20was=20misspelled=20as=20Midjo?= =?UTF-8?q?rneyIcon,=20which=20caused=20a=20runtime=20error.=20This=20comm?= =?UTF-8?q?it=20fixes=20the=20typo=20by=20changing=20the=20import=20statem?= =?UTF-8?q?ent=20to=20MidjourneyIcon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index a01acc137..834094ef0 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -33,7 +33,7 @@ import { HackerNewsIcon } from "./icons/hackerNews"; import { HugginFaceIcon } from "./icons/HuggingFace"; import { IFixIcon } from "./icons/IFixIt"; import { MetaIcon } from "./icons/Meta"; -import { MidjorneyIcon } from "./icons/Midjorney"; +import { MidjourneyIcon } from "./icons/Midjorney"; import { NotionIcon } from "./icons/Notion"; import { OpenAiIcon } from "./icons/OpenAi"; import { QDrantIcon } from "./icons/QDrant"; @@ -187,7 +187,7 @@ export const nodeIcons: { HuggingFaceEmbeddings: HugginFaceIcon, IFixitLoader: IFixIcon, Meta: MetaIcon, - Midjourney: MidjorneyIcon, + Midjourney: MidjourneyIcon, NotionDirectoryLoader: NotionIcon, ChatOpenAI: OpenAiIcon, OpenAI: OpenAiIcon, @@ -285,7 +285,7 @@ export const nodeIconsLucide: { Meta: MetaIcon as React.ForwardRefExoticComponent< ComponentType> >, - Midjorney: MidjorneyIcon as React.ForwardRefExoticComponent< + Midjorney: MidjourneyIcon as React.ForwardRefExoticComponent< ComponentType> >, MongoDBAtlasVectorSearch: MongoDBIcon as React.ForwardRefExoticComponent< From 5cd809ea6a40c0c6384a18727593eab11756155f Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 19:45:00 -0300 Subject: [PATCH 27/43] =?UTF-8?q?=F0=9F=94=BC=20chore(pyproject.toml):=20u?= =?UTF-8?q?pdate=20langchain=20dependency=20to=20version=200.0.215=20?= =?UTF-8?q?=F0=9F=94=BC=20chore(pyproject.toml):=20bump=20package=20versio?= =?UTF-8?q?n=20to=200.2.1=20The=20langchain=20dependency=20has=20been=20up?= =?UTF-8?q?dated=20to=20version=200.0.215,=20which=20includes=20bug=20fixe?= =?UTF-8?q?s=20and=20performance=20improvements.=20The=20package=20version?= =?UTF-8?q?=20has=20been=20bumped=20to=200.2.1=20to=20reflect=20the=20chan?= =?UTF-8?q?ges=20made.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 72 ++++++++++++++++++++++++-------------------------- pyproject.toml | 4 +-- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/poetry.lock b/poetry.lock index ef3ad4285..81019657b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -296,14 +296,14 @@ tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pyte [[package]] name = "authlib" -version = "1.2.0" +version = "1.2.1" description = "The ultimate Python library in building OAuth and OpenID Connect servers and clients." category = "main" optional = false python-versions = "*" files = [ - {file = "Authlib-1.2.0-py2.py3-none-any.whl", hash = "sha256:4ddf4fd6cfa75c9a460b361d4bd9dac71ffda0be879dbe4292a02e92349ad55a"}, - {file = "Authlib-1.2.0.tar.gz", hash = "sha256:4fa3e80883a5915ef9f5bc28630564bc4ed5b5af39812a3ff130ec76bd631e9d"}, + {file = "Authlib-1.2.1-py2.py3-none-any.whl", hash = "sha256:c88984ea00149a90e3537c964327da930779afa4564e354edfd98410bea01911"}, + {file = "Authlib-1.2.1.tar.gz", hash = "sha256:421f7c6b468d907ca2d9afede256f068f87e34d23dd221c07d13d4c234726afb"}, ] [package.dependencies] @@ -2580,14 +2580,14 @@ test = ["ipykernel", "pre-commit", "pytest", "pytest-cov", "pytest-timeout"] [[package]] name = "keyring" -version = "24.1.0" +version = "24.2.0" description = "Store and access your passwords safely." category = "main" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "keyring-24.1.0-py3-none-any.whl", hash = "sha256:ade5e1e7710a7579d7c01e64a712926270239aba48055b1cdc6c022dd6d789b5"}, - {file = "keyring-24.1.0.tar.gz", hash = "sha256:bd48a36612ef55505bf70e563528e3e66ba93267e344b6780cf6151f9c1eda6d"}, + {file = "keyring-24.2.0-py3-none-any.whl", hash = "sha256:4901caaf597bfd3bbd78c9a0c7c4c29fcd8310dab2cffefe749e916b6527acd6"}, + {file = "keyring-24.2.0.tar.gz", hash = "sha256:ca0746a19ec421219f4d713f848fa297a661a8a8c1504867e55bfb5e09091509"}, ] [package.dependencies] @@ -2604,14 +2604,14 @@ testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", [[package]] name = "langchain" -version = "0.0.211" +version = "0.0.215" description = "Building applications with LLMs through composability" category = "main" optional = false python-versions = ">=3.8.1,<4.0" files = [ - {file = "langchain-0.0.211-py3-none-any.whl", hash = "sha256:527b602466d68e5c4e82c550cb6e218d7fe0e1b3d37f97beddc13785a75dbf96"}, - {file = "langchain-0.0.211.tar.gz", hash = "sha256:35b43d4492ef3de67b6ea0168f12a489029cae0f5c4031d5c907764168b177cb"}, + {file = "langchain-0.0.215-py3-none-any.whl", hash = "sha256:af9587c2eb317a6e33123f8a4ee8ccd8685cfab62359ea4fec52c962d9646acf"}, + {file = "langchain-0.0.215.tar.gz", hash = "sha256:a6b261f3be941eeac2d9b37fbf8996fa4279ef724f064e8c90813046126da85b"}, ] [package.dependencies] @@ -5445,41 +5445,39 @@ tests = ["black (>=22.3.0)", "flake8 (>=3.8.2)", "matplotlib (>=3.1.3)", "mypy ( [[package]] name = "scipy" -version = "1.10.1" +version = "1.11.0" description = "Fundamental algorithms for scientific computing in Python" category = "main" optional = false -python-versions = "<3.12,>=3.8" +python-versions = "<3.13,>=3.9" files = [ - {file = "scipy-1.10.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e7354fd7527a4b0377ce55f286805b34e8c54b91be865bac273f527e1b839019"}, - {file = "scipy-1.10.1-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:4b3f429188c66603a1a5c549fb414e4d3bdc2a24792e061ffbd607d3d75fd84e"}, - {file = "scipy-1.10.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1553b5dcddd64ba9a0d95355e63fe6c3fc303a8fd77c7bc91e77d61363f7433f"}, - {file = "scipy-1.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c0ff64b06b10e35215abce517252b375e580a6125fd5fdf6421b98efbefb2d2"}, - {file = "scipy-1.10.1-cp310-cp310-win_amd64.whl", hash = "sha256:fae8a7b898c42dffe3f7361c40d5952b6bf32d10c4569098d276b4c547905ee1"}, - {file = "scipy-1.10.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0f1564ea217e82c1bbe75ddf7285ba0709ecd503f048cb1236ae9995f64217bd"}, - {file = "scipy-1.10.1-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:d925fa1c81b772882aa55bcc10bf88324dadb66ff85d548c71515f6689c6dac5"}, - {file = "scipy-1.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaea0a6be54462ec027de54fca511540980d1e9eea68b2d5c1dbfe084797be35"}, - {file = "scipy-1.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15a35c4242ec5f292c3dd364a7c71a61be87a3d4ddcc693372813c0b73c9af1d"}, - {file = "scipy-1.10.1-cp311-cp311-win_amd64.whl", hash = "sha256:43b8e0bcb877faf0abfb613d51026cd5cc78918e9530e375727bf0625c82788f"}, - {file = "scipy-1.10.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5678f88c68ea866ed9ebe3a989091088553ba12c6090244fdae3e467b1139c35"}, - {file = "scipy-1.10.1-cp38-cp38-macosx_12_0_arm64.whl", hash = "sha256:39becb03541f9e58243f4197584286e339029e8908c46f7221abeea4b749fa88"}, - {file = "scipy-1.10.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bce5869c8d68cf383ce240e44c1d9ae7c06078a9396df68ce88a1230f93a30c1"}, - {file = "scipy-1.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:07c3457ce0b3ad5124f98a86533106b643dd811dd61b548e78cf4c8786652f6f"}, - {file = "scipy-1.10.1-cp38-cp38-win_amd64.whl", hash = "sha256:049a8bbf0ad95277ffba9b3b7d23e5369cc39e66406d60422c8cfef40ccc8415"}, - {file = "scipy-1.10.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:cd9f1027ff30d90618914a64ca9b1a77a431159df0e2a195d8a9e8a04c78abf9"}, - {file = "scipy-1.10.1-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:79c8e5a6c6ffaf3a2262ef1be1e108a035cf4f05c14df56057b64acc5bebffb6"}, - {file = "scipy-1.10.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:51af417a000d2dbe1ec6c372dfe688e041a7084da4fdd350aeb139bd3fb55353"}, - {file = "scipy-1.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1b4735d6c28aad3cdcf52117e0e91d6b39acd4272f3f5cd9907c24ee931ad601"}, - {file = "scipy-1.10.1-cp39-cp39-win_amd64.whl", hash = "sha256:7ff7f37b1bf4417baca958d254e8e2875d0cc23aaadbe65b3d5b3077b0eb23ea"}, - {file = "scipy-1.10.1.tar.gz", hash = "sha256:2cf9dfb80a7b4589ba4c40ce7588986d6d5cebc5457cad2c2880f6bc2d42f3a5"}, + {file = "scipy-1.11.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2e4f14c11fbf825319dbd7f467639a241e7c956c34edb1e036ec7bb6271e4f7b"}, + {file = "scipy-1.11.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:b269ed44e2e2e43611f2ae95ba551fd98abbdc1a7ea8268f72f75876982368c4"}, + {file = "scipy-1.11.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c29bae479b17d85208dfdfc67e50d5944ee23211f236728aadde9b0b7c1c33e"}, + {file = "scipy-1.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a53f9cebcfda6158c241c35a559407a4ef6b8cb0863eb4144958fe0a0b7c3dae"}, + {file = "scipy-1.11.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ebf4b2ea26d50312731ddba2406389c5ddcbff9d777cf3277ea11decc81e5dfb"}, + {file = "scipy-1.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:894ced9a2cdb050ff5e392f274617af46dca896d5c9112fa4a2019929554d321"}, + {file = "scipy-1.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7a92bd3cd4acad2e0e0b360176d5ec68b100983c8145add8a8233acddf4e5fcc"}, + {file = "scipy-1.11.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:586608ea35206257d4e0ce6f154a6cfef71723b2c1f6d40de5e0b0e8a81cd2ff"}, + {file = "scipy-1.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8e631c3c49c24f30828580b8126fe3be5cca5409dad5b797418a5b8965eeafa"}, + {file = "scipy-1.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ccc70892ea674f93183c5c4139557b611e42f644dd755da4b19ca974ab770672"}, + {file = "scipy-1.11.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80015b8928f91bd40377b2b1010ba2e09b03680cbfc291208740494aeb8debf2"}, + {file = "scipy-1.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:6302c7cba5bf99c901653ff158746625526cc438f058bce41514d7469b79b2c3"}, + {file = "scipy-1.11.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c61ea63124da6a3cff38126426912cc86420898b4902a9bc5e5b6524547a6dcb"}, + {file = "scipy-1.11.0-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:684d44607eacd5dd367c7a9e76e922523fa9c0a7f2379a4d0fc4d70d751464cc"}, + {file = "scipy-1.11.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f0c9c160d117fe71cd2a12ef21cce8e0475ade2fd97c761ef327b9839089bd16"}, + {file = "scipy-1.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:83867a63515c4e3fce3272d81200dda614d70f4c3a22f047d84021bfe83d7929"}, + {file = "scipy-1.11.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6666a1e31b2123a077f0dc7ab1053e36479cfd457fb9f5c367e7198505c6607a"}, + {file = "scipy-1.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:fad4006248513528e0c496de295a9f4d2b65086cc0e388f748e7dbf49fa12760"}, + {file = "scipy-1.11.0.tar.gz", hash = "sha256:f9b0248cb9d08eead44cde47cbf6339f1e9aa0dfde28f5fb27950743e317bd5d"}, ] [package.dependencies] -numpy = ">=1.19.5,<1.27.0" +numpy = ">=1.21.6,<1.28.0" [package.extras] -dev = ["click", "doit (>=0.36.0)", "flake8", "mypy", "pycodestyle", "pydevtool", "rich-click", "typing_extensions"] -doc = ["matplotlib (>2)", "numpydoc", "pydata-sphinx-theme (==0.9.0)", "sphinx (!=4.1.0)", "sphinx-design (>=0.2.0)"] +dev = ["click", "cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy", "pycodestyle", "pydevtool", "rich-click", "ruff", "types-psutil", "typing_extensions"] +doc = ["jupytext", "matplotlib (>2)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (==0.9.0)", "sphinx (!=4.1.0)", "sphinx-design (>=0.2.0)"] test = ["asv", "gmpy2", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] [[package]] @@ -7117,4 +7115,4 @@ deploy = ["langchain-serve"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.12" -content-hash = "e7b18762564269aaf9c6b046fa151f5e3acf85444f38653503341f658155e70a" +content-hash = "2f8373e1c80ce345f39ed9247fd4759ae94b5c754c4e850d3aa72183556eb92b" diff --git a/pyproject.toml b/pyproject.toml index bd50b118e..069662355 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.2.0" +version = "0.2.1" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ @@ -30,7 +30,7 @@ google-search-results = "^2.4.1" google-api-python-client = "^2.79.0" typer = "^0.9.0" gunicorn = "^20.1.0" -langchain = "^0.0.211" +langchain = "^0.0.215" openai = "^0.27.8" types-pyyaml = "^6.0.12.8" pandas = "^1.5.3" From a3efa8fe5d62cc56935bd36ce22ba0cb9ff52a63 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 19:52:49 -0300 Subject: [PATCH 28/43] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20fix=20imp?= =?UTF-8?q?ort=20order=20to=20avoid=20import=20errors=20The=20import=20ord?= =?UTF-8?q?er=20was=20changed=20to=20avoid=20import=20errors.=20The=20impo?= =?UTF-8?q?rt=20of=20langchain=20was=20moved=20to=20the=20top=20of=20the?= =?UTF-8?q?=20file=20to=20avoid=20circular=20import=20errors.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/interface/utils.py b/src/backend/langflow/interface/utils.py index 1a37e89b4..8d45aa1b1 100644 --- a/src/backend/langflow/interface/utils.py +++ b/src/backend/langflow/interface/utils.py @@ -63,11 +63,12 @@ def extract_input_variables_from_prompt(prompt: str) -> list[str]: def setup_llm_caching(): """Setup LLM caching.""" - import langchain - from langflow.settings import settings - from langflow.interface.importing.utils import import_class try: + import langchain + from langflow.settings import settings + from langflow.interface.importing.utils import import_class + cache_class = import_class(f"langchain.cache.{settings.cache}") logger.debug(f"Setting up LLM caching with {cache_class.__name__}") 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 29/43] =?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 30/43] =?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 31/43] =?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 c51a90c5370d4899a11595574dc666127d559606 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 26 Jun 2023 13:27:05 -0300 Subject: [PATCH 32/43] =?UTF-8?q?=F0=9F=9A=80=20feat(custom.py):=20add=20A?= =?UTF-8?q?gentType=20enum=20to=20improve=20readability=20and=20type=20saf?= =?UTF-8?q?ety=20The=20`AgentType`=20enum=20is=20added=20to=20the=20`langc?= =?UTF-8?q?hain.agents.custom`=20module=20to=20improve=20readability=20and?= =?UTF-8?q?=20type=20safety.=20The=20`InitializeAgent`=20class=20now=20use?= =?UTF-8?q?s=20the=20`AgentType`=20enum=20to=20ensure=20that=20the=20`agen?= =?UTF-8?q?t`=20parameter=20is=20a=20valid=20value=20from=20the=20enum.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/agents/custom.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/langflow/interface/agents/custom.py b/src/backend/langflow/interface/agents/custom.py index a4191a8b7..aa0cfb5db 100644 --- a/src/backend/langflow/interface/agents/custom.py +++ b/src/backend/langflow/interface/agents/custom.py @@ -6,6 +6,7 @@ from langchain.agents import ( Tool, ZeroShotAgent, initialize_agent, + AgentType, ) from langchain.agents.agent_toolkits import ( SQLDatabaseToolkit, @@ -297,6 +298,9 @@ class InitializeAgent(CustomAgentExecutor): agent: str, memory: Optional[BaseChatMemory] = None, ): + # Find which value in the AgentType enum corresponds to the string + # passed in as agent + agent = AgentType(agent) return initialize_agent( tools=tools, llm=llm, From 644fc982717832246474f5122eea3829660cef0f Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 26 Jun 2023 13:37:28 -0300 Subject: [PATCH 33/43] =?UTF-8?q?=F0=9F=9A=80=20chore(pyproject.toml):=20u?= =?UTF-8?q?pdate=20package=20version=20to=200.2.2=20The=20package=20versio?= =?UTF-8?q?n=20has=20been=20updated=20to=200.2.2=20to=20reflect=20the=20ch?= =?UTF-8?q?anges=20made=20to=20the=20package.=20This=20is=20a=20chore=20co?= =?UTF-8?q?mmit=20as=20it=20does=20not=20include=20any=20functional=20chan?= =?UTF-8?q?ges=20to=20the=20package.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 66 +++++++++++++++++++++++++------------------------- pyproject.toml | 2 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/poetry.lock b/poetry.lock index 81019657b..b13392910 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1102,13 +1102,13 @@ wmi = ["wmi (>=1.5.1,<2.0.0)"] [[package]] name = "docarray" -version = "0.21.0" +version = "0.21.1" description = "The data structure for unstructured data" category = "main" optional = false python-versions = "*" files = [ - {file = "docarray-0.21.0.tar.gz", hash = "sha256:3c9f605123800c1b0cdf8c458be3fb19c05e9a81f723e51200ef531b02e689ee"}, + {file = "docarray-0.21.1.tar.gz", hash = "sha256:3a478707465c263147a98fe32feb0b6eb215c0ed58852135ac86acb7eae5cecb"}, ] [package.dependencies] @@ -3199,44 +3199,44 @@ dill = ">=0.3.6" [[package]] name = "mypy" -version = "1.4.0" +version = "1.4.1" description = "Optional static typing for Python" category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "mypy-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a3af348e0925a59213244f28c7c0c3a2c2088b4ba2fe9d6c8d4fbb0aba0b7d05"}, - {file = "mypy-1.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a0b2e0da7ff9dd8d2066d093d35a169305fc4e38db378281fce096768a3dbdbf"}, - {file = "mypy-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:210fe0f39ec5be45dd9d0de253cb79245f0a6f27631d62e0c9c7988be7152965"}, - {file = "mypy-1.4.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:f7a5971490fd4a5a436e143105a1f78fa8b3fe95b30fff2a77542b4f3227a01f"}, - {file = "mypy-1.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:50f65f0e9985f1e50040e603baebab83efed9eb37e15a22a4246fa7cd660f981"}, - {file = "mypy-1.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3b1b5c875fcf3e7217a3de7f708166f641ca154b589664c44a6fd6d9f17d9e7e"}, - {file = "mypy-1.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b4c734d947e761c7ceb1f09a98359dd5666460acbc39f7d0a6b6beec373c5840"}, - {file = "mypy-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f5984a8d13d35624e3b235a793c814433d810acba9eeefe665cdfed3d08bc3af"}, - {file = "mypy-1.4.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:0f98973e39e4a98709546a9afd82e1ffcc50c6ec9ce6f7870f33ebbf0bd4f26d"}, - {file = "mypy-1.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:19d42b08c7532d736a7e0fb29525855e355fa51fd6aef4f9bbc80749ff64b1a2"}, - {file = "mypy-1.4.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:6ba9a69172abaa73910643744d3848877d6aac4a20c41742027dcfd8d78f05d9"}, - {file = "mypy-1.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a34eed094c16cad0f6b0d889811592c7a9b7acf10d10a7356349e325d8704b4f"}, - {file = "mypy-1.4.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:53c2a1fed81e05ded10a4557fe12bae05b9ecf9153f162c662a71d924d504135"}, - {file = "mypy-1.4.0-cp37-cp37m-win_amd64.whl", hash = "sha256:bba57b4d2328740749f676807fcf3036e9de723530781405cc5a5e41fc6e20de"}, - {file = "mypy-1.4.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:653863c75f0dbb687d92eb0d4bd9fe7047d096987ecac93bb7b1bc336de48ebd"}, - {file = "mypy-1.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7461469e163f87a087a5e7aa224102a30f037c11a096a0ceeb721cb0dce274c8"}, - {file = "mypy-1.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0cf0ca95e4b8adeaf07815a78b4096b65adf64ea7871b39a2116c19497fcd0dd"}, - {file = "mypy-1.4.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:94a81b9354545123feb1a99b960faeff9e1fa204fce47e0042335b473d71530d"}, - {file = "mypy-1.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:67242d5b28ed0fa88edd8f880aed24da481929467fdbca6487167cb5e3fd31ff"}, - {file = "mypy-1.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3f2b353eebef669529d9bd5ae3566905a685ae98b3af3aad7476d0d519714758"}, - {file = "mypy-1.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:62bf18d97c6b089f77f0067b4e321db089d8520cdeefc6ae3ec0f873621c22e5"}, - {file = "mypy-1.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ca33ab70a4aaa75bb01086a0b04f0ba8441e51e06fc57e28585176b08cad533b"}, - {file = "mypy-1.4.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5a0ee54c2cb0f957f8a6f41794d68f1a7e32b9968675ade5846f538504856d42"}, - {file = "mypy-1.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:6c34d43e3d54ad05024576aef28081d9d0580f6fa7f131255f54020eb12f5352"}, - {file = "mypy-1.4.0-py3-none-any.whl", hash = "sha256:f051ca656be0c179c735a4c3193f307d34c92fdc4908d44fd4516fbe8b10567d"}, - {file = "mypy-1.4.0.tar.gz", hash = "sha256:de1e7e68148a213036276d1f5303b3836ad9a774188961eb2684eddff593b042"}, + {file = "mypy-1.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:566e72b0cd6598503e48ea610e0052d1b8168e60a46e0bfd34b3acf2d57f96a8"}, + {file = "mypy-1.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ca637024ca67ab24a7fd6f65d280572c3794665eaf5edcc7e90a866544076878"}, + {file = "mypy-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0dde1d180cd84f0624c5dcaaa89c89775550a675aff96b5848de78fb11adabcd"}, + {file = "mypy-1.4.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8c4d8e89aa7de683e2056a581ce63c46a0c41e31bd2b6d34144e2c80f5ea53dc"}, + {file = "mypy-1.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:bfdca17c36ae01a21274a3c387a63aa1aafe72bff976522886869ef131b937f1"}, + {file = "mypy-1.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7549fbf655e5825d787bbc9ecf6028731973f78088fbca3a1f4145c39ef09462"}, + {file = "mypy-1.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:98324ec3ecf12296e6422939e54763faedbfcc502ea4a4c38502082711867258"}, + {file = "mypy-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:141dedfdbfe8a04142881ff30ce6e6653c9685b354876b12e4fe6c78598b45e2"}, + {file = "mypy-1.4.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8207b7105829eca6f3d774f64a904190bb2231de91b8b186d21ffd98005f14a7"}, + {file = "mypy-1.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:16f0db5b641ba159eff72cff08edc3875f2b62b2fa2bc24f68c1e7a4e8232d01"}, + {file = "mypy-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:470c969bb3f9a9efcedbadcd19a74ffb34a25f8e6b0e02dae7c0e71f8372f97b"}, + {file = "mypy-1.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5952d2d18b79f7dc25e62e014fe5a23eb1a3d2bc66318df8988a01b1a037c5b"}, + {file = "mypy-1.4.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:190b6bab0302cec4e9e6767d3eb66085aef2a1cc98fe04936d8a42ed2ba77bb7"}, + {file = "mypy-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9d40652cc4fe33871ad3338581dca3297ff5f2213d0df345bcfbde5162abf0c9"}, + {file = "mypy-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:01fd2e9f85622d981fd9063bfaef1aed6e336eaacca00892cd2d82801ab7c042"}, + {file = "mypy-1.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2460a58faeea905aeb1b9b36f5065f2dc9a9c6e4c992a6499a2360c6c74ceca3"}, + {file = "mypy-1.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a2746d69a8196698146a3dbe29104f9eb6a2a4d8a27878d92169a6c0b74435b6"}, + {file = "mypy-1.4.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:ae704dcfaa180ff7c4cfbad23e74321a2b774f92ca77fd94ce1049175a21c97f"}, + {file = "mypy-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:43d24f6437925ce50139a310a64b2ab048cb2d3694c84c71c3f2a1626d8101dc"}, + {file = "mypy-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c482e1246726616088532b5e964e39765b6d1520791348e6c9dc3af25b233828"}, + {file = "mypy-1.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:43b592511672017f5b1a483527fd2684347fdffc041c9ef53428c8dc530f79a3"}, + {file = "mypy-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:34a9239d5b3502c17f07fd7c0b2ae6b7dd7d7f6af35fbb5072c6208e76295816"}, + {file = "mypy-1.4.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5703097c4936bbb9e9bce41478c8d08edd2865e177dc4c52be759f81ee4dd26c"}, + {file = "mypy-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:e02d700ec8d9b1859790c0475df4e4092c7bf3272a4fd2c9f33d87fac4427b8f"}, + {file = "mypy-1.4.1-py3-none-any.whl", hash = "sha256:45d32cec14e7b97af848bddd97d85ea4f0db4d5a149ed9676caa4eb2f7402bb4"}, + {file = "mypy-1.4.1.tar.gz", hash = "sha256:9bbcd9ab8ea1f2e1c8031c21445b511442cc45c89951e49bbf852cbb70755b1b"}, ] [package.dependencies] mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=3.10" +typing-extensions = ">=4.1.0" [package.extras] dmypy = ["psutil (>=4.0)"] @@ -5129,14 +5129,14 @@ cffi = {version = "*", markers = "implementation_name == \"pypy\""} [[package]] name = "qdrant-client" -version = "1.3.0" +version = "1.3.1" description = "Client library for the Qdrant vector search engine" category = "main" optional = false python-versions = ">=3.7,<3.12" files = [ - {file = "qdrant_client-1.3.0-py3-none-any.whl", hash = "sha256:f5ab40e24dd31d919475f9a1d7823b1eff2f4df8b4af1812abf19e2789b7021e"}, - {file = "qdrant_client-1.3.0.tar.gz", hash = "sha256:68168e9b69af7c49ea5f9e90e027ae1944d2a1ee1ea6701315e0ba8a2fdc4a63"}, + {file = "qdrant_client-1.3.1-py3-none-any.whl", hash = "sha256:9640855585d1f532094e342f07e0f2ef00652a60fc5d903c92ca3989a1e86318"}, + {file = "qdrant_client-1.3.1.tar.gz", hash = "sha256:a999358b10e611d71b4b04c6ded36a6cfc963e56b4c3f99d9c1a603ca524a82e"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index 069662355..da75b0207 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.2.1" +version = "0.2.2" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ From 47fcdaef419d31956e56ea38b5b1013cb633f08d Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 26 Jun 2023 18:29:27 -0300 Subject: [PATCH 34/43] =?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 35/43] =?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: From 87af22d0592d87bf9e0f54e4c2f265df5a8fdc8f Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 07:33:01 -0300 Subject: [PATCH 36/43] =?UTF-8?q?=F0=9F=94=A8=20refactor(components):=20ad?= =?UTF-8?q?d=20info=20property=20to=20ParameterComponentType=20The=20Param?= =?UTF-8?q?eterComponent=20now=20has=20an=20info=20icon=20and=20tooltip=20?= =?UTF-8?q?to=20show=20additional=20information=20about=20the=20parameter.?= =?UTF-8?q?=20The=20GenericNode=20component=20now=20passes=20the=20info=20?= =?UTF-8?q?prop=20to=20the=20ParameterComponent=20to=20show=20the=20additi?= =?UTF-8?q?onal=20information.=20The=20ParameterComponentType=20has=20been?= =?UTF-8?q?=20refactored=20to=20include=20the=20info=20property.=20?= =?UTF-8?q?=F0=9F=8E=A8=20style(parameterComponent):=20add=20info=20icon?= =?UTF-8?q?=20and=20tooltip=20to=20show=20additional=20information=20?= =?UTF-8?q?=F0=9F=9A=80=20feat(GenericNode):=20pass=20info=20prop=20to=20P?= =?UTF-8?q?arameterComponent=20to=20show=20additional=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/parameterComponent/index.tsx | 34 ++++++++++++++++++- .../src/CustomNodes/GenericNode/index.tsx | 1 + src/frontend/src/types/components/index.ts | 9 ++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 4347b88ca..0701bfcd4 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -25,6 +25,7 @@ import { nodeColors } from "../../../../utils"; import ShadTooltip from "../../../../components/ShadTooltipComponent"; import { PopUpContext } from "../../../../contexts/popUpContext"; import ToggleShadComponent from "../../../../components/toggleShadComponent"; +import { Info } from "lucide-react"; export default function ParameterComponent({ left, @@ -36,9 +37,11 @@ export default function ParameterComponent({ type, name = "", required = false, + info = "", }: ParameterComponentType) { const ref = useRef(null); const refHtml = useRef(null); + const infoHtml = useRef(null); const updateNodeInternals = useUpdateNodeInternals(); const [position, setPosition] = useState(0); const { closePopUp } = useContext(PopUpContext); @@ -79,6 +82,18 @@ export default function ParameterComponent({ }); }; + useEffect(() => { + infoHtml.current = ( +
+ {info.split("\n").map((line, i) => ( +

+ {line} +

+ ))} +
+ ); + }, [info]); + useEffect(() => { const groupedObj = groupByFamily(myData, tooltipTitle); @@ -126,8 +141,25 @@ export default function ParameterComponent({ className="w-full flex flex-wrap justify-between items-center bg-muted dark:bg-gray-800 dark:text-white mt-1 px-5 py-2" > <> -
+
{title} +
+ {info !== "" && ( + + + + )} +
{required ? " *" : ""}
{left && diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 743339a48..40a306ce6 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -244,6 +244,7 @@ export default function GenericNode({ ? toTitleCase(data.node.template[t].name) : toTitleCase(t) } + info={data.node.template[t].info} name={t} tooltipTitle={data.node.template[t].type} required={data.node.template[t].required} diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index 630526193..b1570ddda 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -1,10 +1,4 @@ -import { - ComponentType, - ForwardRefExoticComponent, - ReactElement, - ReactNode, - SVGProps, -} from "react"; +import { ReactElement, ReactNode } from "react"; import { NodeDataType } from "../flow/index"; import { typesContextType } from "../typesContext"; export type InputComponentType = { @@ -41,6 +35,7 @@ export type ParameterComponentType = { name?: string; tooltipTitle: string; dataContext?: typesContextType; + info?: string; }; export type InputListComponentType = { value: string[]; From 415bee73847e66b749ef3d2cb19cfc1720c5591d Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 07:33:35 -0300 Subject: [PATCH 37/43] =?UTF-8?q?=F0=9F=94=A7=20chore(base.py,=20constants?= =?UTF-8?q?.py,=20llms.py):=20add=20info=20field=20to=20TemplateField=20an?= =?UTF-8?q?d=20OPENAI=5FAPI=5FBASE=5FINFO=20constant=20The=20`info`=20fiel?= =?UTF-8?q?d=20is=20added=20to=20the=20`TemplateField`=20class=20to=20prov?= =?UTF-8?q?ide=20additional=20information=20about=20the=20field.=20The=20`?= =?UTF-8?q?OPENAI=5FAPI=5FBASE=5FINFO`=20constant=20is=20added=20to=20the?= =?UTF-8?q?=20`constants.py`=20file=20to=20provide=20information=20about?= =?UTF-8?q?=20the=20base=20URL=20of=20the=20OpenAI=20API=20and=20how=20it?= =?UTF-8?q?=20can=20be=20changed=20to=20use=20other=20APIs=20like=20Prem?= =?UTF-8?q?=20and=20LocalAI.=20The=20`info`=20field=20is=20set=20to=20`OPE?= =?UTF-8?q?NAI=5FAPI=5FBASE=5FINFO`=20for=20the=20`openai=5Fapi=5Fbase`=20?= =?UTF-8?q?field=20in=20the=20`LLMFrontendNode`=20class=20in=20`llms.py`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/template/field/base.py | 1 + .../langflow/template/frontend_node/constants.py | 10 ++++++++++ src/backend/langflow/template/frontend_node/llms.py | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/backend/langflow/template/field/base.py b/src/backend/langflow/template/field/base.py index a9c18ff63..fdfdca562 100644 --- a/src/backend/langflow/template/field/base.py +++ b/src/backend/langflow/template/field/base.py @@ -21,6 +21,7 @@ class TemplateFieldCreator(BaseModel, ABC): name: str = "" display_name: Optional[str] = None advanced: bool = False + info: Optional[str] = "" def to_dict(self): result = self.dict() diff --git a/src/backend/langflow/template/frontend_node/constants.py b/src/backend/langflow/template/frontend_node/constants.py index 20b8a0c61..ac2e400b3 100644 --- a/src/backend/langflow/template/frontend_node/constants.py +++ b/src/backend/langflow/template/frontend_node/constants.py @@ -32,3 +32,13 @@ You are a good listener and you can talk about anything. HUMAN_PROMPT = "{input}" QA_CHAIN_TYPES = ["stuff", "map_reduce", "map_rerank", "refine"] + + +# This variable is used to tell the user +# that it can be changed to use other APIs +# like Prem and LocalAI +OPENAI_API_BASE_INFO = """ +The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. + +You can change this to use other APIs like Prem and LocalAI. +""" diff --git a/src/backend/langflow/template/frontend_node/llms.py b/src/backend/langflow/template/frontend_node/llms.py index 272e42c7f..65bffc303 100644 --- a/src/backend/langflow/template/frontend_node/llms.py +++ b/src/backend/langflow/template/frontend_node/llms.py @@ -2,6 +2,7 @@ from typing import Optional from langflow.template.field.base import TemplateField from langflow.template.frontend_node.base import FrontendNode +from langflow.template.frontend_node.constants import OPENAI_API_BASE_INFO class LLMFrontendNode(FrontendNode): @@ -15,6 +16,9 @@ class LLMFrontendNode(FrontendNode): if "key" not in field.name.lower() and "token" not in field.name.lower(): field.password = False + if field.name == "openai_api_base": + field.info = OPENAI_API_BASE_INFO + @staticmethod def format_azure_field(field: TemplateField): if field.name == "model_name": From 0d84d196573f3b620c8431ab080cfe4bd1f389f4 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 07:44:20 -0300 Subject: [PATCH 38/43] =?UTF-8?q?=F0=9F=93=9D=20docs(constants.py):=20upda?= =?UTF-8?q?te=20OpenAI=20API=20base=20info=20to=20include=20additional=20A?= =?UTF-8?q?PI=20options=20This=20commit=20updates=20the=20documentation=20?= =?UTF-8?q?in=20the=20constants.py=20file=20to=20include=20additional=20AP?= =?UTF-8?q?I=20options=20that=20can=20be=20used=20instead=20of=20the=20def?= =?UTF-8?q?ault=20OpenAI=20API.=20The=20new=20options=20are=20JinaChat,=20?= =?UTF-8?q?LocalAI,=20and=20Prem.=20This=20change=20provides=20more=20info?= =?UTF-8?q?rmation=20to=20the=20user=20and=20allows=20them=20to=20make=20a?= =?UTF-8?q?n=20informed=20decision=20when=20choosing=20an=20API=20to=20use?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/template/frontend_node/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/template/frontend_node/constants.py b/src/backend/langflow/template/frontend_node/constants.py index ac2e400b3..d30239ff7 100644 --- a/src/backend/langflow/template/frontend_node/constants.py +++ b/src/backend/langflow/template/frontend_node/constants.py @@ -40,5 +40,5 @@ QA_CHAIN_TYPES = ["stuff", "map_reduce", "map_rerank", "refine"] OPENAI_API_BASE_INFO = """ The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. -You can change this to use other APIs like Prem and LocalAI. +You can change this to use other APIs like JinaChat, LocalAI and Prem. """ From f78088bdb24dbd2c0ef3eb4d6429098618c15a2c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 09:44:20 -0300 Subject: [PATCH 39/43] =?UTF-8?q?=F0=9F=94=A7=20refactor(=5F=5Fmain=5F=5F.?= =?UTF-8?q?py,=20main.py):=20move=20setup=5Fstatic=5Ffiles=20function=20to?= =?UTF-8?q?=20main.py=20and=20rename=20create=5Fapp=20to=20setup=5Fapp=20?= =?UTF-8?q?=E2=9C=A8=20feat(=5F=5Fmain=5F=5F.py,=20main.py):=20add=20suppo?= =?UTF-8?q?rt=20for=20a=20custom=20static=20files=20directory=20to=20be=20?= =?UTF-8?q?passed=20as=20an=20argument=20to=20the=20app=20The=20`setup=5Fs?= =?UTF-8?q?tatic=5Ffiles`=20function=20has=20been=20moved=20from=20`=5F=5F?= =?UTF-8?q?main=5F=5F.py`=20to=20`main.py`=20to=20improve=20code=20organiz?= =?UTF-8?q?ation.=20The=20function=20has=20also=20been=20renamed=20to=20`s?= =?UTF-8?q?etup=5Fapp`=20to=20better=20reflect=20its=20purpose.=20The=20`c?= =?UTF-8?q?reate=5Fapp`=20function=20has=20been=20renamed=20to=20`setup=5F?= =?UTF-8?q?app`=20to=20follow=20the=20naming=20convention=20of=20the=20new?= =?UTF-8?q?=20function.=20The=20`setup=5Fapp`=20function=20now=20accepts?= =?UTF-8?q?=20an=20optional=20argument=20`static=5Ffiles=5Fdir`=20which=20?= =?UTF-8?q?allows=20the=20user=20to=20specify=20a=20custom=20directory=20f?= =?UTF-8?q?or=20static=20files.=20This=20improves=20the=20flexibility=20of?= =?UTF-8?q?=20the=20app=20as=20it=20can=20now=20be=20run=20with=20a=20cust?= =?UTF-8?q?om=20frontend.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 40 ++++---------------------------- src/backend/langflow/main.py | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index a3841ec93..377339c98 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -1,6 +1,5 @@ import sys import time -from fastapi import FastAPI import httpx from multiprocess import Process, cpu_count # type: ignore import platform @@ -11,9 +10,7 @@ from rich.panel import Panel from rich import box from rich import print as rprint import typer -from fastapi.staticfiles import StaticFiles -from fastapi.responses import FileResponse -from langflow.main import create_app +from langflow.main import setup_app from langflow.settings import settings from langflow.utils.logger import configure, logger import webbrowser @@ -144,15 +141,9 @@ def serve( remove_api_keys=remove_api_keys, cache=cache, ) - # get the directory of the current file - if not path: - frontend_path = Path(__file__).parent - static_files_dir = frontend_path / "frontend" - else: - static_files_dir = Path(path) - - app = create_app() - setup_static_files(app, static_files_dir) + # create path object if path is provided + path = Path(path) if path else path + app = setup_app(static_files_dir=path) # check if port is being used if is_port_in_use(port, host): port = get_free_port(port) @@ -200,29 +191,6 @@ def run_on_windows(host, port, log_level, options, app): run_langflow(host, port, log_level, options, app) -def setup_static_files(app: FastAPI, static_files_dir: Path): - """ - Setup the static files directory. - - Args: - app (FastAPI): FastAPI app. - path (str): Path to the static files directory. - """ - app.mount( - "/", - StaticFiles(directory=static_files_dir, html=True), - name="static", - ) - - @app.exception_handler(404) - async def custom_404_handler(request, __): - path = static_files_dir / "index.html" - - if not path.exists(): - raise RuntimeError(f"File at path {path} does not exist.") - return FileResponse(path) - - def is_port_in_use(port, host="localhost"): """ Check if a port is in use. diff --git a/src/backend/langflow/main.py b/src/backend/langflow/main.py index 2a1293f2e..e937931d6 100644 --- a/src/backend/langflow/main.py +++ b/src/backend/langflow/main.py @@ -1,5 +1,9 @@ +from pathlib import Path +from typing import Optional from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware +from fastapi.responses import FileResponse +from fastapi.staticfiles import StaticFiles from langflow.api import router from langflow.database.base import create_db_and_tables @@ -33,6 +37,42 @@ def create_app(): return app +def setup_static_files(app: FastAPI, static_files_dir: Path): + """ + Setup the static files directory. + Args: + app (FastAPI): FastAPI app. + path (str): Path to the static files directory. + """ + app.mount( + "/", + StaticFiles(directory=static_files_dir, html=True), + name="static", + ) + + @app.exception_handler(404) + async def custom_404_handler(request, __): + path = static_files_dir / "index.html" + + if not path.exists(): + raise RuntimeError(f"File at path {path} does not exist.") + return FileResponse(path) + + +# app = create_app() +# setup_static_files(app, static_files_dir) +def setup_app(static_files_dir: Optional[Path]) -> FastAPI: + """Setup the FastAPI app.""" + # get the directory of the current file + if not static_files_dir: + frontend_path = Path(__file__).parent + static_files_dir = frontend_path / "frontend" + + app = create_app() + setup_static_files(app, static_files_dir) + return app + + app = create_app() From c86f72e7a622828ff6c0ae512ce444c79cf003dc Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 10:11:39 -0300 Subject: [PATCH 40/43] =?UTF-8?q?=F0=9F=8E=89=20feat(config.py):=20add=20C?= =?UTF-8?q?hatConfig=20class=20with=20streaming=20attribute=20set=20to=20T?= =?UTF-8?q?rue=20The=20ChatConfig=20class=20is=20added=20to=20the=20projec?= =?UTF-8?q?t=20with=20a=20single=20attribute,=20streaming,=20set=20to=20Tr?= =?UTF-8?q?ue.=20This=20attribute=20is=20used=20to=20determine=20whether?= =?UTF-8?q?=20the=20chatbot=20should=20use=20streaming=20or=20request-resp?= =?UTF-8?q?onse=20communication=20with=20the=20client.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/chat/config.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/backend/langflow/chat/config.py diff --git a/src/backend/langflow/chat/config.py b/src/backend/langflow/chat/config.py new file mode 100644 index 000000000..274f4d5bd --- /dev/null +++ b/src/backend/langflow/chat/config.py @@ -0,0 +1,2 @@ +class ChatConfig: + streaming: bool = True From 7c6845b15eb101f80f13d6395169dbebe77c5ffb Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 10:16:19 -0300 Subject: [PATCH 41/43] =?UTF-8?q?=F0=9F=94=A7=20chore(loading.py):=20add?= =?UTF-8?q?=20instantiate=5Fllm=20function=20to=20handle=20LLM=20instantia?= =?UTF-8?q?tion=20and=20set=20ChatConfig.streaming=20based=20on=20openai?= =?UTF-8?q?=5Fapi=5Fbase=20parameter=20This=20commit=20adds=20a=20new=20fu?= =?UTF-8?q?nction=20`instantiate=5Fllm`=20to=20handle=20LLM=20(Language=20?= =?UTF-8?q?Model)=20instantiation.=20It=20also=20sets=20the=20`ChatConfig.?= =?UTF-8?q?streaming`=20attribute=20based=20on=20the=20`openai=5Fapi=5Fbas?= =?UTF-8?q?e`=20parameter.=20This=20is=20a=20workaround=20to=20ensure=20th?= =?UTF-8?q?at=20JinaChat=20works=20until=20streaming=20is=20implemented.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/initialize/loading.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index 756588058..cfa5b5717 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -6,6 +6,7 @@ from langchain.agents import agent as agent_module from langchain.agents.agent import AgentExecutor from langchain.agents.agent_toolkits.base import BaseToolkit from langchain.agents.tools import BaseTool + from langflow.interface.initialize.vector_store import vecstore_initializer from pydantic import ValidationError @@ -20,6 +21,7 @@ from langchain.chains.base import Chain from langchain.vectorstores.base import VectorStore from langchain.document_loaders.base import BaseLoader from langchain.prompts.base import BasePromptTemplate +from langflow.chat.config import ChatConfig def instantiate_class(node_type: str, base_type: str, params: Dict) -> Any: @@ -76,10 +78,21 @@ def instantiate_based_on_type(class_object, base_type, node_type, params): return instantiate_utility(node_type, class_object, params) elif base_type == "chains": return instantiate_chains(node_type, class_object, params) + elif base_type == "llms": + return instantiate_llm(node_type, class_object, params) else: return class_object(**params) +def instantiate_llm(node_type, class_object, params: Dict): + # This is a workaround so JinaChat works until streaming is implemented + # if "openai_api_base" in params and "jina" in params["openai_api_base"]: + # False if condition is True + ChatConfig.streaming = "jina" not in params.get("openai_api_base", "") + + return 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() From b741853454370f4dbb4f4de254a4741f4af4c077 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 10:16:41 -0300 Subject: [PATCH 42/43] =?UTF-8?q?=F0=9F=94=A7=20chore(utils.py):=20use=20C?= =?UTF-8?q?hatConfig=20to=20set=20streaming=20option=20The=20first=20chang?= =?UTF-8?q?e=20removes=20an=20extra=20blank=20line=20in=20the=20ChatManage?= =?UTF-8?q?r=20class.=20The=20second=20change=20updates=20the=20try=5Fsett?= =?UTF-8?q?ing=5Fstreaming=5Foptions=20function=20to=20use=20the=20ChatCon?= =?UTF-8?q?fig=20class=20to=20set=20the=20streaming=20option=20instead=20o?= =?UTF-8?q?f=20hardcoding=20it.=20This=20makes=20the=20code=20more=20modul?= =?UTF-8?q?ar=20and=20easier=20to=20maintain.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/chat/manager.py | 2 ++ src/backend/langflow/interface/utils.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/chat/manager.py b/src/backend/langflow/chat/manager.py index 4a1b8e77c..b693e00a3 100644 --- a/src/backend/langflow/chat/manager.py +++ b/src/backend/langflow/chat/manager.py @@ -209,3 +209,5 @@ class ChatManager: except Exception as e: logger.error(e) self.disconnect(client_id) + + diff --git a/src/backend/langflow/interface/utils.py b/src/backend/langflow/interface/utils.py index 8d45aa1b1..ff89e92bf 100644 --- a/src/backend/langflow/interface/utils.py +++ b/src/backend/langflow/interface/utils.py @@ -4,10 +4,12 @@ import os from io import BytesIO import re + import yaml from langchain.base_language import BaseLanguageModel from PIL.Image import Image from langflow.utils.logger import logger +from langflow.chat.config import ChatConfig def load_file_into_dict(file_path: str) -> dict: @@ -49,9 +51,9 @@ def try_setting_streaming_options(langchain_object, websocket): if isinstance(llm, BaseLanguageModel): if hasattr(llm, "streaming") and isinstance(llm.streaming, bool): - llm.streaming = True + llm.streaming = ChatConfig.streaming elif hasattr(llm, "stream") and isinstance(llm.stream, bool): - llm.stream = True + llm.stream = ChatConfig.streaming return langchain_object From 93c3f7a2a6279b696ddec97dd12f8752a2359fe7 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 11:09:26 -0300 Subject: [PATCH 43/43] =?UTF-8?q?=E2=9C=A8=20feat(=5F=5Fmain=5F=5F.py):=20?= =?UTF-8?q?add=20optional=20static=5Ffiles=5Fdir=20parameter=20to=20setup?= =?UTF-8?q?=5Fapp=20function=20The=20variable=20name=20static=5Ffiles=5Fdi?= =?UTF-8?q?r=20was=20changed=20to=20improve=20semantics.=20It=20is=20now?= =?UTF-8?q?=20more=20clear=20that=20it=20is=20a=20directory=20path.=20An?= =?UTF-8?q?=20optional=20static=5Ffiles=5Fdir=20parameter=20was=20added=20?= =?UTF-8?q?to=20the=20setup=5Fapp=20function=20to=20allow=20for=20a=20dire?= =?UTF-8?q?ctory=20path=20to=20be=20passed=20in.=20This=20allows=20for=20m?= =?UTF-8?q?ore=20flexibility=20in=20serving=20static=20files.=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(=5F=5Fmain=5F=5F.py):=20fix=20static=5Ffiles?= =?UTF-8?q?=5Fdir=20variable=20name=20to=20improve=20semantics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 377339c98..9980a5d2f 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -142,8 +142,8 @@ def serve( cache=cache, ) # create path object if path is provided - path = Path(path) if path else path - app = setup_app(static_files_dir=path) + static_files_dir: Optional[Path] = Path(path) if path else None + app = setup_app(static_files_dir=static_files_dir) # check if port is being used if is_port_in_use(port, host): port = get_free_port(port)