Refactor code to improve performance and readability
This commit is contained in:
parent
810d91a911
commit
15144a31d0
1 changed files with 1248 additions and 1109 deletions
|
|
@ -5,7 +5,7 @@
|
|||
"data": {
|
||||
"nodes": [
|
||||
{
|
||||
"id": "ChatInput-r2WbA",
|
||||
"id": "ChatInput-t7F8v",
|
||||
"type": "genericNode",
|
||||
"position": {
|
||||
"x": 1283.2700598313072,
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
"info": "",
|
||||
"load_from_db": false,
|
||||
"title_case": false,
|
||||
"value": "what i said in the past?"
|
||||
"value": ""
|
||||
},
|
||||
"return_record": {
|
||||
"type": "bool",
|
||||
|
|
@ -170,11 +170,11 @@
|
|||
"field_order": [],
|
||||
"beta": false
|
||||
},
|
||||
"id": "ChatInput-r2WbA"
|
||||
"id": "ChatInput-t7F8v"
|
||||
},
|
||||
"selected": false,
|
||||
"width": 384,
|
||||
"height": 471,
|
||||
"height": 469,
|
||||
"positionAbsolute": {
|
||||
"x": 1283.2700598313072,
|
||||
"y": 982.5953650473145
|
||||
|
|
@ -182,7 +182,7 @@
|
|||
"dragging": false
|
||||
},
|
||||
{
|
||||
"id": "ChatOutput-65FlE",
|
||||
"id": "ChatOutput-P1jEe",
|
||||
"type": "genericNode",
|
||||
"position": {
|
||||
"x": 3154.916355514023,
|
||||
|
|
@ -348,11 +348,11 @@
|
|||
"field_order": [],
|
||||
"beta": false
|
||||
},
|
||||
"id": "ChatOutput-65FlE"
|
||||
"id": "ChatOutput-P1jEe"
|
||||
},
|
||||
"selected": false,
|
||||
"width": 384,
|
||||
"height": 479,
|
||||
"height": 477,
|
||||
"dragging": false,
|
||||
"positionAbsolute": {
|
||||
"x": 3154.916355514023,
|
||||
|
|
@ -360,7 +360,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"id": "MemoryComponent-CsMk7",
|
||||
"id": "MemoryComponent-cdA1J",
|
||||
"type": "genericNode",
|
||||
"position": {
|
||||
"x": 1289.9606870058817,
|
||||
|
|
@ -552,13 +552,13 @@
|
|||
"field_order": [],
|
||||
"beta": true
|
||||
},
|
||||
"id": "MemoryComponent-CsMk7",
|
||||
"id": "MemoryComponent-cdA1J",
|
||||
"description": "Retrieves stored chat messages given a specific Session ID.",
|
||||
"display_name": "Chat Memory"
|
||||
},
|
||||
"selected": false,
|
||||
"width": 384,
|
||||
"height": 491,
|
||||
"height": 489,
|
||||
"dragging": false,
|
||||
"positionAbsolute": {
|
||||
"x": 1289.9606870058817,
|
||||
|
|
@ -566,7 +566,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"id": "Prompt-p9ug4",
|
||||
"id": "Prompt-ODkUx",
|
||||
"type": "genericNode",
|
||||
"position": {
|
||||
"x": 1894.594426342426,
|
||||
|
|
@ -699,13 +699,13 @@
|
|||
"beta": false,
|
||||
"error": null
|
||||
},
|
||||
"id": "Prompt-p9ug4",
|
||||
"id": "Prompt-ODkUx",
|
||||
"description": "A component for creating prompt templates using dynamic variables.",
|
||||
"display_name": "Prompt"
|
||||
},
|
||||
"selected": false,
|
||||
"width": 384,
|
||||
"height": 479,
|
||||
"height": 477,
|
||||
"dragging": false,
|
||||
"positionAbsolute": {
|
||||
"x": 1894.594426342426,
|
||||
|
|
@ -713,7 +713,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"id": "OpenAIModel-OwSm5",
|
||||
"id": "OpenAIModel-9RykF",
|
||||
"type": "genericNode",
|
||||
"position": {
|
||||
"x": 2561.5850334731617,
|
||||
|
|
@ -979,29 +979,137 @@
|
|||
],
|
||||
"beta": false
|
||||
},
|
||||
"id": "OpenAIModel-OwSm5"
|
||||
"id": "OpenAIModel-9RykF"
|
||||
},
|
||||
"selected": false,
|
||||
"width": 384,
|
||||
"height": 565,
|
||||
"height": 563,
|
||||
"positionAbsolute": {
|
||||
"x": 2561.5850334731617,
|
||||
"y": 553.2745131130916
|
||||
},
|
||||
"dragging": false
|
||||
},
|
||||
{
|
||||
"id": "TextOutput-vrs6T",
|
||||
"type": "genericNode",
|
||||
"position": {
|
||||
"x": 1911.4785906252087,
|
||||
"y": 247.39079954376987
|
||||
},
|
||||
"data": {
|
||||
"type": "TextOutput",
|
||||
"node": {
|
||||
"template": {
|
||||
"input_value": {
|
||||
"type": "str",
|
||||
"required": false,
|
||||
"placeholder": "",
|
||||
"list": false,
|
||||
"show": true,
|
||||
"multiline": false,
|
||||
"value": "",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"password": false,
|
||||
"name": "input_value",
|
||||
"display_name": "Value",
|
||||
"advanced": false,
|
||||
"input_types": [
|
||||
"Record",
|
||||
"Text"
|
||||
],
|
||||
"dynamic": false,
|
||||
"info": "Text or Record to be passed as output.",
|
||||
"load_from_db": false,
|
||||
"title_case": false
|
||||
},
|
||||
"code": {
|
||||
"type": "code",
|
||||
"required": true,
|
||||
"placeholder": "",
|
||||
"list": false,
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from typing import Optional\n\nfrom langflow.base.io.text import TextComponent\nfrom langflow.field_typing import Text\n\n\nclass TextOutput(TextComponent):\n display_name = \"Text Output\"\n description = \"Display a text output in the Interaction Panel.\"\n icon = \"type\"\n\n def build_config(self):\n return {\n \"input_value\": {\n \"display_name\": \"Value\",\n \"input_types\": [\"Record\", \"Text\"],\n \"info\": \"Text or Record to be passed as output.\",\n },\n \"record_template\": {\n \"display_name\": \"Record Template\",\n \"multiline\": True,\n \"info\": \"Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.\",\n \"advanced\": True,\n },\n }\n\n def build(self, input_value: Optional[Text] = \"\", record_template: str = \"\") -> Text:\n return super().build(input_value=input_value, record_template=record_template)\n",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": true,
|
||||
"dynamic": true,
|
||||
"info": "",
|
||||
"load_from_db": false,
|
||||
"title_case": false
|
||||
},
|
||||
"record_template": {
|
||||
"type": "str",
|
||||
"required": false,
|
||||
"placeholder": "",
|
||||
"list": false,
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"password": false,
|
||||
"name": "record_template",
|
||||
"display_name": "Record Template",
|
||||
"advanced": true,
|
||||
"dynamic": false,
|
||||
"info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.",
|
||||
"load_from_db": false,
|
||||
"title_case": false,
|
||||
"input_types": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"_type": "CustomComponent"
|
||||
},
|
||||
"description": "Display a text output in the Interaction Panel.",
|
||||
"icon": "type",
|
||||
"base_classes": [
|
||||
"str",
|
||||
"object",
|
||||
"Text"
|
||||
],
|
||||
"display_name": "Inspect Memory",
|
||||
"documentation": "",
|
||||
"custom_fields": {
|
||||
"input_value": null,
|
||||
"record_template": null
|
||||
},
|
||||
"output_types": [
|
||||
"Text"
|
||||
],
|
||||
"field_formatters": {},
|
||||
"frozen": false,
|
||||
"field_order": [],
|
||||
"beta": false
|
||||
},
|
||||
"id": "TextOutput-vrs6T"
|
||||
},
|
||||
"selected": false,
|
||||
"width": 384,
|
||||
"height": 289,
|
||||
"positionAbsolute": {
|
||||
"x": 1911.4785906252087,
|
||||
"y": 247.39079954376987
|
||||
},
|
||||
"dragging": false
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"source": "MemoryComponent-CsMk7",
|
||||
"sourceHandle": "{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œMemoryComponentœ,œidœ:œMemoryComponent-CsMk7œ}",
|
||||
"target": "Prompt-p9ug4",
|
||||
"targetHandle": "{œfieldNameœ:œcontextœ,œidœ:œPrompt-p9ug4œ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"source": "MemoryComponent-cdA1J",
|
||||
"sourceHandle": "{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œMemoryComponentœ,œidœ:œMemoryComponent-cdA1Jœ}",
|
||||
"target": "Prompt-ODkUx",
|
||||
"targetHandle": "{œfieldNameœ:œcontextœ,œidœ:œPrompt-ODkUxœ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"data": {
|
||||
"targetHandle": {
|
||||
"fieldName": "context",
|
||||
"type": "str",
|
||||
"id": "Prompt-p9ug4",
|
||||
"id": "Prompt-ODkUx",
|
||||
"inputTypes": [
|
||||
"Document",
|
||||
"BaseOutputParser",
|
||||
|
|
@ -1016,26 +1124,26 @@
|
|||
"object"
|
||||
],
|
||||
"dataType": "MemoryComponent",
|
||||
"id": "MemoryComponent-CsMk7"
|
||||
"id": "MemoryComponent-cdA1J"
|
||||
}
|
||||
},
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"id": "reactflow__edge-MemoryComponent-CsMk7{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œMemoryComponentœ,œidœ:œMemoryComponent-CsMk7œ}-Prompt-p9ug4{œfieldNameœ:œcontextœ,œidœ:œPrompt-p9ug4œ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"id": "reactflow__edge-MemoryComponent-cdA1J{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œMemoryComponentœ,œidœ:œMemoryComponent-cdA1Jœ}-Prompt-ODkUx{œfieldNameœ:œcontextœ,œidœ:œPrompt-ODkUxœ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"selected": false
|
||||
},
|
||||
{
|
||||
"source": "ChatInput-r2WbA",
|
||||
"sourceHandle": "{œbaseClassesœ:[œTextœ,œobjectœ,œRecordœ,œstrœ],œdataTypeœ:œChatInputœ,œidœ:œChatInput-r2WbAœ}",
|
||||
"target": "Prompt-p9ug4",
|
||||
"targetHandle": "{œfieldNameœ:œuser_messageœ,œidœ:œPrompt-p9ug4œ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"source": "ChatInput-t7F8v",
|
||||
"sourceHandle": "{œbaseClassesœ:[œTextœ,œobjectœ,œRecordœ,œstrœ],œdataTypeœ:œChatInputœ,œidœ:œChatInput-t7F8vœ}",
|
||||
"target": "Prompt-ODkUx",
|
||||
"targetHandle": "{œfieldNameœ:œuser_messageœ,œidœ:œPrompt-ODkUxœ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"data": {
|
||||
"targetHandle": {
|
||||
"fieldName": "user_message",
|
||||
"type": "str",
|
||||
"id": "Prompt-p9ug4",
|
||||
"id": "Prompt-ODkUx",
|
||||
"inputTypes": [
|
||||
"Document",
|
||||
"BaseOutputParser",
|
||||
|
|
@ -1051,25 +1159,25 @@
|
|||
"str"
|
||||
],
|
||||
"dataType": "ChatInput",
|
||||
"id": "ChatInput-r2WbA"
|
||||
"id": "ChatInput-t7F8v"
|
||||
}
|
||||
},
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"id": "reactflow__edge-ChatInput-r2WbA{œbaseClassesœ:[œTextœ,œobjectœ,œRecordœ,œstrœ],œdataTypeœ:œChatInputœ,œidœ:œChatInput-r2WbAœ}-Prompt-p9ug4{œfieldNameœ:œuser_messageœ,œidœ:œPrompt-p9ug4œ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"id": "reactflow__edge-ChatInput-t7F8v{œbaseClassesœ:[œTextœ,œobjectœ,œRecordœ,œstrœ],œdataTypeœ:œChatInputœ,œidœ:œChatInput-t7F8vœ}-Prompt-ODkUx{œfieldNameœ:œuser_messageœ,œidœ:œPrompt-ODkUxœ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"selected": false
|
||||
},
|
||||
{
|
||||
"source": "Prompt-p9ug4",
|
||||
"sourceHandle": "{œbaseClassesœ:[œTextœ,œstrœ,œobjectœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-p9ug4œ}",
|
||||
"target": "OpenAIModel-OwSm5",
|
||||
"targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-OwSm5œ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}",
|
||||
"source": "Prompt-ODkUx",
|
||||
"sourceHandle": "{œbaseClassesœ:[œTextœ,œstrœ,œobjectœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-ODkUxœ}",
|
||||
"target": "OpenAIModel-9RykF",
|
||||
"targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-9RykFœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}",
|
||||
"data": {
|
||||
"targetHandle": {
|
||||
"fieldName": "input_value",
|
||||
"id": "OpenAIModel-OwSm5",
|
||||
"id": "OpenAIModel-9RykF",
|
||||
"inputTypes": [
|
||||
"Text"
|
||||
],
|
||||
|
|
@ -1082,24 +1190,24 @@
|
|||
"object"
|
||||
],
|
||||
"dataType": "Prompt",
|
||||
"id": "Prompt-p9ug4"
|
||||
"id": "Prompt-ODkUx"
|
||||
}
|
||||
},
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-foreground stroke-connection",
|
||||
"id": "reactflow__edge-Prompt-p9ug4{œbaseClassesœ:[œTextœ,œstrœ,œobjectœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-p9ug4œ}-OpenAIModel-OwSm5{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-OwSm5œ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}"
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"id": "reactflow__edge-Prompt-ODkUx{œbaseClassesœ:[œTextœ,œstrœ,œobjectœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-ODkUxœ}-OpenAIModel-9RykF{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-9RykFœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}"
|
||||
},
|
||||
{
|
||||
"source": "OpenAIModel-OwSm5",
|
||||
"sourceHandle": "{œbaseClassesœ:[œstrœ,œobjectœ,œTextœ],œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-OwSm5œ}",
|
||||
"target": "ChatOutput-65FlE",
|
||||
"targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-65FlEœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}",
|
||||
"source": "OpenAIModel-9RykF",
|
||||
"sourceHandle": "{œbaseClassesœ:[œstrœ,œobjectœ,œTextœ],œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-9RykFœ}",
|
||||
"target": "ChatOutput-P1jEe",
|
||||
"targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-P1jEeœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}",
|
||||
"data": {
|
||||
"targetHandle": {
|
||||
"fieldName": "input_value",
|
||||
"id": "ChatOutput-65FlE",
|
||||
"id": "ChatOutput-P1jEe",
|
||||
"inputTypes": [
|
||||
"Text"
|
||||
],
|
||||
|
|
@ -1112,22 +1220,53 @@
|
|||
"Text"
|
||||
],
|
||||
"dataType": "OpenAIModel",
|
||||
"id": "OpenAIModel-OwSm5"
|
||||
"id": "OpenAIModel-9RykF"
|
||||
}
|
||||
},
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"id": "reactflow__edge-OpenAIModel-9RykF{œbaseClassesœ:[œstrœ,œobjectœ,œTextœ],œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-9RykFœ}-ChatOutput-P1jEe{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-P1jEeœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}"
|
||||
},
|
||||
{
|
||||
"source": "MemoryComponent-cdA1J",
|
||||
"sourceHandle": "{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œMemoryComponentœ,œidœ:œMemoryComponent-cdA1Jœ}",
|
||||
"target": "TextOutput-vrs6T",
|
||||
"targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œTextOutput-vrs6Tœ,œinputTypesœ:[œRecordœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"data": {
|
||||
"targetHandle": {
|
||||
"fieldName": "input_value",
|
||||
"id": "TextOutput-vrs6T",
|
||||
"inputTypes": [
|
||||
"Record",
|
||||
"Text"
|
||||
],
|
||||
"type": "str"
|
||||
},
|
||||
"sourceHandle": {
|
||||
"baseClasses": [
|
||||
"str",
|
||||
"Text",
|
||||
"object"
|
||||
],
|
||||
"dataType": "MemoryComponent",
|
||||
"id": "MemoryComponent-cdA1J"
|
||||
}
|
||||
},
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-foreground stroke-connection",
|
||||
"id": "reactflow__edge-OpenAIModel-OwSm5{œbaseClassesœ:[œstrœ,œobjectœ,œTextœ],œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-OwSm5œ}-ChatOutput-65FlE{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-65FlEœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}"
|
||||
"id": "reactflow__edge-MemoryComponent-cdA1J{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œMemoryComponentœ,œidœ:œMemoryComponent-cdA1Jœ}-TextOutput-vrs6T{œfieldNameœ:œinput_valueœ,œidœ:œTextOutput-vrs6Tœ,œinputTypesœ:[œRecordœ,œTextœ],œtypeœ:œstrœ}"
|
||||
}
|
||||
],
|
||||
"viewport": {
|
||||
"x": -391.0433294674358,
|
||||
"y": -105.08951818254411,
|
||||
"zoom": 0.5948708289887507
|
||||
"x": -569.862554459756,
|
||||
"y": -42.08339711050985,
|
||||
"zoom": 0.4868590524514978
|
||||
}
|
||||
},
|
||||
},
|
||||
"description": "This project can be used as a starting point for building a Chat experience with user specific memory. You can set a different Session ID to start a new message history.",
|
||||
"name": "Memory Chatbot",
|
||||
"last_tested_version": "1.0.0a0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue