{
  "id": 6,
  "title": "DB Assistant",
  "description": "An advanced agent that converts user queries into SQL statements, executes the queries, and assesses and returns the results. You must prepare three knowledge bases: 1: DDL for your database; 2: Examples of user queries converted to SQL statements; 3: A comprehensive description of your database, including but not limited to tables and records. You are also required to configure the corresponding database.",
  "canvas_type": "chatbot",
  "dsl": {
      "answer": [],
      "components": {
        "Answer:SocialAdsWonder": {
          "downstream": [
            "RewriteQuestion:WildIdeasTell"
          ],
          "obj": {
            "component_name": "Answer",
            "inputs": [],
            "output": {},
            "params": {}
          },
          "upstream": [
            "ExeSQL:QuietRosesRun",
            "begin"
          ]
        },
        "ExeSQL:QuietRosesRun": {
          "downstream": [
            "Answer:SocialAdsWonder"
          ],
          "obj": {
            "component_name": "ExeSQL",
            "inputs": [],
            "output": {},
            "params": {
              "database": "",
              "db_type": "mysql",
              "frequencyPenaltyEnabled": true,
              "frequency_penalty": 0.7,
              "host": "",
              "llm_id": "deepseek-chat@DeepSeek",
              "loop": 3,
              "maxTokensEnabled": true,
              "max_tokens": 512,
              "password": "",
              "port": 6630,
              "presencePenaltyEnabled": true,
              "presence_penalty": 0.4,
              "query": [],
              "temperature": 0.1,
              "temperatureEnabled": true,
              "topPEnabled": true,
              "top_n": 30,
              "top_p": 0.3,
              "username": "root"
            }
          },
          "upstream": [
            "Generate:BlueShirtsLaugh"
          ]
        },
        "Generate:BlueShirtsLaugh": {
          "downstream": [
            "ExeSQL:QuietRosesRun"
          ],
          "obj": {
            "component_name": "Generate",
            "params": {
              "cite": false,
              "frequency_penalty": 0.7,
              "llm_id": "deepseek-chat@DeepSeek",
              "message_history_window_size": 1,
              "parameters": [],
              "presence_penalty": 0.4,
              "prompt": "\n##The user provides a question and you provide SQL. You will only respond with SQL code and not with any explanations.\n\n##You may use the following DDL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {Retrieval:SillyPartsCheer}.\n\n##You may use the following documentation as a reference for what tables might be available. Use responses to past questions also to guide you: {Retrieval:OddSingersRefuse}.\n\n##You may use the following SQL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {Retrieval:BrownStreetsRhyme}.\n\n##Respond with only SQL code. Do not answer with any explanations -- just the code.",
              "temperature": 0.1,
              "top_p": 0.3
            }
          },
          "upstream": [
            "Retrieval:SillyPartsCheer",
            "Retrieval:BrownStreetsRhyme",
            "Retrieval:OddSingersRefuse"
          ]
        },
        "Retrieval:BrownStreetsRhyme": {
          "downstream": [
            "Generate:BlueShirtsLaugh"
          ],
          "obj": {
            "component_name": "Retrieval",
            "inputs": [],
            "output": {},
            "params": {
              "empty_response": "Nothing found in Q->SQL!",
              "kb_ids": [],
              "keywords_similarity_weight": 0.3,
              "query": [
                {
                  "component_id": "Answer:SocialAdsWonder",
                  "type": "reference"
                }
              ],
              "similarity_threshold": 0.2,
              "top_n": 8
            }
          },
          "upstream": [
            "RewriteQuestion:WildIdeasTell"
          ]
        },
        "Retrieval:OddSingersRefuse": {
          "downstream": [
            "Generate:BlueShirtsLaugh"
          ],
          "obj": {
            "component_name": "Retrieval",
            "inputs": [],
            "output": {},
            "params": {
              "empty_response": "Nothing found in DB-Description!",
              "kb_ids": [],
              "keywords_similarity_weight": 0.3,
              "query": [
                {
                  "component_id": "Answer:SocialAdsWonder",
                  "type": "reference"
                }
              ],
              "similarity_threshold": 0.2,
              "top_n": 8
            }
          },
          "upstream": [
            "RewriteQuestion:WildIdeasTell"
          ]
        },
        "Retrieval:SillyPartsCheer": {
          "downstream": [
            "Generate:BlueShirtsLaugh"
          ],
          "obj": {
            "component_name": "Retrieval",
            "inputs": [],
            "output": {},
            "params": {
              "empty_response": "Nothing found in DDL!",
              "kb_ids": [],
              "keywords_similarity_weight": 0.1,
              "query": [
                {
                  "component_id": "Answer:SocialAdsWonder",
                  "type": "reference"
                }
              ],
              "similarity_threshold": 0.02,
              "top_n": 18
            }
          },
          "upstream": [
            "RewriteQuestion:WildIdeasTell"
          ]
        },
        "RewriteQuestion:WildIdeasTell": {
          "downstream": [
            "Retrieval:OddSingersRefuse",
            "Retrieval:BrownStreetsRhyme",
            "Retrieval:SillyPartsCheer"
          ],
          "obj": {
            "component_name": "RewriteQuestion",
            "params": {
              "frequencyPenaltyEnabled": true,
              "frequency_penalty": 0.7,
              "llm_id": "deepseek-chat@DeepSeek",
              "maxTokensEnabled": true,
              "max_tokens": 256,
              "message_history_window_size": 6,
              "parameter": "Precise",
              "presencePenaltyEnabled": true,
              "presence_penalty": 0.4,
              "temperature": 0.1,
              "temperatureEnabled": true,
              "topPEnabled": true,
              "top_p": 0.3
            }
          },
          "upstream": [
            "Answer:SocialAdsWonder"
          ]
        },
        "begin": {
          "downstream": [
            "Answer:SocialAdsWonder"
          ],
          "obj": {
            "component_name": "Begin",
            "inputs": [],
            "output": {
              "content": {
                "0": {
                  "content": "Hi! I'm your smart assistant. What can I do for you?"
                }
              }
            },
            "params": {}
          },
          "upstream": []
        }
      },
      "embed_id": "BAAI/bge-large-zh-v1.5",
      "graph": {
        "edges": [
          {
            "id": "xy-edge__ExeSQL:QuietRosesRunc-Answer:SocialAdsWonderc",
            "markerEnd": "logo",
            "source": "ExeSQL:QuietRosesRun",
            "sourceHandle": "c",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Answer:SocialAdsWonder",
            "targetHandle": "c",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__begin-Answer:SocialAdsWonderc",
            "markerEnd": "logo",
            "source": "begin",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Answer:SocialAdsWonder",
            "targetHandle": "c",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__Answer:SocialAdsWonderb-RewriteQuestion:WildIdeasTellc",
            "markerEnd": "logo",
            "source": "Answer:SocialAdsWonder",
            "sourceHandle": "b",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "RewriteQuestion:WildIdeasTell",
            "targetHandle": "c",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__RewriteQuestion:WildIdeasTellb-Retrieval:OddSingersRefusec",
            "markerEnd": "logo",
            "source": "RewriteQuestion:WildIdeasTell",
            "sourceHandle": "b",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Retrieval:OddSingersRefuse",
            "targetHandle": "c",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__RewriteQuestion:WildIdeasTellb-Retrieval:BrownStreetsRhymec",
            "markerEnd": "logo",
            "source": "RewriteQuestion:WildIdeasTell",
            "sourceHandle": "b",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Retrieval:BrownStreetsRhyme",
            "targetHandle": "c",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__RewriteQuestion:WildIdeasTellb-Retrieval:SillyPartsCheerc",
            "markerEnd": "logo",
            "source": "RewriteQuestion:WildIdeasTell",
            "sourceHandle": "b",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Retrieval:SillyPartsCheer",
            "targetHandle": "c",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__Generate:BlueShirtsLaughc-ExeSQL:QuietRosesRunb",
            "markerEnd": "logo",
            "source": "Generate:BlueShirtsLaugh",
            "sourceHandle": "c",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "ExeSQL:QuietRosesRun",
            "targetHandle": "b",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__Retrieval:SillyPartsCheerb-Generate:BlueShirtsLaughb",
            "markerEnd": "logo",
            "source": "Retrieval:SillyPartsCheer",
            "sourceHandle": "b",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Generate:BlueShirtsLaugh",
            "targetHandle": "b",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__Retrieval:BrownStreetsRhymeb-Generate:BlueShirtsLaughb",
            "markerEnd": "logo",
            "source": "Retrieval:BrownStreetsRhyme",
            "sourceHandle": "b",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Generate:BlueShirtsLaugh",
            "targetHandle": "b",
            "type": "buttonEdge",
            "zIndex": 1001
          },
          {
            "id": "xy-edge__Retrieval:OddSingersRefuseb-Generate:BlueShirtsLaughb",
            "markerEnd": "logo",
            "source": "Retrieval:OddSingersRefuse",
            "sourceHandle": "b",
            "style": {
              "stroke": "rgb(202 197 245)",
              "strokeWidth": 2
            },
            "target": "Generate:BlueShirtsLaugh",
            "targetHandle": "b",
            "type": "buttonEdge",
            "zIndex": 1001
          }
        ],
        "nodes": [
          {
            "data": {
              "label": "Begin",
              "name": "begin"
            },
            "dragging": false,
            "height": 44,
            "id": "begin",
            "measured": {
              "height": 44,
              "width": 200
            },
            "position": {
              "x": -707.997699967585,
              "y": 271.71609546793474
            },
            "positionAbsolute": {
              "x": -707.997699967585,
              "y": 271.71609546793474
            },
            "selected": false,
            "sourcePosition": "left",
            "targetPosition": "right",
            "type": "beginNode",
            "width": 200
          },
          {
            "data": {
              "form": {},
              "label": "Answer",
              "name": "Interface"
            },
            "dragging": false,
            "height": 44,
            "id": "Answer:SocialAdsWonder",
            "measured": {
              "height": 44,
              "width": 200
            },
            "position": {
              "x": -265.59460323639587,
              "y": 271.1879130306969
            },
            "positionAbsolute": {
              "x": -58.36886074370702,
              "y": 272.1213623212045
            },
            "selected": false,
            "sourcePosition": "right",
            "targetPosition": "left",
            "type": "logicNode",
            "width": 200
          },
          {
            "data": {
              "form": {
                "empty_response": "Nothing found in DDL!",
                "kb_ids": [],
                "keywords_similarity_weight": 0.1,
                "query": [
                  {
                    "component_id": "Answer:SocialAdsWonder",
                    "type": "reference"
                  }
                ],
                "similarity_threshold": 0.02,
                "top_n": 18
              },
              "label": "Retrieval",
              "name": "DDL"
            },
            "dragging": false,
            "height": 106,
            "id": "Retrieval:SillyPartsCheer",
            "measured": {
              "height": 106,
              "width": 200
            },
            "position": {
              "x": 194.69889765569846,
              "y": 61.49435233230193
            },
            "positionAbsolute": {
              "x": 198.3020069445181,
              "y": -0.9595420072386389
            },
            "selected": false,
            "sourcePosition": "right",
            "targetPosition": "left",
            "type": "retrievalNode",
            "width": 200
          },
          {
            "data": {
              "form": {
                "empty_response": "Nothing found in Q->SQL!",
                "kb_ids": [],
                "keywords_similarity_weight": 0.3,
                "query": [
                  {
                    "component_id": "Answer:SocialAdsWonder",
                    "type": "reference"
                  }
                ],
                "similarity_threshold": 0.2,
                "top_n": 8
              },
              "label": "Retrieval",
              "name": "Q->SQL"
            },
            "dragging": false,
            "height": 106,
            "id": "Retrieval:BrownStreetsRhyme",
            "measured": {
              "height": 106,
              "width": 200
            },
            "position": {
              "x": 240.78282320440022,
              "y": 162.66081324653166
            },
            "positionAbsolute": {
              "x": 231.17453176754782,
              "y": 123.02661106951555
            },
            "selected": false,
            "sourcePosition": "right",
            "targetPosition": "left",
            "type": "retrievalNode",
            "width": 200
          },
          {
            "data": {
              "form": {
                "empty_response": "Nothing found in DB-Description!",
                "kb_ids": [],
                "keywords_similarity_weight": 0.3,
                "query": [
                  {
                    "component_id": "Answer:SocialAdsWonder",
                    "type": "reference"
                  }
                ],
                "similarity_threshold": 0.2,
                "top_n": 8
              },
              "label": "Retrieval",
              "name": "DB Description"
            },
            "dragging": false,
            "height": 106,
            "id": "Retrieval:OddSingersRefuse",
            "measured": {
              "height": 106,
              "width": 200
            },
            "position": {
              "x": 284.5720579655624,
              "y": 246.75395940479467
            },
            "positionAbsolute": {
              "x": 267.7575479510707,
              "y": 249.15603226400776
            },
            "selected": false,
            "sourcePosition": "right",
            "targetPosition": "left",
            "type": "retrievalNode",
            "width": 200
          },
          {
            "data": {
              "form": {
                "text": "Based on the result of the SQL execution, returns the error message to the large model if any errors occur; otherwise, returns the result to the user."
              },
              "label": "Note",
              "name": "N: Analyze SQL"
            },
            "dragHandle": ".note-drag-handle",
            "dragging": false,
            "height": 165,
            "id": "Note:HeavyIconsFollow",
            "measured": {
              "height": 165,
              "width": 347
            },
            "position": {
              "x": -709.8631299685773,
              "y": 96.50319908555313
            },
            "positionAbsolute": {
              "x": -626.6563777191027,
              "y": -48.82220889683933
            },
            "resizing": false,
            "selected": false,
            "sourcePosition": "right",
            "style": {
              "height": 176,
              "width": 266
            },
            "targetPosition": "left",
            "type": "noteNode",
            "width": 347
          },
          {
            "data": {
              "form": {
                "text": "Receives the user's database-related questions and displays the large model's response."
              },
              "label": "Note",
              "name": "N: Interface"
            },
            "dragHandle": ".note-drag-handle",
            "dragging": false,
            "height": 159,
            "id": "Note:PinkTaxesClean",
            "measured": {
              "height": 159,
              "width": 259
            },
            "position": {
              "x": -253.39933811515345,
              "y": 353.7538896054877
            },
            "positionAbsolute": {
              "x": -52.004609812312424,
              "y": 336.95180237635077
            },
            "resizing": false,
            "selected": false,
            "sourcePosition": "right",
            "style": {
              "height": 162,
              "width": 210
            },
            "targetPosition": "left",
            "type": "noteNode",
            "width": 259
          },
          {
            "data": {
              "form": {
                "text": "Searches for description about meanings of  tables and fields."
              },
              "label": "Note",
              "name": "N:DB Description"
            },
            "dragHandle": ".note-drag-handle",
            "dragging": false,
            "height": 128,
            "id": "Note:IcyTreesPeel",
            "measured": {
              "height": 128,
              "width": 251
            },
            "position": {
              "x": 280.8431980571563,
              "y": 394.1463067004627
            },
            "positionAbsolute": {
              "x": 280.8431980571563,
              "y": 394.1463067004627
            },
            "resizing": false,
            "selected": false,
            "sourcePosition": "right",
            "style": {
              "height": 128,
              "width": 251
            },
            "targetPosition": "left",
            "type": "noteNode",
            "width": 251
          },
          {
            "data": {
              "form": {
                "text": "Searches for samples about question to SQL.\nPlease check this dataset: https://huggingface.co/datasets/InfiniFlow/text2sql"
              },
              "label": "Note",
              "name": "N: Q->SQL"
            },
            "dragHandle": ".note-drag-handle",
            "dragging": false,
            "height": 143,
            "id": "Note:HugeGroupsScream",
            "measured": {
              "height": 143,
              "width": 390
            },
            "position": {
              "x": 612.8793199038756,
              "y": 169.1868576959871
            },
            "positionAbsolute": {
              "x": 606.1206536213404,
              "y": 113.09441734894426
            },
            "resizing": false,
            "selected": false,
            "sourcePosition": "right",
            "style": {
              "height": 131,
              "width": 387
            },
            "targetPosition": "left",
            "type": "noteNode",
            "width": 390
          },
          {
            "data": {
              "form": {
                "text": "DDL(Data Definition Language).\n\nSearches for relevant database creation statements.\n\nIt should bind with a KB to which DDL is dumped in.\nYou could use  'General' as parsing method and ';' as delimiter."
              },
              "label": "Note",
              "name": "N: DDL"
            },
            "dragHandle": ".note-drag-handle",
            "dragging": false,
            "height": 208,
            "id": "Note:GreenCrewsArrive",
            "measured": {
              "height": 208,
              "width": 467
            },
            "position": {
              "x": 649.3481710005742,
              "y": -87.70873445087781
            },
            "positionAbsolute": {
              "x": 545.3423934788841,
              "y": -166.58872868890683
            },
            "resizing": false,
            "selected": false,
            "sourcePosition": "right",
            "style": {
              "height": 266,
              "width": 266
            },
            "targetPosition": "left",
            "type": "noteNode",
            "width": 467
          },
          {
            "data": {
              "form": {
                "text": "The large model learns which tables may be available based on the responses from three knowledge bases and converts the user's input into SQL statements."
              },
              "label": "Note",
              "name": "N: Generate SQL"
            },
            "dragHandle": ".note-drag-handle",
            "dragging": false,
            "height": 196,
            "id": "Note:EightTurtlesLike",
            "measured": {
              "height": 196,
              "width": 341
            },
            "position": {
              "x": 134.0070839275931,
              "y": -345.41228234051727
            },
            "positionAbsolute": {
              "x": 222.2150747084395,
              "y": -445.32694170868734
            },
            "resizing": false,
            "selected": false,
            "sourcePosition": "right",
            "style": {
              "height": 175,
              "width": 265
            },
            "targetPosition": "left",
            "type": "noteNode",
            "width": 341
          },
          {
            "data": {
              "form": {
                "text": "Executes the SQL statement in the database and returns the result.\n\nAfter configuring  an accessible database, press 'Test' to  ensure the accessibility.\n\nThe large model modifies the original SQL statement based on the error message and returns the modified SQL statement."
              },
              "label": "Note",
              "name": "N: Execute SQL"
            },
            "dragHandle": ".note-drag-handle",
            "dragging": false,
            "height": 276,
            "id": "Note:FreshKidsTalk",
            "measured": {
              "height": 276,
              "width": 336
            },
            "position": {
              "x": -304.3577648765364,
              "y": -288.054469323955
            },
            "positionAbsolute": {
              "x": -251.5866574377311,
              "y": -372.2192837064241
            },
            "resizing": false,
            "selected": false,
            "sourcePosition": "right",
            "style": {
              "height": 178,
              "width": 346
            },
            "targetPosition": "left",
            "type": "noteNode",
            "width": 336
          },
          {
            "data": {
              "form": {
                "database": "",
                "db_type": "mysql",
                "frequencyPenaltyEnabled": true,
                "frequency_penalty": 0.7,
                "host": "",
                "llm_id": "deepseek-chat@DeepSeek",
                "loop": 3,
                "maxTokensEnabled": true,
                "max_tokens": 512,
                "password": "",
                "port": 6630,
                "presencePenaltyEnabled": true,
                "presence_penalty": 0.4,
                "query": [],
                "temperature": 0.1,
                "temperatureEnabled": true,
                "topPEnabled": true,
                "top_n": 30,
                "top_p": 0.3,
                "username": "root"
              },
              "label": "ExeSQL",
              "name": "ExeSQL"
            },
            "dragging": false,
            "id": "ExeSQL:QuietRosesRun",
            "measured": {
              "height": 64,
              "width": 200
            },
            "position": {
              "x": -318.61920731731163,
              "y": 3.5145731711609436
            },
            "selected": false,
            "sourcePosition": "right",
            "targetPosition": "left",
            "type": "ragNode"
          },
          {
            "data": {
              "form": {
                "frequencyPenaltyEnabled": true,
                "frequency_penalty": 0.7,
                "llm_id": "deepseek-chat@DeepSeek",
                "maxTokensEnabled": true,
                "max_tokens": 256,
                "message_history_window_size": 6,
                "parameter": "Precise",
                "presencePenaltyEnabled": true,
                "presence_penalty": 0.4,
                "temperature": 0.1,
                "temperatureEnabled": true,
                "topPEnabled": true,
                "top_p": 0.3
              },
              "label": "RewriteQuestion",
              "name": "RefineQuestion"
            },
            "dragging": false,
            "id": "RewriteQuestion:WildIdeasTell",
            "measured": {
              "height": 106,
              "width": 200
            },
            "position": {
              "x": -7.734116293705583,
              "y": 236.92372325779243
            },
            "selected": false,
            "sourcePosition": "right",
            "targetPosition": "left",
            "type": "rewriteNode"
          },
          {
            "data": {
              "form": {
                "cite": false,
                "frequencyPenaltyEnabled": true,
                "frequency_penalty": 0.7,
                "llm_id": "deepseek-chat@DeepSeek",
                "maxTokensEnabled": false,
                "max_tokens": 256,
                "message_history_window_size": 1,
                "parameter": "Precise",
                "parameters": [],
                "presencePenaltyEnabled": true,
                "presence_penalty": 0.4,
                "prompt": "\n##The user provides a question and you provide SQL. You will only respond with SQL code and not with any explanations.\n\n##You may use the following DDL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {Retrieval:SillyPartsCheer}.\n\n##You may use the following documentation as a reference for what tables might be available. Use responses to past questions also to guide you: {Retrieval:OddSingersRefuse}.\n\n##You may use the following SQL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {Retrieval:BrownStreetsRhyme}.\n\n##Respond with only SQL code. Do not answer with any explanations -- just the code.",
                "temperature": 0.1,
                "temperatureEnabled": true,
                "topPEnabled": true,
                "top_p": 0.3
              },
              "label": "Generate",
              "name": "Generate SQL Statement LLM"
            },
            "dragging": false,
            "id": "Generate:BlueShirtsLaugh",
            "measured": {
              "height": 106,
              "width": 200
            },
            "position": {
              "x": 147.62383788095065,
              "y": -116.47462293167156
            },
            "selected": false,
            "sourcePosition": "right",
            "targetPosition": "left",
            "type": "generateNode"
          }
        ]
      },
      "history": [],
      "messages": [],
      "path": [],
      "reference": []
    },
  "avatar": "data:image/png;base64,[encoded data, 29608 characters]"
}
