From af84dd2c68b4548c0b9e4860d3fdc9a4c0d0196f Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 29 Jun 2023 22:49:32 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20refactor(process.py):=20rename?= =?UTF-8?q?=20build=5Flangchain=5Fobject=5Fwith=5Fcaching=20to=20build=5Fs?= =?UTF-8?q?orted=5Fvertices=5Fwith=5Fcaching=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(process.py):=20handle=20missing=20inputs=20i?= =?UTF-8?q?n=20process=5Fgraph=5Fcached=20function=20The=20function=20`bui?= =?UTF-8?q?ld=5Flangchain=5Fobject=5Fwith=5Fcaching`=20has=20been=20rename?= =?UTF-8?q?d=20to=20`build=5Fsorted=5Fvertices=5Fwith=5Fcaching`=20to=20pr?= =?UTF-8?q?ovide=20a=20more=20descriptive=20name=20that=20accurately=20ref?= =?UTF-8?q?lects=20its=20purpose.=20Additionally,=20the=20`process=5Fgraph?= =?UTF-8?q?=5Fcached`=20function=20now=20handles=20cases=20where=20the=20`?= =?UTF-8?q?inputs`=20parameter=20is=20missing=20or=20empty=20by=20populati?= =?UTF-8?q?ng=20it=20with=20values=20from=20the=20`artifacts`=20dictionary?= =?UTF-8?q?.=20This=20ensures=20that=20all=20required=20inputs=20are=20pro?= =?UTF-8?q?perly=20set=20before=20running=20the=20graph.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/processing/process.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/processing/process.py b/src/backend/langflow/processing/process.py index abf7a00b8..3ccb3a8b1 100644 --- a/src/backend/langflow/processing/process.py +++ b/src/backend/langflow/processing/process.py @@ -2,7 +2,7 @@ from pathlib import Path from langchain.schema import AgentAction import json from langflow.interface.run import ( - build_langchain_object_with_caching, + build_sorted_vertices_with_caching, get_memory_key, update_memory_keys, ) @@ -88,8 +88,16 @@ def process_graph_cached(data_graph: Dict[str, Any], inputs: Optional[dict] = No with PromptTemplate,then run the graph and return the result and thought. """ # Load langchain object - langchain_object = build_langchain_object_with_caching(data_graph) + langchain_object, artifacts = build_sorted_vertices_with_caching(data_graph) logger.debug("Loaded LangChain object") + if inputs is None: + inputs = {} + for ( + key, + value, + ) in artifacts.items(): + if key not in inputs or not inputs[key]: + inputs[key] = value if langchain_object is None: # Raise user facing error