huchenxucs / ChatDB

The official repository of "ChatDB: Augmenting LLMs with Databases as Their Symbolic Memory".
https://chatdatabase.github.io/
532 stars 46 forks source link

SQL error: execute() first #7

Open potong opened 1 year ago

potong commented 1 year ago

image

Prem95 commented 1 year ago

It means your database is not connected On Mon, 17 Jul 2023 at 6:14 PM, TianMin @.***> wrote:

[image: image] https://user-images.githubusercontent.com/10555409/253911188-a4906d0c-5071-45ee-869a-07c46d3c2f86.png

— Reply to this email directly, view it on GitHub https://github.com/huchenxucs/ChatDB/issues/7, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDKTMVPCQ47PC7XG3GYHQTXQUF6VANCNFSM6AAAAAA2MW4OJY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

potong commented 1 year ago

It means your database is not connected On Mon, 17 Jul 2023 at 6:14 PM, TianMin @.> wrote: [image: image] https://user-images.githubusercontent.com/10555409/253911188-a4906d0c-5071-45ee-869a-07c46d3c2f86.png — Reply to this email directly, view it on GitHub <#7>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDKTMVPCQ47PC7XG3GYHQTXQUF6VANCNFSM6AAAAAA2MW4OJY . You are receiving this because you are subscribed to this thread.Message ID: @.>

I see the problem here: image

Change the pattern to: pattern = r"Step(\d+):\s+(.?)\n(.)\n"

tom68-ll commented 1 year ago

Hello, author. We followed the advice and modified the pattern of the regular expression. However, this caused all the answers to the questions to include the phrase "not need memory". We suspect that there might still be an issue with the pattern here. @potong

ATX735 commented 1 year ago

I try to ask the question "What was the total revenue for January 2023?", The LLM generates the following middle-stage answer:

` ` `
Step1: Calculate the total revenue for January 2023
SELECT SUM(total_price) AS total_revenue
FROM sales
WHERE sale_date >= '2023-01-01' AND sale_date <= '2023-01-31';
` ` `

Notice that, the SQL is not surrounded by backtick `. Therefore, causing the regular expression pattern pattern = r"Step(\d+):\s+(.*?)\n(.*?)" fail to match the SQL, which induces this error. According to the prompt in this program, the LLM's output should look like the text that is shown below with the SQL surrounded by backtick `:

` ` `
Step1: Calculate the total revenue for January 2023
`SELECT SUM(total_price) AS total_revenue
FROM sales
WHERE sale_date >= '2023-01-01' AND sale_date <= '2023-01-31';`
` ` `
ZhengChen6 commented 1 year ago

image

image Just add "`" like this!