From f0c507a6604b87b8fb941f1117f55fca3cab1aec Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 20 Jun 2023 16:14:16 -0300 Subject: [PATCH 001/102] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20inclu?= =?UTF-8?q?de=20"config"=20in=20the=20list=20of=20keys=20to=20check=20for?= =?UTF-8?q?=20*kwargs=20=E2=9C=A8=20feat(constants.py):=20add=20default=20?= =?UTF-8?q?config=20for=20CTransformers=20=F0=9F=9A=80=20feat(llms.py):=20?= =?UTF-8?q?add=20method=20to=20format=20ctransformers=20field=20in=20LLMFr?= =?UTF-8?q?ontendNode=20The=20fix=20in=20loading.py=20ensures=20that=20the?= =?UTF-8?q?=20*kwargs=20are=20converted=20to=20a=20dictionary=20when=20the?= =?UTF-8?q?=20key=20contains=20"config".=20The=20addition=20of=20the=20def?= =?UTF-8?q?ault=20config=20for=20CTransformers=20in=20constants.py=20provi?= =?UTF-8?q?des=20a=20default=20configuration=20for=20the=20CTransformers?= =?UTF-8?q?=20model.=20The=20new=20method=20in=20llms.py=20formats=20the?= =?UTF-8?q?=20ctransformers=20field=20in=20the=20LLMFrontendNode.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/loading.py | 10 ++++++++-- .../template/frontend_node/constants.py | 17 +++++++++++++++++ .../langflow/template/frontend_node/llms.py | 10 ++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/interface/loading.py b/src/backend/langflow/interface/loading.py index a765d3b9b..85ace0b41 100644 --- a/src/backend/langflow/interface/loading.py +++ b/src/backend/langflow/interface/loading.py @@ -53,8 +53,8 @@ def convert_params_to_sets(params): def convert_kwargs(params): # if *kwargs are passed as a string, convert to dict - # first find any key that has kwargs in it - kwargs_keys = [key for key in params.keys() if "kwargs" in key] + # first find any key that has kwargs or config in it + kwargs_keys = [key for key in params.keys() if "kwargs" in key or "config" in key] for key in kwargs_keys: if isinstance(params[key], str): params[key] = json.loads(params[key]) @@ -82,10 +82,16 @@ 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): + return class_object(**params) + + def instantiate_chains(node_type, class_object, params): if "retriever" in params and hasattr(params["retriever"], "as_retriever"): params["retriever"] = params["retriever"].as_retriever() diff --git a/src/backend/langflow/template/frontend_node/constants.py b/src/backend/langflow/template/frontend_node/constants.py index 20b8a0c61..f9894a317 100644 --- a/src/backend/langflow/template/frontend_node/constants.py +++ b/src/backend/langflow/template/frontend_node/constants.py @@ -32,3 +32,20 @@ You are a good listener and you can talk about anything. HUMAN_PROMPT = "{input}" QA_CHAIN_TYPES = ["stuff", "map_reduce", "map_rerank", "refine"] + +CTRANSFORMERS_DEFAULT_CONFIG = { + "top_k": 40, + "top_p": 0.95, + "temperature": 0.8, + "repetition_penalty": 1.1, + "last_n_tokens": 64, + "seed": -1, + "max_new_tokens": 256, + "stop": None, + "stream": False, + "reset": True, + "batch_size": 8, + "threads": -1, + "context_length": -1, + "gpu_layers": 0, +} diff --git a/src/backend/langflow/template/frontend_node/llms.py b/src/backend/langflow/template/frontend_node/llms.py index 272e42c7f..fcd28df6c 100644 --- a/src/backend/langflow/template/frontend_node/llms.py +++ b/src/backend/langflow/template/frontend_node/llms.py @@ -1,7 +1,9 @@ +import json 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 CTRANSFORMERS_DEFAULT_CONFIG class LLMFrontendNode(FrontendNode): @@ -31,6 +33,13 @@ class LLMFrontendNode(FrontendNode): field.show = True field.advanced = not field.required + @staticmethod + def format_ctransformers_field(field: TemplateField): + if field.name == "config": + field.show = True + field.advanced = True + field.value = json.dumps(CTRANSFORMERS_DEFAULT_CONFIG, indent=2) + @staticmethod def format_field(field: TemplateField, name: Optional[str] = None) -> None: display_names_dict = { @@ -38,6 +47,7 @@ class LLMFrontendNode(FrontendNode): } FrontendNode.format_field(field, name) LLMFrontendNode.format_openai_field(field) + LLMFrontendNode.format_ctransformers_field(field) if name and "azure" in name.lower(): LLMFrontendNode.format_azure_field(field) if name and "llama" in name.lower(): From fc2e6c112eb8a6a5390ced06d6bebcae7585af96 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 23 Jun 2023 09:28:25 -0300 Subject: [PATCH 002/102] =?UTF-8?q?=F0=9F=90=9B=20fix(chat.py):=20delete?= =?UTF-8?q?=20flow=20from=20cache=20if=20it=20already=20exists=20before=20?= =?UTF-8?q?initializing=20build=20The=20code=20now=20checks=20if=20the=20f?= =?UTF-8?q?low=20already=20exists=20in=20the=20cache=20and=20deletes=20it?= =?UTF-8?q?=20before=20initializing=20the=20build.=20This=20ensures=20that?= =?UTF-8?q?=20the=20cache=20is=20always=20up=20to=20date=20and=20avoids=20?= =?UTF-8?q?any=20inconsistencies=20that=20may=20arise=20from=20having=20ou?= =?UTF-8?q?tdated=20data=20in=20the=20cache.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/chat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index 262defed6..ae9fb8b30 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -39,6 +39,11 @@ async def init_build(graph_data: dict): try: flow_id = graph_data.get("id") + # Delete from cache if already exists + if flow_id in chat_manager.in_memory_cache: + with chat_manager.in_memory_cache._lock: + chat_manager.in_memory_cache.delete(flow_id) + logger.debug(f"Deleted flow {flow_id} from cache") if flow_id is None: raise ValueError("No ID provided") flow_data_store[flow_id] = graph_data From 8ccdeb9dd541a0da24788f4b1728054300c6cdcb Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 23 Jun 2023 09:54:15 -0300 Subject: [PATCH 003/102] =?UTF-8?q?=F0=9F=90=9B=20fix(chat.py):=20fix=20st?= =?UTF-8?q?ream=5Fbuild=20function=20to=20return=20StreamData=20objects=20?= =?UTF-8?q?instead=20of=20strings=20=E2=9C=A8=20feat(chat.py):=20add=20pro?= =?UTF-8?q?gress=20information=20to=20the=20stream=5Fbuild=20function=20Th?= =?UTF-8?q?e=20stream=5Fbuild=20function=20now=20returns=20StreamData=20ob?= =?UTF-8?q?jects=20instead=20of=20strings,=20which=20improves=20the=20read?= =?UTF-8?q?ability=20of=20the=20code.=20The=20function=20also=20now=20incl?= =?UTF-8?q?udes=20progress=20information=20in=20the=20response,=20which=20?= =?UTF-8?q?allows=20the=20client=20to=20track=20the=20progress=20of=20the?= =?UTF-8?q?=20build=20process.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/chat.py | 65 +++++++++++++++++--------- src/backend/langflow/api/v1/schemas.py | 8 ++++ 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index ae9fb8b30..a730758d2 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -1,4 +1,3 @@ -import json from fastapi import ( APIRouter, HTTPException, @@ -7,7 +6,7 @@ from fastapi import ( status, ) from fastapi.responses import StreamingResponse -from langflow.api.v1.schemas import BuiltResponse, InitResponse +from langflow.api.v1.schemas import BuiltResponse, InitResponse, StreamData from langflow.chat.manager import ChatManager from langflow.graph.graph.base import Graph @@ -39,14 +38,18 @@ async def init_build(graph_data: dict): try: flow_id = graph_data.get("id") + if flow_id is None: + raise ValueError("No ID provided") + # Check if already building + if flow_id in flow_data_store and flow_data_store[flow_id].get("building"): + return InitResponse(flowId=flow_id) + # Delete from cache if already exists if flow_id in chat_manager.in_memory_cache: with chat_manager.in_memory_cache._lock: chat_manager.in_memory_cache.delete(flow_id) logger.debug(f"Deleted flow {flow_id} from cache") - if flow_id is None: - raise ValueError("No ID provided") - flow_data_store[flow_id] = graph_data + flow_data_store[flow_id] = {"graph_data": graph_data, "building": False} return InitResponse(flowId=flow_id) except Exception as exc: @@ -76,26 +79,44 @@ async def stream_build(flow_id: str): """Stream the build process based on stored flow data.""" async def event_stream(flow_id): - final_response = json.dumps({"end_of_stream": True}) + final_response = {"end_of_stream": True} try: if flow_id not in flow_data_store: error_message = "Invalid session ID" - yield f"data: {json.dumps({'error': error_message})}\n\n" + yield str(StreamData(event="error", data={"error": error_message})) + return + + if flow_data_store[flow_id].get("building"): + error_message = "Already building" + yield str(StreamData(event="error", data={"error": error_message})) return graph_data = flow_data_store[flow_id].get("data") if not graph_data: error_message = "No data provided" - yield f"data: {json.dumps({'error': error_message})}\n\n" + yield str(StreamData(event="error", data={"error": error_message})) return logger.debug("Building langchain object") - graph = Graph.from_payload(graph_data) - for node in graph.generator_build(): + try: + # Some error could happen when building the graph + graph = Graph.from_payload(graph_data) + except Exception as exc: + logger.exception(exc) + error_message = str(exc) + yield str(StreamData(event="error", data={"error": error_message})) + return + + number_of_nodes = len(graph.nodes) + for i, vertex in enumerate(graph.generator_build(), 1): try: - node.build() - params = node._built_object_repr() + log_dict = { + "log": f"Building node {vertex.vertex_type}", + } + yield str(StreamData(event="log", data=log_dict)) + vertex.build() + params = vertex._built_object_repr() valid = True logger.debug( f"Building node {params[:50]}{'...' if len(params) > 50 else ''}" @@ -104,21 +125,21 @@ async def stream_build(flow_id: str): params = str(exc) valid = False - response = json.dumps( - { - "valid": valid, - "params": params, - "id": node.id, - } - ) - yield f"data: {response}\n\n" + response = { + "valid": valid, + "params": params, + "id": vertex.id, + "progress": round(i / number_of_nodes, 2), + } + + yield str(StreamData(event="message", data=response)) chat_manager.set_cache(flow_id, graph.build()) except Exception as exc: logger.error("Error while building the flow: %s", exc) - yield f"error: {json.dumps({'error': str(exc)})}\n\n" + yield str(StreamData(event="error", data={"error": str(exc)})) finally: - yield f"data: {final_response}\n\n" + yield str(StreamData(event="message", data=final_response)) try: return StreamingResponse(event_stream(flow_id), media_type="text/event-stream") diff --git a/src/backend/langflow/api/v1/schemas.py b/src/backend/langflow/api/v1/schemas.py index 714f0df7f..263221d75 100644 --- a/src/backend/langflow/api/v1/schemas.py +++ b/src/backend/langflow/api/v1/schemas.py @@ -101,3 +101,11 @@ class InitResponse(BaseModel): class BuiltResponse(BaseModel): built: bool + + +class StreamData(BaseModel): + event: str + data: dict + + def __str__(self) -> str: + return f"event: {self.event}\ndata: {json.dumps(self.data)}\n\n" From 4e01de9e395bff36d2d1ab8834b42ef77a79ee48 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Fri, 23 Jun 2023 19:18:31 -0300 Subject: [PATCH 004/102] =?UTF-8?q?=F0=9F=90=9B=20fix(inputListComponent):?= =?UTF-8?q?=20set=20inputList=20state=20to=20value=20prop=20on=20value=20p?= =?UTF-8?q?rop=20change=20to=20fix=20inputList=20not=20updating=20on=20pro?= =?UTF-8?q?p=20change=20=F0=9F=94=92=20chore(utils.ts):=20add=20random=20n?= =?UTF-8?q?umber=20to=20getRandomKeyByssmm=20function=20to=20reduce=20the?= =?UTF-8?q?=20chance=20of=20key=20collision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/components/inputListComponent/index.tsx | 5 +++++ src/frontend/src/utils.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/inputListComponent/index.tsx b/src/frontend/src/components/inputListComponent/index.tsx index 951d7a7ed..245ea93f0 100644 --- a/src/frontend/src/components/inputListComponent/index.tsx +++ b/src/frontend/src/components/inputListComponent/index.tsx @@ -19,6 +19,11 @@ export default function InputListComponent({ onChange([""]); } }, [disabled, onChange]); + + useEffect(() => { + setInputList(value); + }, [value]); + return (
Date: Fri, 23 Jun 2023 20:15:44 -0300 Subject: [PATCH 005/102] =?UTF-8?q?=F0=9F=90=9B=20fix(inputListComponent):?= =?UTF-8?q?=20fix=20onChange=20event=20not=20being=20triggered=20when=20in?= =?UTF-8?q?put=20value=20changes=20=E2=9C=A8=20feat(inputListComponent):?= =?UTF-8?q?=20add=20PopUpContext=20to=20be=20able=20to=20close=20pop-ups?= =?UTF-8?q?=20when=20input=20value=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/components/inputListComponent/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/inputListComponent/index.tsx b/src/frontend/src/components/inputListComponent/index.tsx index 245ea93f0..f50626e15 100644 --- a/src/frontend/src/components/inputListComponent/index.tsx +++ b/src/frontend/src/components/inputListComponent/index.tsx @@ -5,6 +5,7 @@ import { TabsContext } from "../../contexts/tabsContext"; import _ from "lodash"; import { INPUT_STYLE } from "../../constants"; import { X, Plus } from "lucide-react"; +import { PopUpContext } from "../../contexts/popUpContext"; export default function InputListComponent({ value, @@ -13,6 +14,8 @@ export default function InputListComponent({ editNode = false, }: InputListComponentType) { const [inputList, setInputList] = useState(value ?? [""]); + const { closePopUp } = useContext(PopUpContext); + useEffect(() => { if (disabled) { setInputList([""]); @@ -22,8 +25,10 @@ export default function InputListComponent({ useEffect(() => { setInputList(value); - }, [value]); + }, [closePopUp]); + + return (
{ let newInputList = _.cloneDeep(old); newInputList[idx] = e.target.value; + onChange(newInputList); return newInputList; }); - onChange(inputList); }} /> {idx === inputList.length - 1 ? ( From 94cc554834363281f0e83052c6ac1c1a391f0bb5 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Sat, 24 Jun 2023 11:03:36 -0300 Subject: [PATCH 006/102] =?UTF-8?q?=F0=9F=90=9B=20fix(dropdownComponent):?= =?UTF-8?q?=20add=20missing=20context=20imports=20and=20dependencies=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(floatComponent):=20add=20missing=20context?= =?UTF-8?q?=20imports=20and=20dependencies=20=F0=9F=90=9B=20fix(intCompone?= =?UTF-8?q?nt):=20add=20missing=20context=20imports=20and=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/dropdownComponent/index.tsx | 12 ++++++++++-- src/frontend/src/components/floatComponent/index.tsx | 5 ++++- src/frontend/src/components/intComponent/index.tsx | 5 ++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/components/dropdownComponent/index.tsx b/src/frontend/src/components/dropdownComponent/index.tsx index 522078629..605a24041 100644 --- a/src/frontend/src/components/dropdownComponent/index.tsx +++ b/src/frontend/src/components/dropdownComponent/index.tsx @@ -1,9 +1,11 @@ import { Listbox, Transition } from "@headlessui/react"; -import { Fragment, useEffect, useState } from "react"; +import { Fragment, useContext, useEffect, useState } from "react"; import { DropDownComponentType } from "../../types/components"; import { classNames } from "../../utils"; import { INPUT_STYLE } from "../../constants"; import { ChevronsUpDown, Check } from "lucide-react"; +import { PopUpContext } from "../../contexts/popUpContext"; +import { TabsContext } from "../../contexts/tabsContext"; export default function Dropdown({ value, @@ -12,12 +14,16 @@ export default function Dropdown({ editNode = false, numberOfOptions = 0, }: DropDownComponentType) { + const { closePopUp } = useContext(PopUpContext); + + let [internalValue, setInternalValue] = useState( value === "" || !value ? "Choose an option" : value ); + useEffect(() => { setInternalValue(value === "" || !value ? "Choose an option" : value); - }, [value]); + }, [closePopUp]); return ( <> @@ -81,7 +87,9 @@ export default function Dropdown({ ) } value={option} + > + {({ selected, active }) => ( <> { setMyValue(value); - }, [value]); + }, [closePopUp]); + return (
{ if (disabled) { @@ -24,7 +26,8 @@ export default function IntComponent({ useEffect(() => { setMyValue(value); - }, [value]); + }, [closePopUp]); + return (
Date: Sat, 24 Jun 2023 16:31:39 -0300 Subject: [PATCH 007/102] 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 008/102] =?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 009/102] =?UTF-8?q?=F0=9F=93=9D=20docs(frontend=5Fnode):?= =?UTF-8?q?=20add=20set=5Fdocumentation=20method=20to=20set=20the=20docume?= =?UTF-8?q?ntation=20of=20the=20frontend=20node=20=E2=9C=A8=20feat(fronten?= =?UTF-8?q?d=5Fnode):=20add=20documentation=20field=20to=20the=20frontend?= =?UTF-8?q?=20node=20dict=20representation=20The=20`set=5Fdocumentation`?= =?UTF-8?q?=20method=20is=20added=20to=20the=20`FrontendNode`=20class=20to?= =?UTF-8?q?=20allow=20setting=20the=20documentation=20of=20the=20frontend?= =?UTF-8?q?=20node.=20The=20`to=5Fdict`=20method=20is=20updated=20to=20inc?= =?UTF-8?q?lude=20the=20`documentation`=20field=20in=20the=20dict=20repres?= =?UTF-8?q?entation=20of=20the=20frontend=20node.=20This=20improves=20the?= =?UTF-8?q?=20readability=20and=20usability=20of=20the=20frontend=20node?= =?UTF-8?q?=20by=20providing=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 010/102] =?UTF-8?q?=F0=9F=8E=A8=20style(GenericNode/index.?= =?UTF-8?q?tsx):=20remove=20unused=20imports=20and=20add=20documentation?= =?UTF-8?q?=20link=20to=20node=20toolbar=20=F0=9F=9A=80=20feat(api/index.t?= =?UTF-8?q?s):=20add=20documentation=20field=20to=20APIClassType=20The=20u?= =?UTF-8?q?nused=20imports=20were=20removed=20to=20improve=20code=20readab?= =?UTF-8?q?ility.=20A=20documentation=20link=20was=20added=20to=20the=20no?= =?UTF-8?q?de=20toolbar=20to=20allow=20users=20to=20easily=20access=20the?= =?UTF-8?q?=20documentation=20for=20the=20node.=20The=20documentation=20fi?= =?UTF-8?q?eld=20was=20added=20to=20the=20APIClassType=20to=20allow=20for?= =?UTF-8?q?=20the=20storage=20of=20a=20link=20to=20the=20documentation=20f?= =?UTF-8?q?or=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 011/102] =?UTF-8?q?=F0=9F=94=A8=20refactor(tabsContext.tsx?= =?UTF-8?q?):=20improve=20code=20readability=20by=20adding=20whitespace=20?= =?UTF-8?q?and=20consistent=20formatting=20The=20code=20has=20been=20refac?= =?UTF-8?q?tored=20to=20improve=20readability=20by=20adding=20whitespace?= =?UTF-8?q?=20and=20consistent=20formatting.=20The=20function=20names=20ha?= =?UTF-8?q?ve=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 012/102] =?UTF-8?q?=F0=9F=90=9B=20fix(GenericNode):=20add?= =?UTF-8?q?=20conditional=20rendering=20to=20documentation=20link=20to=20p?= =?UTF-8?q?revent=20empty=20href=20The=20documentation=20link=20was=20prev?= =?UTF-8?q?iously=20always=20rendered,=20even=20if=20the=20href=20was=20em?= =?UTF-8?q?pty.=20This=20caused=20an=20issue=20where=20the=20link=20would?= =?UTF-8?q?=20be=20clickable=20but=20lead=20to=20nowhere.=20The=20fix=20ad?= =?UTF-8?q?ds=20a=20conditional=20rendering=20to=20the=20link,=20so=20it?= =?UTF-8?q?=20is=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 013/102] =?UTF-8?q?=F0=9F=90=9B=20fix(settings.py):=20chan?= =?UTF-8?q?ge=20default=20values=20of=20settings=20attributes=20from=20lis?= =?UTF-8?q?t=20to=20dictionary=20The=20default=20values=20of=20the=20setti?= =?UTF-8?q?ngs=20attributes=20were=20changed=20from=20an=20empty=20list=20?= =?UTF-8?q?to=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 014/102] =?UTF-8?q?=F0=9F=94=A5=20chore(test=5Fprompts=5Ft?= =?UTF-8?q?emplate.py):=20remove=20unused=20test=5Ffew=5Fshot=5Fprompt=5Ft?= =?UTF-8?q?emplate=20function=20The=20test=5Ffew=5Fshot=5Fprompt=5Ftemplat?= =?UTF-8?q?e=20function=20is=20not=20being=20used=20and=20is=20not=20neces?= =?UTF-8?q?sary=20for=20the=20tests.=20Removing=20it=20will=20make=20the?= =?UTF-8?q?=20code=20cleaner=20and=20easier=20to=20maintain.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_prompts_template.py | 79 ---------------------------------- 1 file changed, 79 deletions(-) diff --git a/tests/test_prompts_template.py b/tests/test_prompts_template.py index a8562898c..5094f50f0 100644 --- a/tests/test_prompts_template.py +++ b/tests/test_prompts_template.py @@ -88,85 +88,6 @@ def test_prompt_template(client: TestClient): } -def test_few_shot_prompt_template(client: TestClient): - response = client.get("api/v1/all") - assert response.status_code == 200 - json_response = response.json() - prompts = json_response["prompts"] - - prompt = prompts["FewShotPromptTemplate"] - template = prompt["template"] - # Test other fields in the template similar to PromptTemplate - assert template["examples"] == { - "required": False, - "placeholder": "", - "show": True, - "multiline": True, - "password": False, - "name": "examples", - "type": "prompt", - "list": True, - "advanced": False, - } - assert template["example_selector"] == { - "required": False, - "placeholder": "", - "show": False, - "multiline": False, - "password": False, - "name": "example_selector", - "type": "BaseExampleSelector", - "list": False, - "advanced": False, - } - assert template["example_prompt"] == { - "required": True, - "placeholder": "", - "show": True, - "multiline": False, - "password": False, - "name": "example_prompt", - "type": "PromptTemplate", - "list": False, - "advanced": False, - } - assert template["suffix"] == { - "required": True, - "placeholder": "", - "show": True, - "multiline": True, - "password": False, - "name": "suffix", - "type": "prompt", - "list": False, - "advanced": False, - } - assert template["example_separator"] == { - "required": False, - "placeholder": "", - "show": False, - "multiline": False, - "value": "\n\n", - "password": False, - "name": "example_separator", - "type": "str", - "list": False, - "advanced": False, - } - assert template["prefix"] == { - "required": False, - "placeholder": "", - "show": True, - "multiline": True, - "value": "", - "password": False, - "name": "prefix", - "type": "prompt", - "list": False, - "advanced": False, - } - - def test_zero_shot_prompt(client: TestClient): response = client.get("api/v1/all") assert response.status_code == 200 From d523b7f8b07194a81a832f174a77ccb21b488182 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 09:26:13 -0300 Subject: [PATCH 015/102] 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 016/102] =?UTF-8?q?=F0=9F=93=9D=20docs(config.yaml):=20add?= =?UTF-8?q?=20documentation=20links=20for=20LlamaCpp=20and=20CTransformers?= =?UTF-8?q?=20integrations=20This=20commit=20adds=20documentation=20links?= =?UTF-8?q?=20for=20the=20LlamaCpp=20and=20CTransformers=20integrations=20?= =?UTF-8?q?in=20the=20config.yaml=20file.=20The=20links=20point=20to=20the?= =?UTF-8?q?=20relevant=20documentation=20pages=20on=20the=20LangChain=20we?= =?UTF-8?q?bsite.=20This=20improves=20the=20accessibility=20of=20the=20doc?= =?UTF-8?q?umentation=20for=20these=20integrations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index 0abeb7a7e..0077b4ba1 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -108,9 +108,9 @@ llms: ChatOpenAI: documentation: "" LlamaCpp: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/llamacpp" CTransformers: - documentation: "" + documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/ctransformers" Cohere: documentation: "" Anthropic: From a45947c01beb0da9c91e410e4122ca0882bca30b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:37:05 -0300 Subject: [PATCH 017/102] =?UTF-8?q?=F0=9F=9A=80=20feat(vectorstores.py):?= =?UTF-8?q?=20add=20VectorStoreRetriever=20as=20an=20extra=20base=20class?= =?UTF-8?q?=20to=20VectorStoreFrontendNode=20The=20VectorStoreFrontendNode?= =?UTF-8?q?=20class=20now=20has=20VectorStoreRetriever=20as=20an=20extra?= =?UTF-8?q?=20base=20class=20in=20addition=20to=20BaseRetriever.=20This=20?= =?UTF-8?q?change=20was=20made=20to=20improve=20the=20functionality=20of?= =?UTF-8?q?=20the=20class=20by=20allowing=20it=20to=20inherit=20from=20Vec?= =?UTF-8?q?torStoreRetriever.?= 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 018/102] =?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 019/102] =?UTF-8?q?=F0=9F=94=A8=20refactor(loading.py):=20?= =?UTF-8?q?add=20type=20hints=20to=20function=20parameters=20and=20return?= =?UTF-8?q?=20types=20This=20commit=20adds=20type=20hints=20to=20the=20fun?= =?UTF-8?q?ction=20parameters=20and=20return=20types=20in=20the=20loading.?= =?UTF-8?q?py=20file.=20This=20improves=20the=20readability=20and=20mainta?= =?UTF-8?q?inability=20of=20the=20codebase=20by=20making=20it=20easier=20t?= =?UTF-8?q?o=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 020/102] =?UTF-8?q?=F0=9F=9A=80=20feat(textsplitters.py):?= =?UTF-8?q?=20add=20a=20field=20for=20separator=20type=20in=20RecursiveCha?= =?UTF-8?q?racterTextSplitter=20The=20RecursiveCharacterTextSplitter=20cla?= =?UTF-8?q?ss=20in=20textsplitters.py=20now=20has=20a=20new=20field=20call?= =?UTF-8?q?ed=20separator=5Ftype.=20This=20field=20is=20used=20to=20specif?= =?UTF-8?q?y=20the=20type=20of=20separator=20to=20be=20used=20in=20the=20s?= =?UTF-8?q?plitter.=20The=20separator=5Ftype=20field=20is=20a=20string=20a?= =?UTF-8?q?nd=20can=20take=20any=20value=20from=20the=20Language=20enum=20?= =?UTF-8?q?or=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 021/102] =?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 022/102] =?UTF-8?q?=F0=9F=94=A8=20refactor(loading.py):=20?= =?UTF-8?q?add=20type=20hinting=20to=20instantiate=5Fagent=20function=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20fix=20type=20hinting=20in=20i?= =?UTF-8?q?nstantiate=5Fembedding=20function=20=F0=9F=94=A8=20refactor(loa?= =?UTF-8?q?ding.py):=20add=20type=20hinting=20to=20instantiate=5Ftextsplit?= =?UTF-8?q?ter=20function=20The=20changes=20in=20this=20commit=20add=20typ?= =?UTF-8?q?e=20hinting=20to=20the=20`instantiate=5Fagent`,=20`instantiate?= =?UTF-8?q?=5Fembedding`,=20and=20`instantiate=5Ftextsplitter`=20functions?= =?UTF-8?q?=20to=20improve=20code=20readability=20and=20maintainability.?= =?UTF-8?q?=20The=20`instantiate=5Fembedding`=20function=20had=20a=20bug?= =?UTF-8?q?=20in=20its=20type=20hinting=20which=20has=20been=20fixed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/initialize/loading.py | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index 4acc21383..a928ea586 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -16,11 +16,10 @@ from langflow.interface.toolkits.base import toolkits_creator from langflow.interface.chains.base import chain_creator from langflow.interface.utils import load_file_into_dict from langflow.utils import validate -from langchain.text_splitter import TextSplitter +from langchain.text_splitter import TextSplitter, RecursiveCharacterTextSplitter from langchain.chains.base import Chain from langchain.vectorstores.base import VectorStore from langchain.document_loaders.base import BaseLoader -from langchain.embeddings.base import Embeddings from langchain.prompts.base import BasePromptTemplate @@ -94,7 +93,7 @@ def instantiate_chains(node_type, class_object: Type[Chain], params: Dict): return class_object(**params) -def instantiate_agent(class_object: Type[Chain], params: Dict): +def instantiate_agent(class_object: Type[agent_module.Agent], params: Dict): return load_agent_executor(class_object, params) @@ -134,7 +133,7 @@ def instantiate_toolkit(node_type, class_object: Type[BaseToolkit], params: Dict return loaded_toolkit -def instantiate_embedding(class_object: Type[Embeddings], params: Dict): +def instantiate_embedding(class_object, params: Dict): params.pop("model", None) params.pop("headers", None) try: @@ -193,20 +192,25 @@ def instantiate_documentloader(class_object: Type[BaseLoader], params: Dict): return docs -def instantiate_textsplitter(class_object: Type[TextSplitter], params: Dict): +def instantiate_textsplitter( + class_object: Type[TextSplitter], + params: Dict, +): try: documents = params.pop("documents") - except KeyError as e: + except KeyError as exc: raise ValueError( "The source you provided did not load correctly or was empty." "Try changing the chunk_size of the Text Splitter." - ) from e - if "separator_type" in params and params["separator_type"] == "Text": - text_splitter = class_object(**params) - else: - params["language"] = params.pop("separator_type", None) - params.pop("separators", None) - text_splitter = class_object.from_language(**params) + ) from exc + + if type(class_object) == RecursiveCharacterTextSplitter: + if "separator_type" in params and params["separator_type"] == "Text": + text_splitter = class_object(**params) + else: + params["language"] = params.pop("separator_type", None) + params.pop("separators", None) + text_splitter = class_object.from_language(**params) return text_splitter.split_documents(documents) From 7d415e62df66ddeea0d86833cc02486a9166ec88 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 21:32:48 -0300 Subject: [PATCH 023/102] =?UTF-8?q?=F0=9F=8E=A8=20style(GenericNode):=20re?= =?UTF-8?q?factor=20tooltip=20to=20improve=20accessibility=20and=20user=20?= =?UTF-8?q?experience=20The=20tooltip=20now=20includes=20a=20link=20to=20t?= =?UTF-8?q?he=20documentation=20of=20the=20node,=20which=20makes=20it=20mo?= =?UTF-8?q?re=20accessible=20and=20user-friendly.=20The=20link=20is=20now?= =?UTF-8?q?=20wrapped=20in=20the=20tooltip=20title,=20which=20improves=20t?= =?UTF-8?q?he=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 024/102] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20use?= =?UTF-8?q?=20'is'=20instead=20of=20'=3D=3D'=20to=20compare=20object=20typ?= =?UTF-8?q?es=20The=20commit=20changes=20the=20comparison=20operator=20fro?= =?UTF-8?q?m=20'=3D=3D'=20to=20'is'=20to=20compare=20object=20types.=20Thi?= =?UTF-8?q?s=20is=20because=20'is'=20compares=20the=20object=20identity=20?= =?UTF-8?q?while=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 025/102] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20fix?= =?UTF-8?q?=20instantiation=20of=20TextSplitter=20by=20removing=20unnecess?= =?UTF-8?q?ary=20check=20for=20RecursiveCharacterTextSplitter=20The=20impo?= =?UTF-8?q?rt=20of=20RecursiveCharacterTextSplitter=20was=20removed=20as?= =?UTF-8?q?=20it=20was=20not=20being=20used=20in=20the=20code.=20The=20ins?= =?UTF-8?q?tantiation=20of=20TextSplitter=20was=20fixed=20by=20removing=20?= =?UTF-8?q?the=20unnecessary=20check=20for=20RecursiveCharacterTextSplitte?= =?UTF-8?q?r=20and=20simplifying=20the=20code.=20=F0=9F=94=A5=20refactor(l?= =?UTF-8?q?oading.py):=20remove=20unused=20import=20of=20RecursiveCharacte?= =?UTF-8?q?rTextSplitter?= 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 fcedf0807392344f30c47aef0aebb865878db741 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 26 Jun 2023 17:11:47 -0300 Subject: [PATCH 026/102] =?UTF-8?q?=F0=9F=94=A7=20refactor(frontend):=20re?= =?UTF-8?q?move=20unnecessary=20blank=20lines=20in=20multiple=20components?= =?UTF-8?q?=20=F0=9F=94=A7=20refactor(tabsContext.tsx):=20add=20missing=20?= =?UTF-8?q?type=20annotations=20and=20improve=20code=20readability=20?= =?UTF-8?q?=F0=9F=94=A7=20refactor(ApiModal):=20improve=20code=20readabili?= =?UTF-8?q?ty=20by=20adding=20a=20new=20line=20to=20a=20JSX=20element=20?= =?UTF-8?q?=F0=9F=94=A7=20refactor(EditNodeModal):=20remove=20unnecessary?= =?UTF-8?q?=20blank=20line=20in=20a=20JSX=20element?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/package-lock.json | 39 ++++++++++--------- .../components/dropdownComponent/index.tsx | 3 -- .../src/components/floatComponent/index.tsx | 1 - .../components/inputListComponent/index.tsx | 2 - .../src/components/intComponent/index.tsx | 1 - src/frontend/src/contexts/tabsContext.tsx | 28 +++++++------ src/frontend/src/modals/ApiModal/index.tsx | 4 +- .../src/modals/EditNodeModal/index.tsx | 2 +- 8 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json index 673f56f10..0edd88d0d 100644 --- a/src/frontend/package-lock.json +++ b/src/frontend/package-lock.json @@ -1212,15 +1212,15 @@ "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, "node_modules/@mui/system": { - "version": "5.13.5", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.13.5.tgz", - "integrity": "sha512-n0gzUxoZ2ZHZgnExkh2Htvo9uW2oakofgPRQrDoa/GQOWyRD0NH9MDszBwOb6AAoXZb+OV5TE7I4LeZ/dzgHYA==", + "version": "5.13.6", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.13.6.tgz", + "integrity": "sha512-G3Xr28uLqU3DyF6r2LQkHGw/ku4P0AHzlKVe7FGXOPl7X1u+hoe2xxj8Vdiq/69II/mh9OP21i38yBWgWb7WgQ==", "dependencies": { - "@babel/runtime": "^7.21.0", + "@babel/runtime": "^7.22.5", "@mui/private-theming": "^5.13.1", "@mui/styled-engine": "^5.13.2", "@mui/types": "^7.2.4", - "@mui/utils": "^5.13.1", + "@mui/utils": "^5.13.6", "clsx": "^1.2.1", "csstype": "^3.1.2", "prop-types": "^15.8.1" @@ -1280,11 +1280,11 @@ } }, "node_modules/@mui/utils": { - "version": "5.13.1", - "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.13.1.tgz", - "integrity": "sha512-6lXdWwmlUbEU2jUI8blw38Kt+3ly7xkmV9ljzY4Q20WhsJMWiNry9CX8M+TaP/HbtuyR8XKsdMgQW7h7MM3n3A==", + "version": "5.13.6", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.13.6.tgz", + "integrity": "sha512-ggNlxl5NPSbp+kNcQLmSig6WVB0Id+4gOxhx644987v4fsji+CSXc+MFYLocFB/x4oHtzCUlSzbVHlJfP/fXoQ==", "dependencies": { - "@babel/runtime": "^7.21.0", + "@babel/runtime": "^7.22.5", "@types/prop-types": "^15.7.5", "@types/react-is": "^18.2.0", "prop-types": "^15.8.1", @@ -3444,7 +3444,7 @@ "version": "16.18.12", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.12.tgz", "integrity": "sha512-vzLe5NaNMjIE3mcddFVGlAXN1LEWueUsMsOJWaT6wWMJGyljHAWHznqfnKUQWGzu7TLPrGvWdNAsvQYW+C0xtw==", - "devOptional": true + "dev": true }, "node_modules/@types/parse-json": { "version": "4.0.0", @@ -3714,9 +3714,9 @@ } }, "node_modules/aria-query": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.2.1.tgz", - "integrity": "sha512-7uFg4b+lETFgdaJyETnILsXgnnzVnkHcgRbwbPwevm5x/LmUlt3MjczMRe1zg824iBgXZNRPTBftNYyRSKLp2g==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", "dev": true, "dependencies": { "dequal": "^2.0.3" @@ -5010,9 +5010,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.438", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.438.tgz", - "integrity": "sha512-x94U0FhphEsHsOloCvlsujHCvoir0ZQ73ZAs/QN4PLx98uNvyEU79F75rq1db75Bx/atvuh7KPeuxelh+xfYJw==" + "version": "1.4.440", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.440.tgz", + "integrity": "sha512-r6dCgNpRhPwiWlxbHzZQ/d9swfPaEJGi8ekqRBwQYaR3WmA5VkqQfBWSDDjuJU1ntO+W9tHx8OHV/96Q8e0dVw==" }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -5504,6 +5504,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -6745,9 +6746,9 @@ } }, "node_modules/katex": { - "version": "0.16.7", - "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.7.tgz", - "integrity": "sha512-Xk9C6oGKRwJTfqfIbtr0Kes9OSv6IFsuhFGc7tW4urlpMJtuh+7YhzU6YEG9n8gmWKcMAFzkp7nr+r69kV0zrA==", + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.8.tgz", + "integrity": "sha512-ftuDnJbcbOckGY11OO+zg3OofESlbR5DRl2cmN8HeWeeFIV7wTXvAOx8kEjZjobhA+9wh2fbKeO6cdcA9Mnovg==", "funding": [ "https://opencollective.com/katex", "https://github.com/sponsors/katex" diff --git a/src/frontend/src/components/dropdownComponent/index.tsx b/src/frontend/src/components/dropdownComponent/index.tsx index 605a24041..e252e1b21 100644 --- a/src/frontend/src/components/dropdownComponent/index.tsx +++ b/src/frontend/src/components/dropdownComponent/index.tsx @@ -16,7 +16,6 @@ export default function Dropdown({ }: DropDownComponentType) { const { closePopUp } = useContext(PopUpContext); - let [internalValue, setInternalValue] = useState( value === "" || !value ? "Choose an option" : value ); @@ -87,9 +86,7 @@ export default function Dropdown({ ) } value={option} - > - {({ selected, active }) => ( <> { setInputList(value); }, [closePopUp]); - - return (
{ 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"] + ? template["display_name"] + : node.data.type; } 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); @@ -220,11 +222,15 @@ export function TabsProvider({ children }: { children: ReactNode }) { }); } - 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 +242,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 @@ -404,7 +410,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { y: insidePosition.y + n.position.y - minimumY, }, data: { - ...n.data, + ..._.cloneDeep(n.data), id: newId, }, }; diff --git a/src/frontend/src/modals/ApiModal/index.tsx b/src/frontend/src/modals/ApiModal/index.tsx index 8b373c4e2..d6fff5d9f 100644 --- a/src/frontend/src/modals/ApiModal/index.tsx +++ b/src/frontend/src/modals/ApiModal/index.tsx @@ -103,7 +103,9 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
{tabs.map((tab, index) => ( - {tab.name} + + {tab.name} + ))}
diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index fa7563bfb..e2f9c7bca 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -79,7 +79,7 @@ export default function EditNodeModal({ data }: { data: NodeDataType }) { } return ( - + From 47fcdaef419d31956e56ea38b5b1013cb633f08d Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 26 Jun 2023 18:29:27 -0300 Subject: [PATCH 027/102] =?UTF-8?q?=F0=9F=8E=A8=20style(GenericNode/index.?= =?UTF-8?q?tsx):=20refactor=20GenericNode=20component=20to=20use=20a=20mor?= =?UTF-8?q?e=20readable=20and=20maintainable=20code=20structure=20?= =?UTF-8?q?=E2=9C=A8=20feat(GenericNode/index.tsx):=20add=20documentation?= =?UTF-8?q?=20link=20to=20GenericNode=20component=20and=20display=20it=20a?= =?UTF-8?q?s=20a=20tooltip=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 028/102] =?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 029/102] =?UTF-8?q?=F0=9F=94=A8=20refactor(components):=20?= =?UTF-8?q?add=20info=20property=20to=20ParameterComponentType=20The=20Par?= =?UTF-8?q?ameterComponent=20now=20has=20an=20info=20icon=20and=20tooltip?= =?UTF-8?q?=20to=20show=20additional=20information=20about=20the=20paramet?= =?UTF-8?q?er.=20The=20GenericNode=20component=20now=20passes=20the=20info?= =?UTF-8?q?=20prop=20to=20the=20ParameterComponent=20to=20show=20the=20add?= =?UTF-8?q?itional=20information.=20The=20ParameterComponentType=20has=20b?= =?UTF-8?q?een=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 030/102] =?UTF-8?q?=F0=9F=94=A7=20chore(base.py,=20constan?= =?UTF-8?q?ts.py,=20llms.py):=20add=20info=20field=20to=20TemplateField=20?= =?UTF-8?q?and=20OPENAI=5FAPI=5FBASE=5FINFO=20constant=20The=20`info`=20fi?= =?UTF-8?q?eld=20is=20added=20to=20the=20`TemplateField`=20class=20to=20pr?= =?UTF-8?q?ovide=20additional=20information=20about=20the=20field.=20The?= =?UTF-8?q?=20`OPENAI=5FAPI=5FBASE=5FINFO`=20constant=20is=20added=20to=20?= =?UTF-8?q?the=20`constants.py`=20file=20to=20provide=20information=20abou?= =?UTF-8?q?t=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 031/102] =?UTF-8?q?=F0=9F=93=9D=20docs(constants.py):=20up?= =?UTF-8?q?date=20OpenAI=20API=20base=20info=20to=20include=20additional?= =?UTF-8?q?=20API=20options=20This=20commit=20updates=20the=20documentatio?= =?UTF-8?q?n=20in=20the=20constants.py=20file=20to=20include=20additional?= =?UTF-8?q?=20API=20options=20that=20can=20be=20used=20instead=20of=20the?= =?UTF-8?q?=20default=20OpenAI=20API.=20The=20new=20options=20are=20JinaCh?= =?UTF-8?q?at,=20LocalAI,=20and=20Prem.=20This=20change=20provides=20more?= =?UTF-8?q?=20information=20to=20the=20user=20and=20allows=20them=20to=20m?= =?UTF-8?q?ake=20an=20informed=20decision=20when=20choosing=20an=20API=20t?= =?UTF-8?q?o=20use.?= 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 032/102] =?UTF-8?q?=F0=9F=94=A7=20refactor(=5F=5Fmain=5F?= =?UTF-8?q?=5F.py,=20main.py):=20move=20setup=5Fstatic=5Ffiles=20function?= =?UTF-8?q?=20to=20main.py=20and=20rename=20create=5Fapp=20to=20setup=5Fap?= =?UTF-8?q?p=20=E2=9C=A8=20feat(=5F=5Fmain=5F=5F.py,=20main.py):=20add=20s?= =?UTF-8?q?upport=20for=20a=20custom=20static=20files=20directory=20to=20b?= =?UTF-8?q?e=20passed=20as=20an=20argument=20to=20the=20app=20The=20`setup?= =?UTF-8?q?=5Fstatic=5Ffiles`=20function=20has=20been=20moved=20from=20`?= =?UTF-8?q?=5F=5Fmain=5F=5F.py`=20to=20`main.py`=20to=20improve=20code=20o?= =?UTF-8?q?rganization.=20The=20function=20has=20also=20been=20renamed=20t?= =?UTF-8?q?o=20`setup=5Fapp`=20to=20better=20reflect=20its=20purpose.=20Th?= =?UTF-8?q?e=20`create=5Fapp`=20function=20has=20been=20renamed=20to=20`se?= =?UTF-8?q?tup=5Fapp`=20to=20follow=20the=20naming=20convention=20of=20the?= =?UTF-8?q?=20new=20function.=20The=20`setup=5Fapp`=20function=20now=20acc?= =?UTF-8?q?epts=20an=20optional=20argument=20`static=5Ffiles=5Fdir`=20whic?= =?UTF-8?q?h=20allows=20the=20user=20to=20specify=20a=20custom=20directory?= =?UTF-8?q?=20for=20static=20files.=20This=20improves=20the=20flexibility?= =?UTF-8?q?=20of=20the=20app=20as=20it=20can=20now=20be=20run=20with=20a?= =?UTF-8?q?=20custom=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 033/102] =?UTF-8?q?=F0=9F=8E=89=20feat(config.py):=20add?= =?UTF-8?q?=20ChatConfig=20class=20with=20streaming=20attribute=20set=20to?= =?UTF-8?q?=20True=20The=20ChatConfig=20class=20is=20added=20to=20the=20pr?= =?UTF-8?q?oject=20with=20a=20single=20attribute,=20streaming,=20set=20to?= =?UTF-8?q?=20True.=20This=20attribute=20is=20used=20to=20determine=20whet?= =?UTF-8?q?her=20the=20chatbot=20should=20use=20streaming=20or=20request-r?= =?UTF-8?q?esponse=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 034/102] =?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 035/102] =?UTF-8?q?=F0=9F=94=A7=20chore(utils.py):=20use?= =?UTF-8?q?=20ChatConfig=20to=20set=20streaming=20option=20The=20first=20c?= =?UTF-8?q?hange=20removes=20an=20extra=20blank=20line=20in=20the=20ChatMa?= =?UTF-8?q?nager=20class.=20The=20second=20change=20updates=20the=20try=5F?= =?UTF-8?q?setting=5Fstreaming=5Foptions=20function=20to=20use=20the=20Cha?= =?UTF-8?q?tConfig=20class=20to=20set=20the=20streaming=20option=20instead?= =?UTF-8?q?=20of=20hardcoding=20it.=20This=20makes=20the=20code=20more=20m?= =?UTF-8?q?odular=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 036/102] =?UTF-8?q?=E2=9C=A8=20feat(=5F=5Fmain=5F=5F.py):?= =?UTF-8?q?=20add=20optional=20static=5Ffiles=5Fdir=20parameter=20to=20set?= =?UTF-8?q?up=5Fapp=20function=20The=20variable=20name=20static=5Ffiles=5F?= =?UTF-8?q?dir=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) From 23cf37eee5f910a783754bed9cf1eb0f3dc6b7a8 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 13:21:40 -0300 Subject: [PATCH 037/102] =?UTF-8?q?=F0=9F=94=96=20chore(pyproject.toml):?= =?UTF-8?q?=20update=20package=20version=20to=200.2.3=20=F0=9F=94=A5=20ref?= =?UTF-8?q?actor(manager.py):=20remove=20unnecessary=20blank=20line=20at?= =?UTF-8?q?=20the=20end=20of=20the=20file=20The=20package=20version=20has?= =?UTF-8?q?=20been=20updated=20to=200.2.3=20in=20the=20pyproject.toml=20fi?= =?UTF-8?q?le.=20This=20is=20a=20chore=20as=20it=20does=20not=20affect=20t?= =?UTF-8?q?he=20functionality=20of=20the=20package.=20The=20blank=20line?= =?UTF-8?q?=20at=20the=20end=20of=20the=20manager.py=20file=20has=20been?= =?UTF-8?q?=20removed=20as=20it=20is=20unnecessary=20and=20does=20not=20ad?= =?UTF-8?q?d=20any=20value=20to=20the=20code.=20This=20is=20a=20refactor?= =?UTF-8?q?=20as=20it=20improves=20the=20code=20readability.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 12 ++++++------ pyproject.toml | 2 +- src/backend/langflow/chat/manager.py | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/poetry.lock b/poetry.lock index b13392910..b854f5c2e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1565,14 +1565,14 @@ uritemplate = ">=3.0.1,<5" [[package]] name = "google-auth" -version = "2.20.0" +version = "2.21.0" description = "Google Authentication Library" category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "google-auth-2.20.0.tar.gz", hash = "sha256:030af34138909ccde0fbce611afc178f1d65d32fbff281f25738b1fe1c6f3eaa"}, - {file = "google_auth-2.20.0-py2.py3-none-any.whl", hash = "sha256:23b7b0950fcda519bfb6692bf0d5289d2ea49fc143717cc7188458ec620e63fa"}, + {file = "google-auth-2.21.0.tar.gz", hash = "sha256:b28e8048e57727e7cf0e5bd8e7276b212aef476654a09511354aa82753b45c66"}, + {file = "google_auth-2.21.0-py2.py3-none-any.whl", hash = "sha256:da3f18d074fa0f5a7061d99b9af8cee3aa6189c987af7c1b07d94566b6b11268"}, ] [package.dependencies] @@ -4977,14 +4977,14 @@ files = [ [[package]] name = "pywin32-ctypes" -version = "0.2.1" +version = "0.2.2" description = "A (partial) reimplementation of pywin32 using ctypes/cffi" category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "pywin32-ctypes-0.2.1.tar.gz", hash = "sha256:934a2def1e5cbc472b2b6bf80680c0f03cd87df65dfd58bfd1846969de095b03"}, - {file = "pywin32_ctypes-0.2.1-py3-none-any.whl", hash = "sha256:b9a53ef754c894a525469933ab2a447c74ec1ea6b9d2ef446f40ec50d3dcec9f"}, + {file = "pywin32-ctypes-0.2.2.tar.gz", hash = "sha256:3426e063bdd5fd4df74a14fa3cf80a0b42845a87e1d1e81f6549f9daec593a60"}, + {file = "pywin32_ctypes-0.2.2-py3-none-any.whl", hash = "sha256:bf490a1a709baf35d688fe0ecf980ed4de11d2b3e37b51e5442587a75d9957e7"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index da75b0207..4fc5e3ce3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.2.2" +version = "0.2.3" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ diff --git a/src/backend/langflow/chat/manager.py b/src/backend/langflow/chat/manager.py index b693e00a3..4a1b8e77c 100644 --- a/src/backend/langflow/chat/manager.py +++ b/src/backend/langflow/chat/manager.py @@ -209,5 +209,3 @@ class ChatManager: except Exception as e: logger.error(e) self.disconnect(client_id) - - From 1880484a6ca5b496bd2941ab6bed2b443b2cda53 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 13:25:59 -0300 Subject: [PATCH 038/102] fix: add info field to tests --- tests/test_agents_template.py | 10 ++++++++++ tests/test_chains_template.py | 21 +++++++++++++++++++++ tests/test_llms_template.py | 29 +++++++++++++++++++++++++++++ tests/test_prompts_template.py | 9 +++++++++ 4 files changed, 69 insertions(+) diff --git a/tests/test_agents_template.py b/tests/test_agents_template.py index 0497283b9..bf89f9996 100644 --- a/tests/test_agents_template.py +++ b/tests/test_agents_template.py @@ -26,6 +26,7 @@ def test_zero_shot_agent(client: TestClient): "type": "LLMChain", "list": False, "advanced": False, + "info": "", } assert template["allowed_tools"] == { "required": False, @@ -37,6 +38,7 @@ def test_zero_shot_agent(client: TestClient): "type": "Tool", "list": True, "advanced": False, + "info": "", } @@ -60,6 +62,7 @@ def test_json_agent(client: TestClient): "type": "BaseToolkit", "list": False, "advanced": False, + "info": "", } assert template["llm"] == { "required": True, @@ -72,6 +75,7 @@ def test_json_agent(client: TestClient): "list": False, "advanced": False, "display_name": "LLM", + "info": "", } @@ -99,6 +103,7 @@ def test_csv_agent(client: TestClient): "list": False, "file_path": None, "advanced": False, + "info": "", } assert template["llm"] == { "required": True, @@ -111,6 +116,7 @@ def test_csv_agent(client: TestClient): "list": False, "advanced": False, "display_name": "LLM", + "info": "", } @@ -143,6 +149,7 @@ def test_initialize_agent(client: TestClient): "type": "str", "list": True, "advanced": False, + "info": "", } assert template["memory"] == { "required": False, @@ -154,6 +161,7 @@ def test_initialize_agent(client: TestClient): "type": "BaseChatMemory", "list": False, "advanced": False, + "info": "", } assert template["tools"] == { "required": False, @@ -165,6 +173,7 @@ def test_initialize_agent(client: TestClient): "type": "Tool", "list": True, "advanced": False, + "info": "", } assert template["llm"] == { "required": True, @@ -177,4 +186,5 @@ def test_initialize_agent(client: TestClient): "list": False, "advanced": False, "display_name": "LLM", + "info": "", } diff --git a/tests/test_chains_template.py b/tests/test_chains_template.py index cba973272..63e236018 100644 --- a/tests/test_chains_template.py +++ b/tests/test_chains_template.py @@ -38,6 +38,7 @@ def test_conversation_chain(client: TestClient): "type": "BaseMemory", "list": False, "advanced": False, + "info": "", } assert template["verbose"] == { "required": False, @@ -49,6 +50,7 @@ def test_conversation_chain(client: TestClient): "type": "bool", "list": False, "advanced": True, + "info": "", } assert template["llm"] == { "required": True, @@ -60,6 +62,7 @@ def test_conversation_chain(client: TestClient): "type": "BaseLanguageModel", "list": False, "advanced": False, + "info": "", } assert template["input_key"] == { "required": True, @@ -72,6 +75,7 @@ def test_conversation_chain(client: TestClient): "type": "str", "list": False, "advanced": True, + "info": "", } assert template["output_key"] == { "required": True, @@ -84,6 +88,7 @@ def test_conversation_chain(client: TestClient): "type": "str", "list": False, "advanced": True, + "info": "", } assert template["_type"] == "ConversationChain" @@ -120,6 +125,7 @@ def test_llm_chain(client: TestClient): "type": "BaseMemory", "list": False, "advanced": False, + "info": "", } assert template["verbose"] == { "required": False, @@ -132,6 +138,7 @@ def test_llm_chain(client: TestClient): "type": "bool", "list": False, "advanced": True, + "info": "", } assert template["llm"] == { "required": True, @@ -143,6 +150,7 @@ def test_llm_chain(client: TestClient): "type": "BaseLanguageModel", "list": False, "advanced": False, + "info": "", } assert template["output_key"] == { "required": True, @@ -155,6 +163,7 @@ def test_llm_chain(client: TestClient): "type": "str", "list": False, "advanced": True, + "info": "", } @@ -184,6 +193,7 @@ def test_llm_checker_chain(client: TestClient): "type": "BaseLanguageModel", "list": False, "advanced": False, + "info": "", } assert template["_type"] == "LLMCheckerChain" @@ -217,6 +227,7 @@ def test_llm_math_chain(client: TestClient): "type": "BaseMemory", "list": False, "advanced": False, + "info": "", } assert template["verbose"] == { "required": False, @@ -229,6 +240,7 @@ def test_llm_math_chain(client: TestClient): "type": "bool", "list": False, "advanced": True, + "info": "", } assert template["llm"] == { "required": True, @@ -240,6 +252,7 @@ def test_llm_math_chain(client: TestClient): "type": "BaseLanguageModel", "list": False, "advanced": False, + "info": "", } assert template["input_key"] == { "required": True, @@ -252,6 +265,7 @@ def test_llm_math_chain(client: TestClient): "type": "str", "list": False, "advanced": True, + "info": "", } assert template["output_key"] == { "required": True, @@ -264,6 +278,7 @@ def test_llm_math_chain(client: TestClient): "type": "str", "list": False, "advanced": True, + "info": "", } assert template["_type"] == "LLMMathChain" @@ -304,6 +319,7 @@ def test_series_character_chain(client: TestClient): "type": "BaseLanguageModel", "list": False, "advanced": False, + "info": "", } assert template["character"] == { "required": True, @@ -315,6 +331,7 @@ def test_series_character_chain(client: TestClient): "type": "str", "list": False, "advanced": False, + "info": "", } assert template["series"] == { "required": True, @@ -326,6 +343,7 @@ def test_series_character_chain(client: TestClient): "type": "str", "list": False, "advanced": False, + "info": "", } assert template["_type"] == "SeriesCharacterChain" @@ -367,6 +385,7 @@ def test_mid_journey_prompt_chain(client: TestClient): "type": "BaseLanguageModel", "list": False, "advanced": False, + "info": "", } # Test the description object assert ( @@ -406,6 +425,7 @@ def test_time_travel_guide_chain(client: TestClient): "type": "BaseLanguageModel", "list": False, "advanced": False, + "info": "", } assert template["memory"] == { "required": False, @@ -417,6 +437,7 @@ def test_time_travel_guide_chain(client: TestClient): "type": "BaseChatMemory", "list": False, "advanced": False, + "info": "", } assert chain["description"] == "Time travel guide chain." diff --git a/tests/test_llms_template.py b/tests/test_llms_template.py index 3f8c09079..859b722e1 100644 --- a/tests/test_llms_template.py +++ b/tests/test_llms_template.py @@ -121,6 +121,7 @@ def test_openai(client: TestClient): "type": "bool", "list": False, "advanced": False, + "info": "", } assert template["verbose"] == { "required": False, @@ -132,6 +133,7 @@ def test_openai(client: TestClient): "type": "bool", "list": False, "advanced": False, + "info": "", } assert template["client"] == { "required": False, @@ -143,6 +145,7 @@ def test_openai(client: TestClient): "type": "Any", "list": False, "advanced": False, + "info": "", } assert template["model_name"] == { "required": False, @@ -162,6 +165,7 @@ def test_openai(client: TestClient): "type": "str", "list": True, "advanced": False, + "info": "", } # Add more assertions for other properties here assert template["temperature"] == { @@ -175,6 +179,7 @@ def test_openai(client: TestClient): "type": "float", "list": False, "advanced": False, + "info": "", } assert template["max_tokens"] == { "required": False, @@ -187,6 +192,7 @@ def test_openai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["top_p"] == { "required": False, @@ -199,6 +205,7 @@ def test_openai(client: TestClient): "type": "float", "list": False, "advanced": False, + "info": "", } assert template["frequency_penalty"] == { "required": False, @@ -211,6 +218,7 @@ def test_openai(client: TestClient): "type": "float", "list": False, "advanced": False, + "info": "", } assert template["presence_penalty"] == { "required": False, @@ -223,6 +231,7 @@ def test_openai(client: TestClient): "type": "float", "list": False, "advanced": False, + "info": "", } assert template["n"] == { "required": False, @@ -235,6 +244,7 @@ def test_openai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["best_of"] == { "required": False, @@ -247,6 +257,7 @@ def test_openai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["model_kwargs"] == { "required": False, @@ -258,6 +269,7 @@ def test_openai(client: TestClient): "type": "code", "list": False, "advanced": True, + "info": "", } assert template["openai_api_key"] == { "required": False, @@ -271,6 +283,7 @@ def test_openai(client: TestClient): "type": "str", "list": False, "advanced": False, + "info": "", } assert template["batch_size"] == { "required": False, @@ -283,6 +296,7 @@ def test_openai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["request_timeout"] == { "required": False, @@ -294,6 +308,7 @@ def test_openai(client: TestClient): "type": "float", "list": False, "advanced": False, + "info": "", } assert template["logit_bias"] == { "required": False, @@ -305,6 +320,7 @@ def test_openai(client: TestClient): "type": "code", "list": False, "advanced": False, + "info": "", } assert template["max_retries"] == { "required": False, @@ -317,6 +333,7 @@ def test_openai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["streaming"] == { "required": False, @@ -329,6 +346,7 @@ def test_openai(client: TestClient): "type": "bool", "list": False, "advanced": False, + "info": "", } @@ -352,6 +370,7 @@ def test_chat_open_ai(client: TestClient): "type": "bool", "list": False, "advanced": False, + "info": "", } assert template["client"] == { "required": False, @@ -363,6 +382,7 @@ def test_chat_open_ai(client: TestClient): "type": "Any", "list": False, "advanced": False, + "info": "", } assert template["model_name"] == { "required": False, @@ -385,6 +405,7 @@ def test_chat_open_ai(client: TestClient): "type": "str", "list": True, "advanced": False, + "info": "", } assert template["temperature"] == { "required": False, @@ -397,6 +418,7 @@ def test_chat_open_ai(client: TestClient): "type": "float", "list": False, "advanced": False, + "info": "", } assert template["model_kwargs"] == { "required": False, @@ -408,6 +430,7 @@ def test_chat_open_ai(client: TestClient): "type": "code", "list": False, "advanced": True, + "info": "", } assert template["openai_api_key"] == { "required": False, @@ -421,6 +444,7 @@ def test_chat_open_ai(client: TestClient): "type": "str", "list": False, "advanced": False, + "info": "", } assert template["request_timeout"] == { "required": False, @@ -432,6 +456,7 @@ def test_chat_open_ai(client: TestClient): "type": "float", "list": False, "advanced": False, + "info": "", } assert template["max_retries"] == { "required": False, @@ -444,6 +469,7 @@ def test_chat_open_ai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["streaming"] == { "required": False, @@ -456,6 +482,7 @@ def test_chat_open_ai(client: TestClient): "type": "bool", "list": False, "advanced": False, + "info": "", } assert template["n"] == { "required": False, @@ -468,6 +495,7 @@ def test_chat_open_ai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["max_tokens"] == { @@ -480,6 +508,7 @@ def test_chat_open_ai(client: TestClient): "type": "int", "list": False, "advanced": False, + "info": "", } assert template["_type"] == "ChatOpenAI" assert ( diff --git a/tests/test_prompts_template.py b/tests/test_prompts_template.py index 5094f50f0..4e6030cab 100644 --- a/tests/test_prompts_template.py +++ b/tests/test_prompts_template.py @@ -28,6 +28,7 @@ def test_prompt_template(client: TestClient): "type": "str", "list": True, "advanced": False, + "info": "", } assert template["output_parser"] == { "required": False, @@ -39,6 +40,7 @@ def test_prompt_template(client: TestClient): "type": "BaseOutputParser", "list": False, "advanced": False, + "info": "", } assert template["partial_variables"] == { "required": False, @@ -50,6 +52,7 @@ def test_prompt_template(client: TestClient): "type": "code", "list": False, "advanced": False, + "info": "", } assert template["template"] == { "required": True, @@ -61,6 +64,7 @@ def test_prompt_template(client: TestClient): "type": "prompt", "list": False, "advanced": False, + "info": "", } assert template["template_format"] == { "required": False, @@ -73,6 +77,7 @@ def test_prompt_template(client: TestClient): "type": "str", "list": False, "advanced": False, + "info": "", } assert template["validate_template"] == { "required": False, @@ -85,6 +90,7 @@ def test_prompt_template(client: TestClient): "type": "bool", "list": False, "advanced": False, + "info": "", } @@ -106,6 +112,7 @@ def test_zero_shot_prompt(client: TestClient): "type": "prompt", "list": False, "advanced": False, + "info": "", } assert template["suffix"] == { "required": True, @@ -118,6 +125,7 @@ def test_zero_shot_prompt(client: TestClient): "type": "prompt", "list": False, "advanced": False, + "info": "", } assert template["format_instructions"] == { "required": True, @@ -130,4 +138,5 @@ def test_zero_shot_prompt(client: TestClient): "type": "prompt", "list": False, "advanced": False, + "info": "", } From e10d271e223d29817ea47a11c36ca6c560561923 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 15:26:53 -0300 Subject: [PATCH 039/102] =?UTF-8?q?=F0=9F=94=A7=20refactor(ShadTooltipComp?= =?UTF-8?q?onent):=20destructure=20props=20and=20add=20types=20The=20ShadT?= =?UTF-8?q?ooltipComponent=20has=20been=20refactored=20to=20destructure=20?= =?UTF-8?q?the=20props=20and=20add=20types=20to=20improve=20readability=20?= =?UTF-8?q?and=20maintainability.=20The=20ShadTooltipProps=20type=20has=20?= =?UTF-8?q?been=20added=20to=20the=20types/components/index.ts=20file=20to?= =?UTF-8?q?=20define=20the=20expected=20props=20for=20the=20ShadTooltipCom?= =?UTF-8?q?ponent.=20The=20delayDuration,=20side,=20content,=20and=20child?= =?UTF-8?q?ren=20props=20are=20now=20destructured=20from=20the=20props=20o?= =?UTF-8?q?bject=20and=20have=20their=20respective=20types=20defined.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ShadTooltipComponent/index.tsx | 20 ++++++++++--------- src/frontend/src/types/components/index.ts | 9 +++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/components/ShadTooltipComponent/index.tsx b/src/frontend/src/components/ShadTooltipComponent/index.tsx index 44ffac075..aa31b534b 100644 --- a/src/frontend/src/components/ShadTooltipComponent/index.tsx +++ b/src/frontend/src/components/ShadTooltipComponent/index.tsx @@ -1,3 +1,4 @@ +import { ShadTooltipProps } from "../../types/components"; import { Tooltip, TooltipContent, @@ -5,18 +6,19 @@ import { TooltipTrigger, } from "../ui/tooltip"; -const ShadTooltip = (props) => { +const ShadTooltip = ({ + delayDuration = 500, + side, + content, + children, +}: ShadTooltipProps) => { return ( - - {props.children} + + {children} - - {props.content} + + {content} diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index b1570ddda..2ac6960fd 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -110,3 +110,12 @@ export type RadialProgressType = { value?: number; color?: string; }; + +export type Side = "top" | "right" | "bottom" | "left"; + +export type ShadTooltipProps = { + delayDuration?: number; + side?: Side; + content: ReactNode; + children: ReactNode; +}; From 0a3648c23e6c80fd03522da55ae9984540174125 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 15:29:20 -0300 Subject: [PATCH 040/102] =?UTF-8?q?=F0=9F=94=A8=20refactor(GenericNode):?= =?UTF-8?q?=20remove=20unused=20imports=20and=20simplify=20documentation?= =?UTF-8?q?=20tooltip=20The=20required=20indicator=20is=20now=20next=20to?= =?UTF-8?q?=20the=20title,=20which=20improves=20readability=20and=20makes?= =?UTF-8?q?=20it=20easier=20to=20see=20which=20parameters=20are=20required?= =?UTF-8?q?.=20The=20documentation=20tooltip=20has=20been=20simplified=20t?= =?UTF-8?q?o=20only=20show=20the=20documentation=20link,=20which=20improve?= =?UTF-8?q?s=20the=20user=20experience=20by=20reducing=20clutter.=20Unused?= =?UTF-8?q?=20imports=20have=20been=20removed=20to=20improve=20code=20qual?= =?UTF-8?q?ity.=20=F0=9F=94=A8=20refactor(parameterComponent):=20move=20re?= =?UTF-8?q?quired=20indicator=20next=20to=20title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/parameterComponent/index.tsx | 8 +--- .../src/CustomNodes/GenericNode/index.tsx | 45 +------------------ 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 0701bfcd4..ccc18a5fa 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -149,18 +149,14 @@ export default function ParameterComponent({ } > {title} + {required ? " *" : ""}
{info !== "" && ( - + )}
- {required ? " *" : ""}
{left && (type === "str" || diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 40a306ce6..aaa8030b5 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -14,7 +14,6 @@ import NodeModal from "../../modals/NodeModal"; import Tooltip from "../../components/TooltipComponent"; import { NodeToolbar } from "reactflow"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; -import { FileText, Info } from "lucide-react"; import ShadTooltip from "../../components/ShadTooltipComponent"; import { useSSE } from "../../contexts/SSEContext"; @@ -70,22 +69,6 @@ export default function GenericNode({ useEffect(() => {}, [closePopUp, data.node.template]); - useEffect(() => { - refHtml.current = ( -
- {`${data.node.display_name} Documentation`} - - - -
- ); - }, []); - return ( <> @@ -111,37 +94,11 @@ export default function GenericNode({ }} />
- +
{data.node.display_name}
-
- {data.node.documentation !== "" && ( - - - - - - )} -
From 37239e27c9aee424902a6b6b024a9d8f374ed5a5 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 27 Jun 2023 15:29:40 -0300 Subject: [PATCH 041/102] =?UTF-8?q?=F0=9F=8E=A8=20style(extraSidebarCompon?= =?UTF-8?q?ent):=20remove=20delayDuration=20from=20ShadTooltip=20component?= =?UTF-8?q?=20The=20delayDuration=20prop=20was=20removed=20from=20all=20Sh?= =?UTF-8?q?adTooltip=20components=20in=20the=20ExtraSidebar=20component.?= =?UTF-8?q?=20This=20improves=20the=20user=20experience=20by=20removing=20?= =?UTF-8?q?the=20delay=20before=20the=20tooltip=20is=20displayed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FlowPage/components/extraSidebarComponent/index.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index b4f380164..5da2d8e28 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -62,7 +62,7 @@ export default function ExtraSidebar() { return (
- + - + - + - + - {nodeLength > 0 && ( - - - - )} + } + }} + > + + + + + + + {/* -