Find answers from the community

Updated 2 years ago

I m working with GPTSQLStructStoreIndex

I'm working with GPTSQLStructStoreIndex to review transaction data and have a chat interface which can answer questions about the data.

I've got a working version on my dataset but I'm finding Llamaindex defaults to essentially Text-to-SQL in nearly all cases when I'm looking to get both a natural language and SQL output like ChatGPT.

I've tried adding the custom LLM predictor but get errors from psycopg2

Plain Text
llm_predictor = LLMPredictor(llm=OpenAIChat(temperature=0, model_name="gpt-3.5-turbo"))


Plain Text
psycopg2.errors.SyntaxError: syntax error at or near "Answer"
LINE 2: Answer: The query will return the top 5 transactions by amou...


For example in the error above, I just asked the model to find and list the top 5 transactions by amount. The natural language response is correct but before we can run the SQL (which also looks correct) it errors out because the natural language input is passed to psycopg2 which is expecting SQL.

Any recommendation on how best to handle responses containing both natural language and SQL?
a
1 comment
Here's the output:

[SQL: SELECT * FROM transactions ORDER BY amount DESC LIMIT 5
Answer: The query will return the top 5 transactions by amount in descending order. The result will include all columns in the transactions table for those 5 transactions.]
Add a reply
Sign up and join the conversation on Discord