{"id":9480,"date":"2025-11-11T16:43:12","date_gmt":"2025-11-11T08:43:12","guid":{"rendered":"\/?p=9480"},"modified":"2025-11-11T16:43:12","modified_gmt":"2025-11-11T08:43:12","slug":"text2sql-nl2sql%ef%bc%88%e4%b8%89%ef%bc%89%e5%bc%80%e6%ba%90%e9%a1%b9%e7%9b%ae%e6%80%8e%e4%b9%88%e9%80%89%ef%bc%9atalk-is-cheap-show-me-the-code","status":"publish","type":"post","link":"\/?p=9480","title":{"rendered":"Text2SQL \/ NL2SQL\uff08\u4e09\uff09\u5f00\u6e90\u9879\u76ee\u600e\u4e48\u9009\uff1atalk is cheap, show me the code!"},"content":{"rendered":"<h2>\u6f14\u793a<\/h2>\n<p>\u8fd9\u662f\u7cfb\u5217\u6587\u7ae0\u7684\u7b2c\u4e09\u7bc7\uff0c\u4e4b\u524d\u5199\u4e86 Text2SQL \u7684\u6838\u5fc3\u5e94\u7528\u65b9\u5f0f\u548c\u4e1a\u5185\u516c\u8ba4\u7684<strong>\u6570\u636e\u96c6<\/strong>\u3001\u5f53\u4e0b SOTA \u7684 LLM-based \u7684\u5b9e\u73b0\u65b9\u5f0f\u548c\u8036\u9c81\u5927\u5b66 2024 \u5e74\u6570\u636e\u96c6 <strong>Spider 2\uff0c\u6392\u884c\u699c TOP1 \u7684<\/strong>\u5b9e\u73b0\uff1a<\/p>\n<p>\u672c\u7bc7\u4ecb\u7ecd <strong>5<\/strong> \u4e2a\u5f00\u6e90\u9879\u76ee\uff1atalk is cheap, show me the code!<\/p>\n<p>\u9762\u5bf9\u6d69\u7e41\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u5982\u4f55\u6839\u636e\u9700\u8981\u9009\u62e9\u9002\u5408\u81ea\u5df1\u7684\uff0c\u8bf7\u63a5\u7740\u5f80\u4e0b\u770b\u3002\u7ed3\u8bba\u8bf7\u76f4\u63a5\u8df3\u5230\u6700\u540e\u4e00\u7ae0\u3002<\/p>\n<p><strong>\u8001\u89c4\u77e9\uff0c\u5148\u770b\u6548\u679c<\/strong><\/p>\n<p>\u4e0b\u9762\u7684 demo \u6765\u81ea\u8bd5\u7528\u7684 SuperSonic\uff0c\u5c06\u4f1a\u5728\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640.gif\" alt=\"\u56fe\u7247\" \/><\/p>\n<h2><strong>\u5927\u6a21\u578b\u65f6\u4ee3 Text-to-SQL \u7279\u70b9<\/strong><\/h2>\n<p>\u968f\u7740\u57fa\u4e8e LLM \u6280\u672f\u7684\u53d1\u5c55\uff0cRAG \/ AI Agent \/ Fine-tuning \u7b49\u65b9\u6cd5\u4e5f\u5e7f\u6cdb\u5e94\u7528\u4e8e Text-to-SQL \u9886\u57df\uff0c\u5927\u6a21\u578b\u65f6\u4ee3\u53d1\u5c55\u51fa\u5982\u4e0b\u7279\u70b9\uff1a<\/p>\n<ul>\n<li><strong>\u5e73\u53f0\u5316<\/strong><\/li>\n<\/ul>\n<p>\u63d0\u9ad8\u517c\u5bb9\u6027\uff0c\u4fbf\u4e8e\u63a5\u5165\u5176\u4ed6\u4ea7\u54c1\uff0c\u751f\u4ea7\u73af\u5883\u4e0b\uff0c\u4e0d\u540c\u4ea7\u54c1 schema \u5b9a\u4e49\u4e0d\u4e00\u6837\uff0c\u751a\u81f3\u7528\u7684\u6570\u636e\u5e93\u90fd\u4e0d\u4e00\u6837\uff0c\u6bd4\u5982\uff1amysql \/ postgressql \/ nosql ...\uff0c\u5c31\u8981\u6c42\u5177\u6709\u5e73\u53f0\u7684\u517c\u5bb9\u7279\u70b9<\/p>\n<ul>\n<li><strong>\u63d2\u4ef6\u5316<\/strong><\/li>\n<\/ul>\n<p>\u63d0\u9ad8\u6269\u5c55\u6027\uff0c\u4fbf\u4e8e\u529f\u80fd\u6269\u5c55\uff0c\u5982\uff1a<\/p>\n<p>\u63d0\u4f9b\u8bb0\u5fc6\u529f\u80fd\uff0c\u7f13\u5b58\u7528\u6237\u95ee\u9898\uff0c\u63d0\u9ad8\u54cd\u5e94\u901f\u5ea6\uff1b<\/p>\n<p>\u63d0\u4f9b tools \u8c03\u7528\u529f\u80fd\uff0c\u7528\u4e8e\u8fd4\u56de\u6570\u636e\u7684\u540e\u5904\u7406\uff08LLM\u7684\u6570\u636e\u8ba1\u7b97\u80fd\u529b\uff0c\u4e00\u76f4\u662f\u9650\u5236\u4ea7\u4e1a\u8bd5\u7528\u7684\u77ed\u677f\uff09\uff1b<\/p>\n<p>\u63d0\u4f9b\u7ed3\u679c\u6e32\u67d3\u529f\u80fd\uff0c\u751f\u6210\u8868\u683c\uff0c\u56fe\u7247\uff0c\u62a5\u544a\uff0cmarkdown<\/p>\n<ul>\n<li><strong>\u81ea\u6211\u8fdb\u5316<\/strong><\/li>\n<\/ul>\n<p>\u8bc4\u6d4b -&gt; \u53cd\u9988 -&gt; \u4f18\u5316\uff0c\u5f62\u6210\u95ed\u73af\uff0c\u4e0d\u65ad<strong>\u4e30\u5bcc\u6570\u636e\u96c6<\/strong>\uff0c\u63d0\u9ad8\u51c6\u786e\u6027\u3002text2sql \u672c\u8d28\u662f\u6570\u636e\u4ea7\u54c1\uff0c\u9ad8\u8d28\u91cf\u7684\u6570\u636e\u96c6\u51b3\u5b9a\u4e86\u9879\u76ee\u6210\u529f\u4e0e\u5426<\/p>\n<ul>\n<li>\u6210\u672c\u63a7\u5236<\/li>\n<\/ul>\n<p>\u5927\u6a21\u578b\u8c03\u7528\u6309\u7167 token \u6570\u91cf\u7b97\u94b1\uff0c\u672c\u5730\u90e8\u7f72\u4e5f\u9700\u8981\u5360\u7528\u7b97\u529b\u8d44\u6e90\uff0c\u56e0\u6b64\u5982\u4f55\u4f18\u5316 prompt template\uff0c\u964d\u4f4e\u6210\u672c\uff0c\u4e5f\u662f\u5fc5\u987b\u8003\u8651\u7684\u56e0\u7d20<\/p>\n<h2><strong>\u5f00\u6e90\u9879\u76ee\u8be6\u7ec6\u4ecb\u7ecd<\/strong><\/h2>\n<p>\u501f\u52a9\u8fd9\u4e9b\u5f00\u6e90\u9879\u76ee\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5feb\u901f\u6784\u5efa\u51fa demo\uff0c\u5bf9\u65b9\u6848\u9a8c\u8bc1\u5f88\u6709\u4f5c\u7528\u3002\u8fd9\u4e9b\u5f00\u6e90\u9879\u76ee\uff0c\u5927\u591a\u80fd\u65b9\u4fbf\u5bfc\u5165\u81ea\u5df1\u7684\u6570\u636e\u5e93\u914d\u7f6e\uff0c\u800c\u4e14\u53ef\u4ee5\u672c\u5730\u5316\u90e8\u7f72\uff0c\u4fdd\u8bc1\u6570\u636e\u5b89\u5168\uff1b\u540c\u65f6\u8fd8\u80fd\u914d\u7f6e\u4e0d\u540c\u7684 LLM\uff0c\u8ba9\u7cfb\u7edf\u80fd\u529b\u4e0e\u65f6\u4ff1\u8fdb\uff0c\u6bd4\u5982\u53ef\u4ee5\u63a5\u5165\u5f53\u4e0b\u80fd\u529b\u5f88\u5f3a\u7684 claude-3.7\uff0copenai-o1\uff0cdeepseek-r1 ...<\/p>\n<p>\u7edf\u8ba1\u65f6\u95f4\uff1a2025.03.14<\/p>\n<table>\n<thead>\n<tr>\n<th>\u9879\u76ee\u540d\u79f0<\/th>\n<th>\u94fe\u63a5<\/th>\n<th>githubstar<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>DB-GPT<\/td>\n<td><a href=\"https:\/\/github.com\/eosphoros-ai\/DB-GPT\">https:\/\/github.com\/eosphoros-ai\/DB-GPT<\/a><\/td>\n<td>15.5k<\/td>\n<\/tr>\n<tr>\n<td>Vanna<\/td>\n<td><a href=\"https:\/\/github.com\/vanna-ai\/vanna\">https:\/\/github.com\/vanna-ai\/vanna<\/a><\/td>\n<td>14.1k<\/td>\n<\/tr>\n<tr>\n<td>SuperSonic<\/td>\n<td><a href=\"https:\/\/github.com\/tencentmusic\/supersonic\">https:\/\/github.com\/tencentmusic\/supersonic<\/a><\/td>\n<td>3.2k<\/td>\n<\/tr>\n<tr>\n<td>DB-GPT-hub<\/td>\n<td><a href=\"https:\/\/github.com\/eosphoros-ai\/DB-GPT-Hub\">https:\/\/github.com\/eosphoros-ai\/DB-GPT-Hub<\/a><\/td>\n<td>1.7k<\/td>\n<\/tr>\n<tr>\n<td>LangChain<\/td>\n<td><a href=\"https:\/\/python.langchain.com\/v0.1\/docs\/use_cases\/sql\/\">https:\/\/python.langchain.com\/v0.1\/docs\/use_cases\/sql\/<\/a><\/td>\n<td>-<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><strong>\ud83c\udfafDB-GPT &amp; DB-GPT-hub<\/strong><\/h3>\n<p><a href=\"https:\/\/github.com\/eosphoros-ai\/DB-GPT\">https:\/\/github.com\/eosphoros-ai\/DB-GPT<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/eosphoros-ai\/DB-GPT-Hub\">https:\/\/github.com\/eosphoros-ai\/DB-GPT-Hub<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/antvis\/GPT-Vis\">https:\/\/github.com\/antvis\/GPT-Vis<\/a><\/p>\n<p>AI Agent + RAG + Fine-tuning<\/p>\n<p>\u8bbe\u8ba1\u67b6\u6784\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251111163506595.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p>\u8c03\u7814\u7279\u70b9\u603b\u7ed3\uff1a<\/p>\n<ol>\n<li><strong>\u652f\u6301\u5fae\u8c03\uff08fine-tuning\uff09<\/strong><\/li>\n<\/ol>\n<p>\u5fae\u8c03\u652f\u6301\u7684\u6a21\u578b\uff1aLLaMA\u3001LLaMA-2\u3001BLOOM\u3001BLOOMZ\u3001Falcon\u3001Baichuan\u3001Baichuan2\u3001InternLM\u3001Qwen\u3001XVERSE\u3001ChatGLM2<\/p>\n<p>\u652f\u6301\u7684\u5fae\u8c03\u6280\u672f\uff1aLoRA \/ QLoRA \/ Pturning<\/p>\n<ol start=\"2\">\n<li>\n<p>\u6709 UI \u754c\u9762\uff0c\u5982\u4e0b\u56fe\uff1a\u7528 streamlit \u5b9e\u73b0\uff08\u987a\u5e26\u8bf4\u4e00\u4e0b\uff0cstreamlit \u662f\u7eaf python \u7684 web \u795e\u5668\uff0c\u975e\u5e38\u9002\u5408\u6570\u636e\u9879\u76ee\u548c LLM \u9879\u76ee\u8bd5\u7528\uff09\uff1a<\/p>\n<p><a href=\"https:\/\/github.com\/antvis\/GPT-Vis\">https:\/\/github.com\/antvis\/GPT-Vis<\/a><\/p>\n<\/li>\n<\/ol>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640.jpeg\" alt=\"\u56fe\u7247\" \/><\/p>\n<ol start=\"3\">\n<li>\u652f\u6301\u7684\u63a8\u7406\u6a21\u578b\u5f88\u65b0\uff0cQwen2.5 \/ Deepseek \u90fd\u652f\u6301<\/li>\n<li>Monitor \u7cfb\u7edf\u5b8c\u5907<\/li>\n<li>DB-GPT-Hub \u652f\u6301\u5fae\u8c03 GQL\uff08\u56fe\u6570\u636e\u5e93\u67e5\u8be2\uff09<\/li>\n<li>\u6ca1\u6709\u63d0\u4f9b\u6570\u636e\u5e93\u63a5\u5165\uff0c\u9700\u8981\u81ea\u5df1\u52a0<\/li>\n<\/ol>\n<h3><strong>\ud83c\udfafVanna<\/strong><\/h3>\n<p><a href=\"https:\/\/github.com\/vanna-ai\/vanna\">https:\/\/github.com\/vanna-ai\/vanna<\/a><\/p>\n<p><a href=\"https:\/\/vanna.ai\/\">https:\/\/vanna.ai\/<\/a><\/p>\n<p><a href=\"https:\/\/vanna.ai\/docs\/postgres-openai-standard-chromadb\/\">https:\/\/vanna.ai\/docs\/postgres-openai-standard-chromadb\/<\/a><\/p>\n<p>AI Agent + RAG<\/p>\n<p>\u63d0\u4f9b pip \u5305\u5b89\u88c5\uff1a<a href=\"https:\/\/pypi.org\/project\/vanna\/\">https:\/\/pypi.org\/project\/vanna\/<\/a><\/p>\n<p>\u4e0b\u9762\u662f\u8bbe\u8ba1\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251111163506684.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p>\u8bd5\u7528\u540e\u7279\u70b9\u603b\u7ed3\uff1a<\/p>\n<ol>\n<li>\u81ea\u5e26 UI \u754c\u9762<\/li>\n<li>\u53ef\u4ee5\u5411\u7cfb\u7edf\u8f93\u5165\u81ea\u5df1\u7684 DDL \u8bed\u53e5 \/ \u9644\u52a0\u4fe1\u606f \/ sql\u8bed\u53e5\uff0cvn.train<\/li>\n<\/ol>\n<pre><code class=\"language-python\">from vanna.openai import OpenAI_Chat\nfrom vanna.chromadb import ChromaDB_VectorStore\nclass MyVanna(ChromaDB_VectorStore, OpenAI_Chat):\n    def __init__(self, config=None): \n        ChromaDB_VectorStore.__init__(self, config=config) \n        OpenAI_Chat.__init__(self, config=config)\nvn = MyVanna(config={&#039;api_key&#039;: &#039;sk-...&#039;, &#039;model&#039;: &#039;gpt-4-...&#039;})<\/code><\/pre>\n<pre><code class=\"language-python\"># \u6dfb\u52a0\u8bad\u7ec3\u6570\u636e\u7684\u793a\u4f8b\n# DDL \u8bed\u53e5\u529f\u80fd\u5f3a\u5927\uff0c\u56e0\u4e3a\u5b83\u4eec\u6307\u5b9a\u4e86\u8868\u540d\u3001\u5217\u540d\u3001\u6570\u636e\u7c7b\u578b\uff0c\u8fd8\u53ef\u80fd\u6307\u5b9a\u4e86\u5173\u7cfb\u3002\nvn.train(ddl=&quot;&quot;&quot;\nCREATE TABLE IF NOT EXISTS my-table (\nid INT PRIMARY KEY,\nname VARCHAR(100),\nage INT)\n&quot;&quot;&quot;)\n# \u6dfb\u52a0\u5173\u4e8e\u4e1a\u52a1\u672f\u8bed\u6216\u5b9a\u4e49\u7684\u6587\u6863\u8bf4\u660e\u3002\nvn.train(documentation=&quot;Our business defines OTIF score as the percentage of orders that are delivered on time and in full&quot;)\n# \u5c06 SQL \u67e5\u8be2\u6dfb\u52a0\u5230\u8bad\u7ec3\u6570\u636evn.train\n(sql=&quot;SELECT * FROM my-table WHERE name = &#039;John Doe&#039;&quot;)<\/code><\/pre>\n<ol start=\"3\">\n<li>\u652f\u6301\u7684\u6570\u636e\u5e93\u66f4\u591a<\/li>\n<\/ol>\n<p>PostgreSQL\u3001MySQL\u3001PrestoDB\u3001Apache Hive\u3001ClickHouse\u3001Snowflake\u3001Oracle\u3001Microsoft SQL Server\u3001BigQuery\u3001SQLite\u3001DuckDB<\/p>\n<h3><strong>\ud83c\udfafSuperSonic<\/strong><\/h3>\n<p><a href=\"https:\/\/github.com\/tencentmusic\/supersonic\">https:\/\/github.com\/tencentmusic\/supersonic<\/a><\/p>\n<p><a href=\"https:\/\/supersonicbi.github.io\/\">https:\/\/supersonicbi.github.io\/<\/a><\/p>\n<p>AI Agent + RAG<\/p>\n<p>\u8bd5\u7528\uff1a<a href=\"http:\/\/117.72.46.148:9080\">http:\/\/117.72.46.148:9080<\/a><\/p>\n<p>\u8bd5\u7528\u540e\u7684\u4f53\u4f1a\uff1a\u529f\u80fd\u591a\uff1b\u4e14\u652f\u6301\u63d2\u4ef6\u914d\u7f6e\uff0c\u65b9\u4fbf\u80fd\u529b\u6269\u5c55<\/p>\n<p><video data-v-0d691a30=\"\" src=\"https:\/\/mpvideo.qpic.cn\/0bc3wmackaaa5ualnq6rn5tvbm6dewzqajia.f10002.mp4?dis_k=74cdb443fd97f46bf011ad7dab50b0f2&amp;dis_t=1762850082&amp;play_scene=10110&amp;auth_info=Lp73sqkAPaGq9jUUk8yOrQ5ZEDg7Tm4wH2sYVCYkQV0WPSQxWykfEmFFFUEyV0ZvbxopNy8Y&amp;auth_key=e99927d2af5ecc3c9792ee58d32f298d&amp;vid=wxv_3895597876625506323&amp;format_id=10002&amp;support_redirect=1&amp;mmversion=7.0.20.1781\" poster=\"http:\/\/mmbiz.qpic.cn\/sz_mmbiz_jpg\/0s2RLufxO2NeH6CLYMlUMNJYKK7icafRYJjOQNdHMnJEic0gWOgNZGSv3nupImO8TvOvrKB5frCWfKfbEtlpkicjw\/0?wx_fmt=jpeg&amp;wxfrom=16\" webkit-playsinline=\"isiPhoneShowPlaysinline\" playsinline=\"isiPhoneShowPlaysinline\" preload=\"metadata\" crossorigin=\"anonymous\" controlslist=\"nodownload\" class=\"\" style=\"display: block; width: 673px; height: 505px;\"> \u60a8\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301 video \u6807\u7b7e <\/video><\/p>\n<p>\u7279\u70b9\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u652f\u6301\u4e2d\u6587\uff0c<\/strong>\u8fd9\u53ef\u80fd\u662f\u76ee\u524d\u72ec\u6709\u7684\u7279\u70b9\u4e86<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u914d\u7f6e\u81ea\u5b9a\u4e49\u6570\u636e\u96c6<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301 tools \u8c03\u7528\uff1a\u7c7b\u4f3c\u63d0\u4f9b\u4e86 AI Agent \u80fd\u529b\u3002\u5177\u4f53\u6765\u8bf4<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\u4efb\u610f\u4e00\u4e2a\u7f51\u9875, \u53ef\u4ee5\u662f\u4e00\u4e2a\u770b\u677f, \u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u89e3\u8bfb\u62a5\u544a, \u53ec\u56de\u4e4b\u540e\u53ef\u4ee5\u628a\u8fd9\u4e2a\u7f51\u9875\u6e32\u67d3\u5230\u95ee\u7b54\u4f1a\u8bdd\u5217\u8868<\/li>\n<li>\u4e5f\u53ef\u4ee5\u4e3a\u4efb\u610f\u4e00\u4e2aHTTP\u670d\u52a1\u94fe\u63a5<\/li>\n<\/ul>\n<p>\u6bd4\u5982\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251111163508555.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<ol start=\"4\">\n<li>\u652f\u6301\u7684\u6570\u636e\u5e93\u7c7b\u578b\uff1a\u6240\u6709\u652f\u6301MySQL\u534f\u8bae\u7684\u6570\u636e\u5e93\uff0c\u5982MySQL\uff0cDoris\uff0cStarRocks\u7b49\uff1b\u53e6\u5916\u8fd8\u6709 Clickhouse\uff0cPostgreSQL\uff0cH2<\/li>\n<li>\u652f\u6301<strong>\u5728\u6570\u636e\u5e93\u8868\u4e0a\u521b\u5efa\u62bd\u8c61\u5c42<\/strong>\uff1a\u7ef4\u5ea6 \/ \u5ea6\u91cf \/ \u6307\u6807<\/li>\n<\/ol>\n<p><a href=\"https:\/\/supersonicbi.github.io\/docs\/headless-bi\/%E6%A6%82%E5%BF%B5\/\">https:\/\/supersonicbi.github.io\/docs\/headless-bi\/%E6%A6%82%E5%BF%B5\/<\/a><\/p>\n<ol start=\"6\">\n<li>\u8fd8\u6709\u4e00\u4e2a\u91cd\u8981\u529f\u80fd\uff1a<strong>\u672f\u8bed\u7ba1\u7406<\/strong>\uff0c\u7528\u4e8e\u6307\u4ee3\u81ea\u5b9a\u4e49\u77e5\u8bc6\uff0c\u901a\u8fc7\u914d\u7f6e\u672f\u8bed\u53ca\u5176\u63cf\u8ff0\uff0c\u5c31\u53ef\u4ee5\u628a\u79c1\u57df\u77e5\u8bc6\u4f20\u6388\u7ed9\u5927\u6a21\u578b\u3002\u6bd4\u5982\uff1a\u5bf9\u4e0d\u540c\u4ea7\u54c1\uff0c\u8fd1\u671f\u7684\u6982\u5ff5\u4e0d\u4e00\u6837\uff0c\u5c31\u53ef\u4ee5\u5728\u6b64\u5904\u660e\u786e\uff1a<\/li>\n<\/ol>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251111163508590.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<h3><strong>\ud83c\udfafLangChain<\/strong><\/h3>\n<p><a href=\"https:\/\/python.langchain.com\/v0.1\/docs\/use_cases\/sql\/\">https:\/\/python.langchain.com\/v0.1\/docs\/use_cases\/sql\/<\/a><\/p>\n<p>AI Agent + RAG<\/p>\n<ol>\n<li>\u6ca1\u6709 UI \u9875\u9762\uff0c\u9700\u8981\u81ea\u5df1\u5199<\/li>\n<li>\u5185\u7f6e create_sql_query_chain \u65b9\u4fbf\u8c03\u7528\uff1a<a href=\"https:\/\/api.python.langchain.com\/en\/latest\/chains\/langchain.chains.sql_database.query.create_sql_query_chain.html\">https:\/\/api.python.langchain.com\/en\/latest\/chains\/langchain.chains.sql_database.query.create_sql_query_chain.html<\/a><\/li>\n<\/ol>\n<pre><code class=\"language-python\">from langchain.chains import create_sql_query_chain\nfrom langchain_openai import ChatOpenAI\nllm = ChatOpenAI(model=&quot;gpt-3.5-turbo&quot;, temperature=0)\nchain = create_sql_query_chain(llm, db)\nresponse = chain.invoke({&quot;question&quot;: &quot;How many employees are there&quot;})response<\/code><\/pre>\n<ol start=\"3\">\n<li>\u65b9\u4fbf\u4f7f\u7528 Langchain \u81ea\u5df1\u7684\u80fd\u529b\uff0c\u5f15\u5165 tools \u7b49<\/li>\n<li>\u4e5f\u652f\u6301\u5bfc\u5165 CSV\uff0c\u7c7b\u4f3c text2sql \u4e00\u6837\u4ea4\u6d41\uff1a<a href=\"https:\/\/python.langchain.com\/v0.1\/docs\/use_cases\/sql\/csv\/\">https:\/\/python.langchain.com\/v0.1\/docs\/use_cases\/sql\/csv\/<\/a><\/li>\n<\/ol>\n<h2><strong>\u603b\u7ed3<\/strong><\/h2>\n<p>DB-GPT \u5f88\u5168\u9762\uff0c\u6709 AI Agent\u3001RAG\u3001\u5fae\u8c03\u3001UI\uff0c\u5982\u679c\u65f6\u95f4\u5145\u8db3\uff0c\u60f3\u6df1\u5165\u7814\u7a76\uff0c\u7528\u5404\u79cd\u6280\u672f\u63d0\u9ad8\u51c6\u786e\u7387\uff0c\u9009\u5b83\u6ca1\u9519\uff1b\u5982\u679c\u8ffd\u6c42\u63d2\u4ef6\u5316\uff0c\u4e14\u662f\u4e2d\u6587\u573a\uff0c\u9700\u8981\u5f88\u5feb\u5b9e\u73b0\u5e26 UI \u754c\u9762\u6f14\u793a\uff0c\u5c31\u9009\u62e9 SuperSonic\uff1b\u5982\u679c\u6570\u636e\u5e93\u7279\u6b8a\uff0c\u5982\uff1asnokeflake\uff0c\u5c31\u7528 vanna\uff1b\u5982\u679c\u9700\u8981\u628a text2sql \u4f5c\u4e3a\u4e00\u9879\u9644\u52a0\u529f\u80fd\u96c6\u6210\u5230\u5176\u4ed6 AI \u5e73\u53f0\uff0c\u5efa\u8bae\u9009\u62e9 LangChain\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6f14\u793a \u8fd9\u662f\u7cfb\u5217\u6587\u7ae0\u7684\u7b2c\u4e09\u7bc7\uff0c\u4e4b\u524d\u5199\u4e86 Text2SQL \u7684\u6838\u5fc3\u5e94\u7528\u65b9\u5f0f\u548c\u4e1a\u5185\u516c\u8ba4\u7684\u6570\u636e\u96c6\u3001\u5f53\u4e0b SOTA \u7684 LLM-based \u7684\u5b9e\u73b0   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[288],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9480"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9480"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9480\/revisions"}],"predecessor-version":[{"id":9481,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9480\/revisions\/9481"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9480"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}