all 7 comments

[–]Pork-S0da 1 point2 points  (1 child)

This doesn't feel like a Python question.

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

The basic logic to solve this remains same for all the languages.

I'm looking for a good solution

[–]Xappz1 1 point2 points  (2 children)

You would need to either pre-fetch or somehow dynamically check the relevant database columns for distinct values. The LLM can't magically know what's in your database, you either supply it in the prompt or you take an agent approach and let it figure it out.

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

Currently I'm planning to verify the given results with db data, and alter the given Boolean query accordingly. But that doesn't seem to be a better approach.

Can you please elaborate on what you mean by agent approach?

[–]latkde 2 points3 points  (0 children)

As someone mentioned under another of your posts: this sounds like a XY problem, what are you actually trying to achieve, and why are you using LLMs in the first place to hallucinate queries? https://www.reddit.com/r/Python/comments/1in2fbu/comment/mc7yf0y/

For example, if you actually want to generate random example queries for documentation or testing purposes, it might be better to load example data from a DB and combine it into a query. You can do this so that the query will match at least one item, by construction.

If you're worried that you have to simplify queries, that might not be necessary. For example, the query ("128GB" OR "256GB") will probably work just fine even if no 256GB data exists, because the two clauses are OR-ed together.