From 217634fa41df3ac5f7c622148026d574c8c49a0b Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 5 Apr 2023 20:47:49 -0300 Subject: [PATCH 01/10] added colors to toolkits and wrappers --- src/frontend/src/utils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index dc59c6640..19d41ba48 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -77,6 +77,8 @@ export const nodeColors: {[char: string]: string} = { chat: "#454173", thought:"#272541", docloaders:"#FF9135", + toolkits:"#DB2C2C", + wrappers:"#E6277A", unknown:"#9CA3AF" }; From 905804503923b3702defae72c1585f3769e701e9 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 5 Apr 2023 21:07:02 -0300 Subject: [PATCH 02/10] tabsize bug fixed --- .../src/pages/FlowPage/components/tabComponent/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx index 25495dedf..ca21a0a43 100644 --- a/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/tabComponent/index.tsx @@ -50,7 +50,7 @@ export default function TabComponent({ selected, flow, onClick }:{flow:FlowType, ) : (
{ setIsRename(true); setValue(flow.name); From e5ae5d6dcd886fb96333132e15e35b7397ce02f2 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Wed, 5 Apr 2023 21:25:02 -0300 Subject: [PATCH 03/10] bump version to 0.0.53 --- poetry.lock | 55 +++++++++++++++++++++++++------------------------- pyproject.toml | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/poetry.lock b/poetry.lock index ea47f222f..126a99a8b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -220,14 +220,14 @@ files = [ [[package]] name = "beautifulsoup4" -version = "4.12.0" +version = "4.12.1" description = "Screen-scraping library" category = "main" optional = false python-versions = ">=3.6.0" files = [ - {file = "beautifulsoup4-4.12.0-py3-none-any.whl", hash = "sha256:2130a5ad7f513200fae61a17abb5e338ca980fa28c439c0571014bc0217e9591"}, - {file = "beautifulsoup4-4.12.0.tar.gz", hash = "sha256:c5fceeaec29d09c84970e47c65f2f0efe57872f7cff494c9691a26ec0ff13234"}, + {file = "beautifulsoup4-4.12.1-py3-none-any.whl", hash = "sha256:e44795bb4f156d94abb5fbc56efff871c1045bfef72e9efe77558db9f9616ac3"}, + {file = "beautifulsoup4-4.12.1.tar.gz", hash = "sha256:c7bdbfb20a0dbe09518b96a809d93351b2e2bcb8046c0809466fa6632a10c257"}, ] [package.dependencies] @@ -542,29 +542,30 @@ dev = ["flake8", "hypothesis", "ipython", "mypy (>=0.710)", "portray", "pytest ( [[package]] name = "debugpy" -version = "1.6.6" +version = "1.6.7" description = "An implementation of the Debug Adapter Protocol for Python" category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "debugpy-1.6.6-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:0ea1011e94416e90fb3598cc3ef5e08b0a4dd6ce6b9b33ccd436c1dffc8cd664"}, - {file = "debugpy-1.6.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dff595686178b0e75580c24d316aa45a8f4d56e2418063865c114eef651a982e"}, - {file = "debugpy-1.6.6-cp310-cp310-win32.whl", hash = "sha256:87755e173fcf2ec45f584bb9d61aa7686bb665d861b81faa366d59808bbd3494"}, - {file = "debugpy-1.6.6-cp310-cp310-win_amd64.whl", hash = "sha256:72687b62a54d9d9e3fb85e7a37ea67f0e803aaa31be700e61d2f3742a5683917"}, - {file = "debugpy-1.6.6-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:78739f77c58048ec006e2b3eb2e0cd5a06d5f48c915e2fc7911a337354508110"}, - {file = "debugpy-1.6.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:23c29e40e39ad7d869d408ded414f6d46d82f8a93b5857ac3ac1e915893139ca"}, - {file = "debugpy-1.6.6-cp37-cp37m-win32.whl", hash = "sha256:7aa7e103610e5867d19a7d069e02e72eb2b3045b124d051cfd1538f1d8832d1b"}, - {file = "debugpy-1.6.6-cp37-cp37m-win_amd64.whl", hash = "sha256:f6383c29e796203a0bba74a250615ad262c4279d398e89d895a69d3069498305"}, - {file = "debugpy-1.6.6-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:23363e6d2a04d726bbc1400bd4e9898d54419b36b2cdf7020e3e215e1dcd0f8e"}, - {file = "debugpy-1.6.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9b5d1b13d7c7bf5d7cf700e33c0b8ddb7baf030fcf502f76fc061ddd9405d16c"}, - {file = "debugpy-1.6.6-cp38-cp38-win32.whl", hash = "sha256:70ab53918fd907a3ade01909b3ed783287ede362c80c75f41e79596d5ccacd32"}, - {file = "debugpy-1.6.6-cp38-cp38-win_amd64.whl", hash = "sha256:c05349890804d846eca32ce0623ab66c06f8800db881af7a876dc073ac1c2225"}, - {file = "debugpy-1.6.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a771739902b1ae22a120dbbb6bd91b2cae6696c0e318b5007c5348519a4211c6"}, - {file = "debugpy-1.6.6-cp39-cp39-win32.whl", hash = "sha256:549ae0cb2d34fc09d1675f9b01942499751d174381b6082279cf19cdb3c47cbe"}, - {file = "debugpy-1.6.6-cp39-cp39-win_amd64.whl", hash = "sha256:de4a045fbf388e120bb6ec66501458d3134f4729faed26ff95de52a754abddb1"}, - {file = "debugpy-1.6.6-py2.py3-none-any.whl", hash = "sha256:be596b44448aac14eb3614248c91586e2bc1728e020e82ef3197189aae556115"}, - {file = "debugpy-1.6.6.zip", hash = "sha256:b9c2130e1c632540fbf9c2c88341493797ddf58016e7cba02e311de9b0a96b67"}, + {file = "debugpy-1.6.7-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:b3e7ac809b991006ad7f857f016fa92014445085711ef111fdc3f74f66144096"}, + {file = "debugpy-1.6.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3876611d114a18aafef6383695dfc3f1217c98a9168c1aaf1a02b01ec7d8d1e"}, + {file = "debugpy-1.6.7-cp310-cp310-win32.whl", hash = "sha256:33edb4afa85c098c24cc361d72ba7c21bb92f501104514d4ffec1fb36e09c01a"}, + {file = "debugpy-1.6.7-cp310-cp310-win_amd64.whl", hash = "sha256:ed6d5413474e209ba50b1a75b2d9eecf64d41e6e4501977991cdc755dc83ab0f"}, + {file = "debugpy-1.6.7-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:38ed626353e7c63f4b11efad659be04c23de2b0d15efff77b60e4740ea685d07"}, + {file = "debugpy-1.6.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:279d64c408c60431c8ee832dfd9ace7c396984fd7341fa3116aee414e7dcd88d"}, + {file = "debugpy-1.6.7-cp37-cp37m-win32.whl", hash = "sha256:dbe04e7568aa69361a5b4c47b4493d5680bfa3a911d1e105fbea1b1f23f3eb45"}, + {file = "debugpy-1.6.7-cp37-cp37m-win_amd64.whl", hash = "sha256:f90a2d4ad9a035cee7331c06a4cf2245e38bd7c89554fe3b616d90ab8aab89cc"}, + {file = "debugpy-1.6.7-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:5224eabbbeddcf1943d4e2821876f3e5d7d383f27390b82da5d9558fd4eb30a9"}, + {file = "debugpy-1.6.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bae1123dff5bfe548ba1683eb972329ba6d646c3a80e6b4c06cd1b1dd0205e9b"}, + {file = "debugpy-1.6.7-cp38-cp38-win32.whl", hash = "sha256:9cd10cf338e0907fdcf9eac9087faa30f150ef5445af5a545d307055141dd7a4"}, + {file = "debugpy-1.6.7-cp38-cp38-win_amd64.whl", hash = "sha256:aaf6da50377ff4056c8ed470da24632b42e4087bc826845daad7af211e00faad"}, + {file = "debugpy-1.6.7-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:0679b7e1e3523bd7d7869447ec67b59728675aadfc038550a63a362b63029d2c"}, + {file = "debugpy-1.6.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de86029696e1b3b4d0d49076b9eba606c226e33ae312a57a46dca14ff370894d"}, + {file = "debugpy-1.6.7-cp39-cp39-win32.whl", hash = "sha256:d71b31117779d9a90b745720c0eab54ae1da76d5b38c8026c654f4a066b0130a"}, + {file = "debugpy-1.6.7-cp39-cp39-win_amd64.whl", hash = "sha256:c0ff93ae90a03b06d85b2c529eca51ab15457868a377c4cc40a23ab0e4e552a3"}, + {file = "debugpy-1.6.7-py2.py3-none-any.whl", hash = "sha256:53f7a456bc50706a0eaabecf2d3ce44c4d5010e46dfc65b6b81a518b42866267"}, + {file = "debugpy-1.6.7.zip", hash = "sha256:c4c2f0810fa25323abfdfa36cbbbb24e5c3b1a42cb762782de64439c575d67f2"}, ] [[package]] @@ -755,14 +756,14 @@ grpcio-gcp = ["grpcio-gcp (>=0.2.2,<1.0dev)"] [[package]] name = "google-api-python-client" -version = "2.83.0" +version = "2.84.0" description = "Google API Client Library for Python" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "google-api-python-client-2.83.0.tar.gz", hash = "sha256:d07509f1b2d2b2427363b454db996f7a15e1751a48cfcaf28427050560dd51cf"}, - {file = "google_api_python_client-2.83.0-py2.py3-none-any.whl", hash = "sha256:afa7fe2a5d77e8f136cdb8f40a120dd6660c2292f791c1b22734dfe786bd1dac"}, + {file = "google-api-python-client-2.84.0.tar.gz", hash = "sha256:c398fd6f9ead0be23aade3b2704c72c5146df0e3352d8ff9101286077e1b010a"}, + {file = "google_api_python_client-2.84.0-py2.py3-none-any.whl", hash = "sha256:83041bb895863225ecdd9c59dd58565fa48c57c2f10fe06f7c08da7c42c53abc"}, ] [package.dependencies] @@ -774,14 +775,14 @@ uritemplate = ">=3.0.1,<5" [[package]] name = "google-auth" -version = "2.17.1" +version = "2.17.2" description = "Google Authentication Library" category = "main" optional = false python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*" files = [ - {file = "google-auth-2.17.1.tar.gz", hash = "sha256:8f379b46bad381ad2a0b989dfb0c13ad28d3c2a79f27348213f8946a1d15d55a"}, - {file = "google_auth-2.17.1-py2.py3-none-any.whl", hash = "sha256:357ff22a75b4c0f6093470f21816a825d2adee398177569824e37b6c10069e19"}, + {file = "google-auth-2.17.2.tar.gz", hash = "sha256:295c80ebb95eac74003c07a696cf3ef6b414e9230ae8894f3843f8215fd2aa56"}, + {file = "google_auth-2.17.2-py2.py3-none-any.whl", hash = "sha256:544536a43d44dff0f64222e4d027d124989fcb9c10979687e589e1694fba9c94"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index c50b5e12e..c4cfcee8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.0.52" +version = "0.0.53" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ From a344ef29868582a5f79527e7e4eb710f809327c8 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Wed, 5 Apr 2023 21:53:32 -0300 Subject: [PATCH 04/10] fix: add prompt as field_type for validation --- src/backend/langflow/template/nodes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/template/nodes.py b/src/backend/langflow/template/nodes.py index acfc5c2d2..04329b75a 100644 --- a/src/backend/langflow/template/nodes.py +++ b/src/backend/langflow/template/nodes.py @@ -254,11 +254,12 @@ class PromptFrontendNode(FrontendNode): # if field.field_type == "StringPromptTemplate" # change it to str if field.field_type == "StringPromptTemplate" and "Message" in str(name): - field.field_type = "str" + field.field_type = "prompt" field.multiline = True field.value = HUMAN_PROMPT if "Human" in field.name else SYSTEM_PROMPT if field.name == "template" and field.value == "": field.value = DEFAULT_PROMPT + field.field_type = "prompt" if ( "Union" in field.field_type From d6e261286fc339c3ae26a1f66d8a12c4d87b178e Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Wed, 5 Apr 2023 22:05:57 -0300 Subject: [PATCH 05/10] fix: added default prompt fields --- src/backend/langflow/template/nodes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/langflow/template/nodes.py b/src/backend/langflow/template/nodes.py index 04329b75a..c76c56b14 100644 --- a/src/backend/langflow/template/nodes.py +++ b/src/backend/langflow/template/nodes.py @@ -253,12 +253,20 @@ class PromptFrontendNode(FrontendNode): def format_field(field: TemplateField, name: Optional[str] = None) -> None: # if field.field_type == "StringPromptTemplate" # change it to str + PROMPT_FIELDS = [ + "template", + "suffix", + "prefix", + "examples", + ] if field.field_type == "StringPromptTemplate" and "Message" in str(name): field.field_type = "prompt" field.multiline = True field.value = HUMAN_PROMPT if "Human" in field.name else SYSTEM_PROMPT if field.name == "template" and field.value == "": field.value = DEFAULT_PROMPT + + if field.name in PROMPT_FIELDS: field.field_type = "prompt" if ( From 1269f2c371f9fd2f2d6c3f8e2137f9eef5394b4f Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 5 Apr 2023 22:27:21 -0300 Subject: [PATCH 06/10] prompt component created with verification --- .../components/parameterComponent/index.tsx | 15 +- .../src/components/promptComponent/index.tsx | 35 ++++ src/frontend/src/controllers/API/index.ts | 7 +- .../src/modals/codeAreaModal/index.tsx | 1 - src/frontend/src/modals/promptModal/index.tsx | 153 ++++++++++++++++++ src/frontend/src/types/api/index.ts | 3 +- 6 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 src/frontend/src/components/promptComponent/index.tsx create mode 100644 src/frontend/src/modals/promptModal/index.tsx diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 6bf038066..1a2eeb9e6 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -14,6 +14,7 @@ import CodeAreaComponent from "../../../../components/codeAreaComponent"; import InputFileComponent from "../../../../components/inputFileComponent"; import { TabsContext } from "../../../../contexts/tabsContext"; import IntComponent from "../../../../components/intComponent"; +import PromptAreaComponent from "../../../../components/promptComponent"; export default function ParameterComponent({ left, @@ -63,6 +64,7 @@ export default function ParameterComponent({ type === "bool" || type === "float" || type === "code" || + type === "prompt" || type === "file" || type === "int") ? ( <> @@ -187,9 +189,16 @@ export default function ParameterComponent({ save(); }} /> - ) : ( - <> - )} + ) : left === true && type === "prompt" ? ( + { + data.node.template[name].value = t; + save(); + }} + /> + ):(<>)}
); diff --git a/src/frontend/src/components/promptComponent/index.tsx b/src/frontend/src/components/promptComponent/index.tsx new file mode 100644 index 000000000..6ad51f87b --- /dev/null +++ b/src/frontend/src/components/promptComponent/index.tsx @@ -0,0 +1,35 @@ +import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline"; +import { useContext, useEffect, useState } from "react"; +import { PopUpContext } from "../../contexts/popUpContext"; +import CodeAreaModal from "../../modals/codeAreaModal"; +import TextAreaModal from "../../modals/textAreaModal"; +import { TextAreaComponentType } from "../../types/components"; +import PromptAreaModal from "../../modals/promptModal"; + +export default function PromptAreaComponent({ value, onChange, disabled }:TextAreaComponentType) { + const [myValue, setMyValue] = useState(value); + const { openPopUp } = useContext(PopUpContext); + useEffect(() => { + if (disabled) { + setMyValue(""); + onChange(""); + } + }, [disabled, onChange]); + return ( +
+
+ + {myValue !== "" ? myValue : 'Text empty'} + + +
+
+ ); +} diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index bad966ea9..8fa7ff527 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -1,4 +1,4 @@ -import { errorsTypeAPI } from './../../types/api/index'; +import { PromptTypeAPI, errorsTypeAPI } from './../../types/api/index'; import { APIObjectType, sendAllProps } from '../../types/api/index'; import axios, { AxiosResponse } from "axios"; @@ -13,4 +13,9 @@ export async function sendAll(data:sendAllProps) { export async function checkCode(code:string):Promise>{ return await axios.post('/validate/code',{code}) +} + +export async function checkPrompt(template:string):Promise>{ + + return await axios.post('/validate/prompt',{template}) } \ No newline at end of file diff --git a/src/frontend/src/modals/codeAreaModal/index.tsx b/src/frontend/src/modals/codeAreaModal/index.tsx index 72b40ed40..db4de60f4 100644 --- a/src/frontend/src/modals/codeAreaModal/index.tsx +++ b/src/frontend/src/modals/codeAreaModal/index.tsx @@ -96,7 +96,6 @@ export default function CodeAreaModal({
- {/* need to insert code editor */} void; + value: string; +}) { + const [open, setOpen] = useState(true); + const [myValue, setMyValue] = useState(value); + const { dark } = useContext(darkContext); + const { setErrorData, setSuccessData } = useContext(alertContext); + const { closePopUp } = useContext(PopUpContext); + const ref = useRef(); + function setModalOpen(x: boolean) { + setOpen(x); + if (x === false) { + setTimeout(() => { + closePopUp(); + }, 300); + } + } + return ( + + + +
+ + +
+
+ + +
+ +
+
+
+
+
+
+ + Edit Prompt + +
+
+
+
+
+