Find answers from the community

a
aldrin
Offline, last seen 3 months ago
Joined September 25, 2024
Is it possible to give column level context to help refine querying on databases with many columns?
1 comment
a
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?
1 comment
a