From 65037a43a57cfe11d833be2c9ac492bee8ef5be7 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Mon, 10 Jun 2024 14:11:04 -0300 Subject: [PATCH 1/5] refactor: Update session_id parameter in build_and_cache_graph_from_db function --- src/backend/base/langflow/api/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/base/langflow/api/utils.py b/src/backend/base/langflow/api/utils.py index 1dbd68d8f..82bd32165 100644 --- a/src/backend/base/langflow/api/utils.py +++ b/src/backend/base/langflow/api/utils.py @@ -219,7 +219,7 @@ async def build_and_cache_graph_from_db(flow_id: str, session: Session, chat_ser if vertex is None: raise ValueError(f"Vertex {vertex_id} not found") if not vertex._raw_params.get("session_id"): - vertex.update_raw_params({"session_id": flow_id}) + vertex.update_raw_params({"session_id": flow_id}, overwrite=True) await chat_service.set_cache(flow_id, graph) return graph From 6eac507eb9bb64e26931bd5dfe3447b9fff34f56 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Mon, 10 Jun 2024 14:11:43 -0300 Subject: [PATCH 2/5] feat: Update RecordsOutput build method to set status --- .../base/langflow/components/outputs/RecordsOutput.py | 1 + .../outputModal/components/switchOutputView/index.tsx | 2 +- .../src/modals/IOModal/components/IOFieldView/index.tsx | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/components/outputs/RecordsOutput.py b/src/backend/base/langflow/components/outputs/RecordsOutput.py index c750e675b..cbd268ea6 100644 --- a/src/backend/base/langflow/components/outputs/RecordsOutput.py +++ b/src/backend/base/langflow/components/outputs/RecordsOutput.py @@ -16,4 +16,5 @@ class RecordOutput(CustomComponent): } def build(self, input_value: Record) -> Record: + self.status = input_value return input_value diff --git a/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx index 307c77c1a..437adb511 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx @@ -28,7 +28,7 @@ export default function SwitchOutputView(nodeId): JSX.Element { if (resultMessage.raw) { resultMessage = resultMessage.raw; } - console.log("resultType", results); + return ( <> diff --git a/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx b/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx index 20cf9f691..4de8d0687 100644 --- a/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx @@ -254,7 +254,11 @@ export default function IOFieldView({
artifact.data + ) ?? [] + } columnMode="union" />
From f8aa1274fc87233436930eaf9aa358219b3f13d6 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Mon, 10 Jun 2024 14:12:24 -0300 Subject: [PATCH 3/5] =?UTF-8?q?=E2=9C=A8=20(record.py):=20add=20=5F=5Feq?= =?UTF-8?q?=5F=5F=20method=20to=20compare=20Record=20instances=20based=20o?= =?UTF-8?q?n=20their=20data=20attribute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/base/langflow/schema/record.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/schema/record.py b/src/backend/base/langflow/schema/record.py index 830f576ba..67d9b5da8 100644 --- a/src/backend/base/langflow/schema/record.py +++ b/src/backend/base/langflow/schema/record.py @@ -1,12 +1,12 @@ import copy import json -from typing import cast, Optional +from typing import Optional, cast from langchain_core.documents import Document from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage +from langchain_core.prompt_values import ImagePromptValue from langchain_core.prompts.image import ImagePromptTemplate from pydantic import BaseModel, model_serializer, model_validator -from langchain_core.prompt_values import ImagePromptValue class Record(BaseModel): @@ -200,3 +200,6 @@ class Record(BaseModel): def __contains__(self, key): return key in self.data + + def __eq__(self, other): + return isinstance(other, Record) and self.data == other.data From 0de6c2a88fb99b4891e09c849c9d39a72af48597 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Mon, 10 Jun 2024 14:12:32 -0300 Subject: [PATCH 4/5] feat: Update Prompt class to assign formatted prompt to self.text --- src/backend/base/langflow/field_typing/prompt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/base/langflow/field_typing/prompt.py b/src/backend/base/langflow/field_typing/prompt.py index ef6c7ce9a..029261ac7 100644 --- a/src/backend/base/langflow/field_typing/prompt.py +++ b/src/backend/base/langflow/field_typing/prompt.py @@ -25,6 +25,7 @@ class Prompt(Record): prompt_template = PromptTemplate.from_template(self.template) variables_with_str_values = dict_values_to_string(self.variables) formatted_prompt = prompt_template.format(**variables_with_str_values) + self.text = formatted_prompt return formatted_prompt @classmethod From 6c27964edd2213671f3c859653dcb9afb49d1c49 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Mon, 10 Jun 2024 14:12:50 -0300 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=90=9B=20(custom=5Fcomponent.py):=20f?= =?UTF-8?q?ix=20resolving=20path=20logic=20to=20handle=20empty=20path=20in?= =?UTF-8?q?put=20and=20check=20if=20path=20parts=20exist=20before=20access?= =?UTF-8?q?ing=20the=20first=20part?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/custom/custom_component/custom_component.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/custom/custom_component/custom_component.py b/src/backend/base/langflow/custom/custom_component/custom_component.py index 896b07337..5c1da081b 100644 --- a/src/backend/base/langflow/custom/custom_component/custom_component.py +++ b/src/backend/base/langflow/custom/custom_component/custom_component.py @@ -126,8 +126,11 @@ class CustomComponent(Component): @staticmethod def resolve_path(path: str) -> str: """Resolves the path to an absolute path.""" + if not path: + return path path_object = Path(path) - if path_object.parts[0] == "~": + + if path_object.parts and path_object.parts[0] == "~": path_object = path_object.expanduser() elif path_object.is_relative_to("."): path_object = path_object.resolve()