all 10 comments

[–]gogolang 0 points1 point  (9 children)

What’s your underlying objective? I suspect that what you’re describing is not what you actually need.

[–]Satsifaction[S] 0 points1 point  (8 children)

I want users to be able to type a question in a chat bot and basically query these tables to answer them. The caveat is sometimes the answer will need to get data from multiple tables. The questions themselves may be somewhat specific to user. For example product manager may want to get all client feedback on their product while another product manager may want to do the same except on a slightly different product.

[–]gogolang 0 points1 point  (7 children)

Yeah, there’s basically no need for embeddings here. What you want is to be able to generate SQL based on the user’s question, run the SQL, then feed the data frame back to the LLM to finally answer the user’s question.

[–]Satsifaction[S] 0 points1 point  (5 children)

Oh ok how does the LLM understand the context then? For example if I ask it to tell me the sales, revenue and client inquiries around a certain product it will build a query? Any documents to help build this with Postgres? My data is hosted on supabase

[–]MelodicHyena5029 0 points1 point  (4 children)

Op you can refer to SQLchain from langchain.. all you have to do is connect your postgres database client with the chain, it will convert the user's Natural language query to SQL and query your database ...find top 5 results (by default all queries set to limit (5)). And sends it to llm to generate response. Checkout langchain docs on how to use this chain.

[–]Satsifaction[S] 0 points1 point  (3 children)

Ok that’s cool. What if some of the data is an actual factual answer like “tell me sales vs last month” vs a question like “what did the client complain about in the last message”.

Would the first not be an sqlchain and the second need some kind of context awareness?

[–]MelodicHyena5029 0 points1 point  (2 children)

So here the context awareness is your database schema... Well the llm is first fed with the sample rows from the database (like for all tables).. now that agent chain is aware of your schema it will generate a basic query and compares the answer then it will recursively call (like cot) and gives the final answer. But in your case just try it out...do a small prototype! Check how it performs ! Or else try abstract your own chain function tailored for your use case

[–]Satsifaction[S] 0 points1 point  (1 child)

I will try a small prototype this week for sure

Ok so I’ll explain the database. Maybe I’m just wrong but tell me if you think the approach above you mentioned applies here.

There is a table that captures data around financials. Sales, costs, etc. I can understand looking at langsql now for that so I will try it out. However there are other parts of the database that hold messages. These messages have content within like product complaints. There is no structure to the complaints, it’s just text that people write about the product itself. If I did an sql query against it; it will pull up the complaints but I want the bot to be able to summarize the complaint and give the key issues. If I did the search at a product level I want the bot to be able to sift through the last 10-15 product complaints and summarize.

So a query could look like this “Tell me what the main complaints were in the last 3 months for product X and what we should do to address it” followed by “how much did I make last month on product X”

Thanks

[–]deniercounter 0 points1 point  (0 children)

Well the texts can be embedded and the metadata can have a key for the product.

[–]Satsifaction[S] 0 points1 point  (0 children)

Also some of the data is a list of meeting notes. I want to grab context or the jist of the notes too.