1

I would like to perform a query on a database using natural language. However, running direct queries is not possible, and I have to do it via an API. For that, given a sentence, I'd like to extract some custom entities from it.

For example, if the sentence is: "How many more than 20 years old male users viewed a page or logged in in the last 30 days?" The entities are:

<gender, equals, male>,
<age, greater than, 20>,
<event name, equals, view page>,
<event name, equals, login>,
<event timestamp, more than, 30 days>

The first element of each entity (triplet) comes from the list of columns The second element is inferred from context (nature of the operator if it's a single value or array to compare with) The third element is also inferred from the context and must belong to the chosen column (first element)

I'm not able to restrict either of these elements for the entity. I'd like an agent first to check all the columns that are available, choose one and view their unique values. Once it gets that, either choose that column (first element) and value (third element) or look again and repeat these steps.

Any help on this would be great! I'm using langchain for this but using any other approach is fine too.

theodre7
  • 125
  • 4

0 Answers0