From 45dfa30851714e251f828c5db3f70183ab8dcccd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 1 Jul 2023 09:42:29 -0300 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=90=9B=20fix(run.py):=20refactor=20up?= =?UTF-8?q?dating=20memory=20keys=20logic=20to=20use=20a=20loop=20and=20tr?= =?UTF-8?q?y-except=20block=20The=20logic=20for=20updating=20memory=20keys?= =?UTF-8?q?=20in=20the=20`run.py`=20file=20has=20been=20refactored=20to=20?= =?UTF-8?q?use=20a=20loop=20and=20a=20try-except=20block.=20Instead=20of?= =?UTF-8?q?=20individually=20assigning=20values=20to=20`input=5Fkey`,=20`o?= =?UTF-8?q?utput=5Fkey`,=20and=20`memory=5Fkey`,=20the=20keys=20and=20attr?= =?UTF-8?q?ibutes=20are=20now=20stored=20in=20lists.=20The=20loop=20iterat?= =?UTF-8?q?es=20over=20the=20lists=20and=20attempts=20to=20set=20the=20att?= =?UTF-8?q?ribute=20values=20using=20`setattr()`.=20If=20an=20attribute=20?= =?UTF-8?q?does=20not=20exist,=20a=20`ValueError`=20is=20caught=20and=20a?= =?UTF-8?q?=20debug=20log=20message=20is=20printed.=20This=20refactoring?= =?UTF-8?q?=20improves=20code=20readability=20and=20maintainability.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/run.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/interface/run.py b/src/backend/langflow/interface/run.py index a3efe2b0c..ff888487f 100644 --- a/src/backend/langflow/interface/run.py +++ b/src/backend/langflow/interface/run.py @@ -62,6 +62,10 @@ def update_memory_keys(langchain_object, possible_new_mem_key): if key not in [langchain_object.memory.memory_key, possible_new_mem_key] ][0] - langchain_object.memory.input_key = input_key - langchain_object.memory.output_key = output_key - langchain_object.memory.memory_key = possible_new_mem_key + keys = [input_key, output_key, possible_new_mem_key] + attrs = ["input_key", "output_key", "memory_key"] + for key, attr in zip(keys, attrs): + try: + setattr(langchain_object.memory, attr, key) + except ValueError as exc: + logger.debug(f"{langchain_object.memory} has no attribute {attr} ({exc})") From d39bea6e85d534f92cc2a62b57d05e90c6f08ae0 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 1 Jul 2023 09:42:44 -0300 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20convert?= =?UTF-8?q?=20retriever=20to=20retriever=20object=20if=20it=20has=20"as=5F?= =?UTF-8?q?retriever"=20method=20The=20code=20now=20checks=20if=20the=20"r?= =?UTF-8?q?etriever"=20key=20exists=20in=20the=20params=20dictionary=20and?= =?UTF-8?q?=20if=20the=20value=20has=20an=20"as=5Fretriever"=20method.=20I?= =?UTF-8?q?f=20it=20does,=20the=20value=20is=20replaced=20with=20the=20res?= =?UTF-8?q?ult=20of=20calling=20the=20"as=5Fretriever"=20method.=20This=20?= =?UTF-8?q?change=20ensures=20that=20the=20"retriever"=20parameter=20is=20?= =?UTF-8?q?always=20an=20instance=20of=20the=20retriever=20object,=20preve?= =?UTF-8?q?nting=20potential=20attribute=20errors=20later=20in=20the=20cod?= =?UTF-8?q?e.?= 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, 2 insertions(+) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index f214ab74b..9c618b1cd 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -100,6 +100,8 @@ def instantiate_llm(node_type, class_object, params: Dict): def instantiate_memory(node_type, class_object, params): try: + if "retriever" in params and hasattr(params["retriever"], "as_retriever"): + params["retriever"] = params["retriever"].as_retriever() return class_object(**params) # I want to catch a specific attribute error that happens # when the object does not have a cursor attribute From 2635f06a06ed8b9f8ec40697d3016f476f40e788 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 1 Jul 2023 09:43:02 -0300 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=90=9B=20fix(base.py):=20add=20except?= =?UTF-8?q?ion=20logging=20to=20improve=20error=20handling=20and=20debuggi?= =?UTF-8?q?ng=20The=20`logger.exception(exc)`=20line=20has=20been=20added?= =?UTF-8?q?=20to=20log=20the=20exception=20that=20occurred.=20This=20will?= =?UTF-8?q?=20help=20with=20error=20handling=20and=20debugging=20by=20prov?= =?UTF-8?q?iding=20more=20information=20about=20the=20exception=20that=20c?= =?UTF-8?q?aused=20the=20error.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/processing/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/langflow/processing/base.py b/src/backend/langflow/processing/base.py index 97b0d5be0..b332eac7c 100644 --- a/src/backend/langflow/processing/base.py +++ b/src/backend/langflow/processing/base.py @@ -51,5 +51,6 @@ async def get_result_and_steps(langchain_object, message: str, **kwargs): ) thought = format_actions(intermediate_steps) if intermediate_steps else "" except Exception as exc: + logger.exception(exc) raise ValueError(f"Error: {str(exc)}") from exc return result, thought From e04eb0fd7e68b9bedd980c0aee03a1ac6d253c45 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 1 Jul 2023 09:43:17 -0300 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=90=9B=20fix(memories.py):=20add=20co?= =?UTF-8?q?ndition=20to=20only=20add=20output=5Fkey=20field=20if=20templat?= =?UTF-8?q?e=20type=20is=20not=20VectorStoreRetrieverMemory=20The=20output?= =?UTF-8?q?=5Fkey=20field=20is=20now=20only=20added=20to=20the=20template?= =?UTF-8?q?=20if=20the=20template=20type=20is=20not=20VectorStoreRetriever?= =?UTF-8?q?Memory.=20This=20ensures=20that=20the=20output=5Fkey=20field=20?= =?UTF-8?q?is=20not=20added=20unnecessarily=20for=20templates=20of=20this?= =?UTF-8?q?=20type.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/frontend_node/memories.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/backend/langflow/template/frontend_node/memories.py b/src/backend/langflow/template/frontend_node/memories.py index 37177c72e..6d490212f 100644 --- a/src/backend/langflow/template/frontend_node/memories.py +++ b/src/backend/langflow/template/frontend_node/memories.py @@ -37,16 +37,17 @@ class MemoryFrontendNode(FrontendNode): value="", ) ) - self.template.add_field( - TemplateField( - field_type="str", - required=False, - show=True, - name="output_key", - advanced=True, - value="", + if self.template.type_name not in {"VectorStoreRetrieverMemory"}: + self.template.add_field( + TemplateField( + field_type="str", + required=False, + show=True, + name="output_key", + advanced=True, + value="", + ) ) - ) @staticmethod def format_field(field: TemplateField, name: Optional[str] = None) -> None: From 016c9983d6fff446de4780d271a89ebeaa54ed53 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 1 Jul 2023 09:43:30 -0300 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=90=9B=20fix(vectorstores.py):=20chan?= =?UTF-8?q?ge=20default=20value=20of=20"Persist"=20extra=20field=20to=20Fa?= =?UTF-8?q?lse=20The=20default=20value=20of=20the=20"Persist"=20extra=20fi?= =?UTF-8?q?eld=20in=20the=20VectorStoreFrontendNode=20class=20has=20been?= =?UTF-8?q?=20changed=20from=20True=20to=20False.=20This=20change=20was=20?= =?UTF-8?q?made=20to=20align=20the=20default=20value=20with=20the=20desire?= =?UTF-8?q?d=20behavior=20of=20the=20application.?= 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 58cfcdc34..13c955f7a 100644 --- a/src/backend/langflow/template/frontend_node/vectorstores.py +++ b/src/backend/langflow/template/frontend_node/vectorstores.py @@ -51,7 +51,7 @@ class VectorStoreFrontendNode(FrontendNode): required=False, show=True, advanced=False, - value=True, + value=False, display_name="Persist", ) extra_fields.append(extra_field) From 156807b8e16bad58760e3a3ef536de824fe581a8 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 1 Jul 2023 09:52:45 -0300 Subject: [PATCH 6/6] fix: replace old complex_example to fix tests --- tests/data/complex_example.json | 744 +------------------------------- 1 file changed, 1 insertion(+), 743 deletions(-) diff --git a/tests/data/complex_example.json b/tests/data/complex_example.json index d7d0d44c6..b4e688fc7 100644 --- a/tests/data/complex_example.json +++ b/tests/data/complex_example.json @@ -1,743 +1 @@ -{ - "name": "New Flow", - "id": "0", - "data": { - "nodes": [ - { - "width": 384, - "height": 351, - "id": "dndnode_3", - "type": "genericNode", - "position": { - "x": 612.9299322834961, - "y": 194.75070242078417 - }, - "data": { - "type": "ZeroShotAgent", - "node": { - "template": { - "_type": "zero-shot-react-description", - "llm_chain": { - "type": "LLMChain", - "required": true, - "placeholder": "", - "list": false, - "show": true, - "password": false, - "multiline": false - }, - "allowed_tools": { - "type": "Tool", - "required": false, - "placeholder": "", - "list": true, - "show": true, - "password": false, - "multiline": false, - "value": null - }, - "return_values": { - "type": "str", - "required": false, - "placeholder": "", - "list": true, - "show": false, - "password": false, - "multiline": false, - "value": [ - "output" - ] - } - }, - "description": "Agent for the MRKL chain.", - "base_classes": [ - "Agent", - "function" - ] - }, - "id": "dndnode_3", - "value": null - }, - "selected": false, - "positionAbsolute": { - "x": 612.9299322834961, - "y": 194.75070242078417 - }, - "dragging": false - }, - { - "width": 384, - "height": 463, - "id": "dndnode_27", - "type": "genericNode", - "position": { - "x": 86.29922452047686, - "y": 39.132143332238115 - }, - "data": { - "type": "Tool", - "node": { - "template": { - "name": { - "type": "str", - "required": true, - "list": false, - "show": true, - "placeholder": "", - "value": "Uppercase", - "password": false, - "multiline": false - }, - "description": { - "type": "str", - "required": true, - "list": false, - "show": true, - "placeholder": "", - "value": "Returns an uppercase version of the text passed.", - "password": false, - "multiline": false - }, - "func": { - "type": "function", - "required": true, - "list": false, - "show": true, - "value": "", - "multiline": false, - "password": false - }, - "_type": "Tool" - }, - "name": "Tool", - "func": "", - "description": "", - "base_classes": [ - "Tool" - ] - }, - "id": "dndnode_27", - "value": null - }, - "selected": false, - "positionAbsolute": { - "x": 86.29922452047686, - "y": 39.132143332238115 - }, - "dragging": false - }, - { - "width": 384, - "height": 463, - "id": "dndnode_28", - "type": "genericNode", - "position": { - "x": 1134.4549802672202, - "y": 287.9885910233929 - }, - "data": { - "type": "Tool", - "node": { - "template": { - "name": { - "type": "str", - "required": true, - "list": false, - "show": true, - "placeholder": "", - "value": "", - "password": false, - "multiline": false - }, - "description": { - "type": "str", - "required": true, - "list": false, - "show": true, - "placeholder": "", - "value": "", - "password": false, - "multiline": false - }, - "func": { - "type": "function", - "required": true, - "list": false, - "show": true, - "value": "", - "multiline": false, - "password": false - }, - "_type": "Tool" - }, - "name": "Tool", - "func": "", - "description": "", - "base_classes": [ - "Tool" - ] - }, - "id": "dndnode_28", - "value": null - }, - "positionAbsolute": { - "x": 1134.4549802672202, - "y": 287.9885910233929 - }, - "selected": false, - "dragging": false - }, - { - "width": 384, - "height": 357, - "id": "dndnode_40", - "type": "genericNode", - "position": { - "x": -366.4341715850213, - "y": 136.29836646158452 - }, - "data": { - "type": "PythonFunctionTool", - "node": { - "template": { - "code": { - "required": true, - "placeholder": "", - "show": true, - "multiline": true, - "value": "\ndef upper_case(text: str) -> str:\n return text.upper()\n", - "name": "code", - "type": "str", - "list": false - }, - "description": { - "required": true, - "placeholder": "", - "show": true, - "multiline": true, - "value": "My description", - "name": "description", - "type": "str", - "list": false - }, - "name": { - "required": true, - "placeholder": "", - "show": true, - "multiline": true, - "value": "My Tool", - "name": "name", - "type": "str", - "list": false - }, - "_type": "python_function" - }, - "description": "Python function to be executed.", - "base_classes": [ - "function" - ] - }, - "id": "dndnode_40", - "value": null - }, - "selected": false, - "positionAbsolute": { - "x": -366.4341715850213, - "y": 136.29836646158452 - }, - "dragging": false - }, - { - "width": 384, - "height": 351, - "id": "dndnode_41", - "type": "genericNode", - "position": { - "x": 1642.7653281427417, - "y": 69.01105573790835 - }, - "data": { - "type": "ZeroShotAgent", - "node": { - "template": { - "_type": "zero-shot-react-description", - "llm_chain": { - "type": "LLMChain", - "required": true, - "placeholder": "", - "list": false, - "show": true, - "password": false, - "multiline": false - }, - "allowed_tools": { - "type": "Tool", - "required": false, - "placeholder": "", - "list": true, - "show": true, - "password": false, - "multiline": false, - "value": null - }, - "return_values": { - "type": "str", - "required": false, - "placeholder": "", - "list": true, - "show": false, - "password": false, - "multiline": false, - "value": [ - "output" - ] - } - }, - "description": "Agent for the MRKL chain.", - "base_classes": [ - "Agent", - "function" - ] - }, - "id": "dndnode_41", - "value": null - }, - "selected": false, - "positionAbsolute": { - "x": 1642.7653281427417, - "y": 69.01105573790835 - }, - "dragging": false - }, - { - "width": 384, - "height": 529, - "id": "dndnode_42", - "type": "genericNode", - "position": { - "x": -379.23467185725826, - "y": -551.3889442620921 - }, - "data": { - "type": "ZeroShotPrompt", - "node": { - "template": { - "prefix": { - "required": false, - "placeholder": "", - "show": true, - "multiline": true, - "value": "Answer the following questions as best you can. You have access to the following tools:", - "name": "prefix", - "type": "str", - "list": false - }, - "suffix": { - "required": true, - "placeholder": "", - "show": true, - "multiline": true, - "value": "Begin!\n\nQuestion: {input}\nThought:{agent_scratchpad}", - "name": "suffix", - "type": "str", - "list": false - }, - "format_instructions": { - "required": false, - "placeholder": "", - "show": true, - "multiline": true, - "value": "Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question", - "name": "format_instructions", - "type": "str", - "list": false - }, - "_type": "ZeroShotPrompt" - }, - "description": "Prompt template for Zero Shot Agent.", - "base_classes": [ - "BasePromptTemplate" - ] - }, - "id": "dndnode_42", - "value": null - }, - "selected": false, - "positionAbsolute": { - "x": -379.23467185725826, - "y": -551.3889442620921 - }, - "dragging": false - }, - { - "width": 384, - "height": 391, - "id": "dndnode_43", - "type": "genericNode", - "position": { - "x": 100.76532814274174, - "y": -437.78894426209195 - }, - "data": { - "type": "LLMChain", - "node": { - "template": { - "_type": "llm_chain", - "memory": { - "type": "BaseMemory", - "required": false, - "placeholder": "", - "list": false, - "show": true, - "password": false, - "multiline": false, - "value": null - }, - "verbose": { - "type": "bool", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": false - }, - "prompt": { - "type": "BasePromptTemplate", - "required": true, - "placeholder": "", - "list": false, - "show": true, - "password": false, - "multiline": false - }, - "llm": { - "type": "BaseLanguageModel", - "required": true, - "placeholder": "", - "list": false, - "show": true, - "password": false, - "multiline": false - }, - "output_key": { - "type": "str", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": true, - "multiline": false, - "value": "text" - } - }, - "description": "Chain to run queries against LLMs.", - "base_classes": [ - "Chain" - ] - }, - "id": "dndnode_43", - "value": null - }, - "selected": false, - "positionAbsolute": { - "x": 100.76532814274174, - "y": -437.78894426209195 - }, - "dragging": false - }, - { - "width": 384, - "height": 477, - "id": "dndnode_44", - "type": "genericNode", - "position": { - "x": -841.2346718572583, - "y": 368.6110557379079 - }, - "data": { - "type": "OpenAI", - "node": { - "template": { - "_type": "openai", - "cache": { - "type": "bool", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": null - }, - "verbose": { - "type": "bool", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": null - }, - "client": { - "type": "Any", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": null - }, - "model_name": { - "type": "str", - "required": false, - "placeholder": "", - "list": false, - "show": true, - "password": false, - "multiline": false, - "value": "text-davinci-003", - "options": [ - "text-davinci-003", - "text-davinci-002", - "text-curie-001", - "text-babbage-001", - "text-ada-001" - ] - }, - "temperature": { - "type": "float", - "required": false, - "placeholder": "", - "list": false, - "show": true, - "password": false, - "multiline": false, - "value": 0.7 - }, - "max_tokens": { - "type": "int", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": true, - "multiline": false, - "value": 256 - }, - "top_p": { - "type": "float", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": 1 - }, - "frequency_penalty": { - "type": "float", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": 0 - }, - "presence_penalty": { - "type": "float", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": 0 - }, - "n": { - "type": "int", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": 1 - }, - "best_of": { - "type": "int", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": 1 - }, - "model_kwargs": { - "type": "dict[str, Any]", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": null - }, - "openai_api_key": { - "type": "str", - "required": false, - "placeholder": "", - "list": false, - "show": true, - "password": true, - "multiline": false, - "value": "sk-" - }, - "batch_size": { - "type": "int", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": 20 - }, - "request_timeout": { - "type": "Union[float, Tuple[float, float], NoneType]", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": null - }, - "logit_bias": { - "type": "dict[str, float]", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": null - }, - "max_retries": { - "type": "int", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": 6 - }, - "streaming": { - "type": "bool", - "required": false, - "placeholder": "", - "list": false, - "show": false, - "password": false, - "multiline": false, - "value": false - } - }, - "description": "Generic OpenAI class that uses model name.", - "base_classes": [ - "BaseOpenAI", - "BaseLLM", - "BaseLanguageModel" - ] - }, - "id": "dndnode_44", - "value": null - }, - "selected": false, - "positionAbsolute": { - "x": -841.2346718572583, - "y": 368.6110557379079 - }, - "dragging": false - } - ], - "edges": [ - { - "source": "dndnode_27", - "sourceHandle": "Tool|dndnode_27|Tool", - "target": "dndnode_3", - "targetHandle": "Tool|allowed_tools|dndnode_3", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_27Tool|dndnode_27|Tool-dndnode_3Tool|allowed_tools|dndnode_3" - }, - { - "source": "dndnode_3", - "sourceHandle": "ZeroShotAgent|dndnode_3|Agent|function", - "target": "dndnode_28", - "targetHandle": "function|func|dndnode_28", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_3ZeroShotAgent|dndnode_3|Agent|function-dndnode_28function|func|dndnode_28" - }, - { - "source": "dndnode_40", - "sourceHandle": "PythonFunction|dndnode_40|function", - "target": "dndnode_27", - "targetHandle": "function|func|dndnode_27", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_40PythonFunction|dndnode_40|function-dndnode_27function|func|dndnode_27" - }, - { - "source": "dndnode_28", - "sourceHandle": "Tool|dndnode_28|Tool", - "target": "dndnode_41", - "targetHandle": "Tool|allowed_tools|dndnode_41", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_28Tool|dndnode_28|Tool-dndnode_41Tool|allowed_tools|dndnode_41" - }, - { - "source": "dndnode_42", - "sourceHandle": "ZeroShotPrompt|dndnode_42|BasePromptTemplate", - "target": "dndnode_43", - "targetHandle": "BasePromptTemplate|prompt|dndnode_43", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_42ZeroShotPrompt|dndnode_42|BasePromptTemplate-dndnode_43BasePromptTemplate|prompt|dndnode_43" - }, - { - "source": "dndnode_44", - "sourceHandle": "OpenAI|dndnode_44|BaseOpenAI|BaseLLM|BaseLanguageModel", - "target": "dndnode_43", - "targetHandle": "BaseLanguageModel|llm|dndnode_43", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_44OpenAI|dndnode_44|BaseOpenAI|BaseLLM|BaseLanguageModel-dndnode_43BaseLanguageModel|llm|dndnode_43" - }, - { - "source": "dndnode_43", - "sourceHandle": "LLMChain|dndnode_43|Chain", - "target": "dndnode_3", - "targetHandle": "LLMChain|llm_chain|dndnode_3", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_43LLMChain|dndnode_43|Chain-dndnode_3LLMChain|llm_chain|dndnode_3" - }, - { - "source": "dndnode_43", - "sourceHandle": "LLMChain|dndnode_43|Chain", - "target": "dndnode_41", - "targetHandle": "LLMChain|llm_chain|dndnode_41", - "className": "animate-pulse", - "id": "reactflow__edge-dndnode_43LLMChain|dndnode_43|Chain-dndnode_41LLMChain|llm_chain|dndnode_41" - } - ], - "viewport": { - "x": 250.11733592862913, - "y": 349.94447213104604, - "zoom": 0.5 - } - }, - "chat": [] -} \ No newline at end of file +{"description":"Chain the Words, Master Language!","name":"complex_example","data":{"nodes":[{"width":384,"height":267,"id":"ZeroShotAgent-UQytQ","type":"genericNode","position":{"x":1444.3029693177525,"y":769.2195451536553},"data":{"type":"ZeroShotAgent","node":{"template":{"allowed_tools":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"allowed_tools","advanced":false,"info":"","type":"Tool","list":true},"llm_chain":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"llm_chain","advanced":false,"info":"","type":"LLMChain","list":false},"output_parser":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"output_parser","advanced":false,"info":"","type":"AgentOutputParser","list":false},"_type":"ZeroShotAgent"},"description":"Agent for the MRKL chain.","base_classes":["BaseSingleActionAgent","ZeroShotAgent","Agent","function"],"display_name":"ZeroShotAgent","documentation":"https://python.langchain.com/docs/modules/agents/how_to/custom_mrkl_agent"},"id":"ZeroShotAgent-UQytQ","value":null},"selected":false,"positionAbsolute":{"x":1444.3029693177525,"y":769.2195451536553},"dragging":false},{"width":384,"height":267,"id":"ZeroShotAgent-4Yl9Q","type":"genericNode","position":{"x":2507.5134255411913,"y":703.4268189022047},"data":{"type":"ZeroShotAgent","node":{"template":{"allowed_tools":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"allowed_tools","advanced":false,"info":"","type":"Tool","list":true},"llm_chain":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"llm_chain","advanced":false,"info":"","type":"LLMChain","list":false},"output_parser":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"output_parser","advanced":false,"info":"","type":"AgentOutputParser","list":false},"_type":"ZeroShotAgent"},"description":"Agent for the MRKL chain.","base_classes":["BaseSingleActionAgent","ZeroShotAgent","Agent","function"],"display_name":"ZeroShotAgent","documentation":"https://python.langchain.com/docs/modules/agents/how_to/custom_mrkl_agent"},"id":"ZeroShotAgent-4Yl9Q","value":null},"selected":false,"positionAbsolute":{"x":2507.5134255411913,"y":703.4268189022047},"dragging":false},{"width":384,"height":475,"id":"Tool-Ssk4g","type":"genericNode","position":{"x":1990.4155792278825,"y":894.4563316029999},"data":{"type":"Tool","node":{"template":{"func":{"required":true,"placeholder":"","show":true,"multiline":true,"password":false,"name":"func","advanced":false,"info":"","type":"function","list":false},"description":{"required":true,"placeholder":"","show":true,"multiline":true,"value":"AgentTool","password":false,"name":"description","advanced":false,"info":"","type":"str","list":false},"name":{"required":true,"placeholder":"","show":true,"multiline":true,"value":"AgentTool","password":false,"name":"name","advanced":false,"info":"","type":"str","list":false},"return_direct":{"required":true,"placeholder":"","show":true,"multiline":false,"value":false,"password":false,"name":"return_direct","advanced":false,"info":"","type":"bool","list":false},"_type":"Tool"},"description":"Converts a chain, agent or function into a tool.","base_classes":["Tool"],"display_name":"Tool","documentation":""},"id":"Tool-Ssk4g","value":null},"selected":false,"positionAbsolute":{"x":1990.4155792278825,"y":894.4563316029999},"dragging":false},{"width":384,"height":513,"id":"PythonFunctionTool-qSfC8","type":"genericNode","position":{"x":881.9234666781165,"y":717.4260855419674},"data":{"type":"PythonFunctionTool","node":{"template":{"code":{"required":true,"placeholder":"","show":true,"multiline":true,"value":"\ndef python_function(text: str) -> str:\n \"\"\"This is a default python function that returns the input text\"\"\"\n return text\n","password":false,"name":"code","advanced":false,"info":"","type":"code","list":false},"description":{"required":true,"placeholder":"","show":true,"multiline":true,"value":"Uppercases","password":false,"name":"description","advanced":false,"info":"","type":"str","list":false},"name":{"required":true,"placeholder":"","show":true,"multiline":false,"value":"Uppercase","password":false,"name":"name","advanced":false,"info":"","type":"str","list":false},"return_direct":{"required":true,"placeholder":"","show":true,"multiline":false,"value":false,"password":false,"name":"return_direct","advanced":false,"info":"","type":"bool","list":false},"_type":"PythonFunctionTool"},"description":"Python function to be executed.","base_classes":["Tool"],"display_name":"PythonFunctionTool","documentation":""},"id":"PythonFunctionTool-qSfC8","value":null},"selected":false,"dragging":false,"positionAbsolute":{"x":881.9234666781165,"y":717.4260855419674}},{"width":384,"height":307,"id":"LLMChain-5pPr3","type":"genericNode","position":{"x":952.8848633792611,"y":205.91268432121848},"data":{"type":"LLMChain","node":{"template":{"callbacks":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"callbacks","advanced":false,"info":"","type":"langchain.callbacks.base.BaseCallbackHandler","list":true},"llm":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"llm","advanced":false,"info":"","type":"BaseLanguageModel","list":false},"memory":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"memory","advanced":false,"info":"","type":"BaseMemory","list":false},"output_parser":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"output_parser","advanced":false,"info":"","type":"BaseLLMOutputParser","list":false},"prompt":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"prompt","advanced":false,"info":"","type":"BasePromptTemplate","list":false},"llm_kwargs":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"llm_kwargs","advanced":false,"info":"","type":"code","list":false},"output_key":{"required":true,"placeholder":"","show":true,"multiline":false,"value":"text","password":false,"name":"output_key","advanced":true,"info":"","type":"str","list":false},"return_final_only":{"required":false,"placeholder":"","show":false,"multiline":false,"value":true,"password":false,"name":"return_final_only","advanced":false,"info":"","type":"bool","list":false},"tags":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"tags","advanced":false,"info":"","type":"str","list":true},"verbose":{"required":false,"placeholder":"","show":true,"multiline":false,"value":false,"password":false,"name":"verbose","advanced":true,"info":"","type":"bool","list":false},"_type":"LLMChain"},"description":"Chain to run queries against LLMs.","base_classes":["LLMChain","Chain","function"],"display_name":"LLMChain","documentation":"https://python.langchain.com/docs/modules/chains/foundational/llm_chain"},"id":"LLMChain-5pPr3","value":null},"selected":false,"positionAbsolute":{"x":952.8848633792611,"y":205.91268432121848},"dragging":false},{"width":384,"height":421,"id":"ZeroShotPrompt-KeA26","type":"genericNode","position":{"x":284.2531445624355,"y":99.41468159745108},"data":{"type":"ZeroShotPrompt","node":{"template":{"format_instructions":{"required":true,"placeholder":"","show":true,"multiline":true,"value":"Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question","password":false,"name":"format_instructions","advanced":false,"info":"","type":"prompt","list":false},"prefix":{"required":false,"placeholder":"","show":true,"multiline":true,"value":"Answer the following questions as best you can. You have access to the following tools:","password":false,"name":"prefix","advanced":false,"info":"","type":"prompt","list":false},"suffix":{"required":true,"placeholder":"","show":true,"multiline":true,"value":"Begin!\n\nQuestion: {input}\nThought:{agent_scratchpad}","password":false,"name":"suffix","advanced":false,"info":"","type":"prompt","list":false},"_type":"ZeroShotPrompt"},"description":"Prompt template for Zero Shot Agent.","base_classes":["BasePromptTemplate"],"display_name":"ZeroShotPrompt","documentation":"https://python.langchain.com/docs/modules/agents/how_to/custom_mrkl_agent"},"id":"ZeroShotPrompt-KeA26","value":null},"selected":false,"positionAbsolute":{"x":284.2531445624355,"y":99.41468159745108},"dragging":false},{"width":384,"height":611,"id":"OpenAI-YKFjJ","type":"genericNode","position":{"x":151.61242562883945,"y":646.4646888408231},"data":{"type":"OpenAI","node":{"template":{"allowed_special":{"required":false,"placeholder":"","show":false,"multiline":false,"value":[],"password":false,"name":"allowed_special","advanced":false,"info":"","type":"Literal'all'","list":true},"callbacks":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"callbacks","advanced":false,"info":"","type":"langchain.callbacks.base.BaseCallbackHandler","list":true},"disallowed_special":{"required":false,"placeholder":"","show":false,"multiline":false,"value":"all","password":false,"name":"disallowed_special","advanced":false,"info":"","type":"Literal'all'","list":false},"batch_size":{"required":false,"placeholder":"","show":false,"multiline":false,"value":20,"password":false,"name":"batch_size","advanced":false,"info":"","type":"int","list":false},"best_of":{"required":false,"placeholder":"","show":false,"multiline":false,"value":1,"password":false,"name":"best_of","advanced":false,"info":"","type":"int","list":false},"cache":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"cache","advanced":false,"info":"","type":"bool","list":false},"client":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"client","advanced":false,"info":"","type":"Any","list":false},"frequency_penalty":{"required":false,"placeholder":"","show":false,"multiline":false,"value":0,"password":false,"name":"frequency_penalty","advanced":false,"info":"","type":"float","list":false},"logit_bias":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"logit_bias","advanced":false,"info":"","type":"code","list":false},"max_retries":{"required":false,"placeholder":"","show":false,"multiline":false,"value":6,"password":false,"name":"max_retries","advanced":false,"info":"","type":"int","list":false},"max_tokens":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"","password":true,"name":"max_tokens","advanced":false,"info":"","type":"int","list":false},"model_kwargs":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"model_kwargs","advanced":true,"info":"","type":"code","list":false},"model_name":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"text-davinci-003","password":false,"options":["text-davinci-003","text-davinci-002","text-curie-001","text-babbage-001","text-ada-001"],"name":"model_name","advanced":false,"info":"","type":"str","list":true},"n":{"required":false,"placeholder":"","show":false,"multiline":false,"value":1,"password":false,"name":"n","advanced":false,"info":"","type":"int","list":false},"openai_api_base":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"openai_api_base","display_name":"OpenAI API Base","advanced":false,"info":"\nThe base URL of the OpenAI API. Defaults to https://api.openai.com/v1.\n\nYou can change this to use other APIs like JinaChat, LocalAI and Prem.\n","type":"str","list":false},"openai_api_key":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"","password":true,"name":"openai_api_key","display_name":"OpenAI API Key","advanced":false,"info":"","type":"str","list":false},"openai_organization":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"openai_organization","display_name":"OpenAI Organization","advanced":false,"info":"","type":"str","list":false},"openai_proxy":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"openai_proxy","display_name":"OpenAI Proxy","advanced":false,"info":"","type":"str","list":false},"presence_penalty":{"required":false,"placeholder":"","show":false,"multiline":false,"value":0,"password":false,"name":"presence_penalty","advanced":false,"info":"","type":"float","list":false},"request_timeout":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"request_timeout","advanced":false,"info":"","type":"float","list":false},"streaming":{"required":false,"placeholder":"","show":false,"multiline":false,"value":false,"password":false,"name":"streaming","advanced":false,"info":"","type":"bool","list":false},"tags":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"tags","advanced":false,"info":"","type":"str","list":true},"temperature":{"required":false,"placeholder":"","show":true,"multiline":false,"value":0.7,"password":false,"name":"temperature","advanced":false,"info":"","type":"float","list":false},"tiktoken_model_name":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"tiktoken_model_name","advanced":false,"info":"","type":"str","list":false},"top_p":{"required":false,"placeholder":"","show":false,"multiline":false,"value":1,"password":false,"name":"top_p","advanced":false,"info":"","type":"float","list":false},"verbose":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"verbose","advanced":false,"info":"","type":"bool","list":false},"_type":"OpenAI"},"description":"Wrapper around OpenAI large language models.","base_classes":["BaseOpenAI","BaseLLM","OpenAI","BaseLanguageModel"],"display_name":"OpenAI","documentation":"https://python.langchain.com/docs/modules/model_io/models/llms/integrations/openai"},"id":"OpenAI-YKFjJ","value":null},"selected":false,"positionAbsolute":{"x":151.61242562883945,"y":646.4646888408231},"dragging":false}],"edges":[{"source":"Tool-Ssk4g","sourceHandle":"Tool|Tool-Ssk4g|Tool","target":"ZeroShotAgent-4Yl9Q","targetHandle":"Tool|allowed_tools|ZeroShotAgent-4Yl9Q","style":{"stroke":"inherit"},"className":"stroke-gray-900 dark:stroke-gray-200","animated":false,"id":"reactflow__edge-Tool-Ssk4gTool|Tool-Ssk4g|Tool-ZeroShotAgent-4Yl9QTool|allowed_tools|ZeroShotAgent-4Yl9Q","selected":false},{"source":"ZeroShotAgent-UQytQ","sourceHandle":"ZeroShotAgent|ZeroShotAgent-UQytQ|BaseSingleActionAgent|ZeroShotAgent|Agent|function","target":"Tool-Ssk4g","targetHandle":"function|func|Tool-Ssk4g","style":{"stroke":"inherit"},"className":"stroke-gray-900 dark:stroke-gray-200","animated":false,"id":"reactflow__edge-ZeroShotAgent-UQytQZeroShotAgent|ZeroShotAgent-UQytQ|BaseSingleActionAgent|ZeroShotAgent|Agent|function-Tool-Ssk4gfunction|func|Tool-Ssk4g","selected":false},{"source":"PythonFunctionTool-qSfC8","sourceHandle":"PythonFunctionTool|PythonFunctionTool-qSfC8|Tool","target":"ZeroShotAgent-UQytQ","targetHandle":"Tool|allowed_tools|ZeroShotAgent-UQytQ","style":{"stroke":"inherit"},"className":"stroke-gray-900 dark:stroke-gray-200","animated":false,"id":"reactflow__edge-PythonFunctionTool-qSfC8PythonFunctionTool|PythonFunctionTool-qSfC8|Tool-ZeroShotAgent-UQytQTool|allowed_tools|ZeroShotAgent-UQytQ","selected":false},{"source":"ZeroShotPrompt-KeA26","sourceHandle":"ZeroShotPrompt|ZeroShotPrompt-KeA26|BasePromptTemplate","target":"LLMChain-5pPr3","targetHandle":"BasePromptTemplate|prompt|LLMChain-5pPr3","style":{"stroke":"inherit"},"className":"stroke-gray-900 dark:stroke-gray-200","animated":false,"id":"reactflow__edge-ZeroShotPrompt-KeA26ZeroShotPrompt|ZeroShotPrompt-KeA26|BasePromptTemplate-LLMChain-5pPr3BasePromptTemplate|prompt|LLMChain-5pPr3","selected":false},{"source":"OpenAI-YKFjJ","sourceHandle":"OpenAI|OpenAI-YKFjJ|BaseOpenAI|BaseLLM|OpenAI|BaseLanguageModel","target":"LLMChain-5pPr3","targetHandle":"BaseLanguageModel|llm|LLMChain-5pPr3","style":{"stroke":"inherit"},"className":"stroke-gray-900 dark:stroke-gray-200","animated":false,"id":"reactflow__edge-OpenAI-YKFjJOpenAI|OpenAI-YKFjJ|BaseOpenAI|BaseLLM|OpenAI|BaseLanguageModel-LLMChain-5pPr3BaseLanguageModel|llm|LLMChain-5pPr3","selected":false},{"source":"LLMChain-5pPr3","sourceHandle":"LLMChain|LLMChain-5pPr3|LLMChain|Chain|function","target":"ZeroShotAgent-4Yl9Q","targetHandle":"LLMChain|llm_chain|ZeroShotAgent-4Yl9Q","style":{"stroke":"inherit"},"className":"stroke-gray-900 dark:stroke-gray-200","animated":false,"id":"reactflow__edge-LLMChain-5pPr3LLMChain|LLMChain-5pPr3|LLMChain|Chain|function-ZeroShotAgent-4Yl9QLLMChain|llm_chain|ZeroShotAgent-4Yl9Q","selected":false},{"source":"LLMChain-5pPr3","sourceHandle":"LLMChain|LLMChain-5pPr3|LLMChain|Chain|function","target":"ZeroShotAgent-UQytQ","targetHandle":"LLMChain|llm_chain|ZeroShotAgent-UQytQ","style":{"stroke":"inherit"},"className":"stroke-gray-900 dark:stroke-gray-200","animated":false,"id":"reactflow__edge-LLMChain-5pPr3LLMChain|LLMChain-5pPr3|LLMChain|Chain|function-ZeroShotAgent-UQytQLLMChain|llm_chain|ZeroShotAgent-UQytQ","selected":false}],"viewport":{"x":-77.90141289801102,"y":58.94201890632064,"zoom":0.3906639400861592}},"id":"e5213457-cb4c-48b5-b2bf-a6bc5b63f625"} \ No newline at end of file