Canner / WrenAI

🚀 Open-source SQL AI Agent for Text-to-SQL. Make Text2SQL Easy! 🙌
https://getwren.ai/oss
GNU Affero General Public License v3.0
1.73k stars 155 forks source link

Feature(wren-ai-service): SQL Correction Refinement #411

Open imAsterSun opened 3 months ago

imAsterSun commented 3 months ago

Description

Currently, the invalid generation results are all processed in 1 prompt. Now we proposed a refinement plan to separate the correction into 2 detailed steps:

  1. Error Classification First, we pass the sql, the summary and the error message to LLM, let it analyzes the error message, and define the following additional attributes:
    • error_type: the error type of the invalid sql, currently we want it to identify 3 types of error table not found, column not found and others
    • error_point: identify which part of the sql is incorrect, currently, it will be the wrong table name or wrong column name.
    • Then we compare the error_point to the mdl, to see if the table/column is truly not existed. Record it as the mdl_check_result
  2. SQL Correction based on the Error Type After we attach 3 additional attributes to the original invalid results, the correction prompts will be generated according to the error_type of each invalid sql, then pass to LLM 1 by 1

Results

[TODO]