What is the best way to use RAG and realtime database

I’m building a calendar application, where I want the user to ask a chatbot to perform actions and retrieve data.

Currently, I’m using function calling and gpt-3.5-turbo-1106, to pull data from my Firebase. I can get information on events and push new events as well.

This works fine but is starting to become limiting. It’s as if my data and the chatbot are disconnected so I cannot ask it certain types of questions. I also have to be specific with my database item names.

For example, I cannot ask my chatbot “Who is attending my Monday 3pm event?”. Even though I as a human can look into the database, see the 3pm event on Monday, and retrieve attendants.

As I was researching how to solve this, I learned about RAG and vector search. As well as services such as MongoDB Atlas Search and Pinecone.

So my idea is to vectorize my database, and make it semantically searchable and implement RAG.

My questions are:

Is this even the correct approach on how to solve this issue?

Does vector search work well with real-time databases, and would it be easily searchable?

Is this approach overkill, and is there a much simpler way to do this that I missed?

I hope I explained my problem and questions well. I’m still new to all this, so please let me know if I need to clarify anything.

Thanks.

In my opinion calendar functions can be handled just as easily by normal database search. You just need to convert that user inquiry into some search query for your database.

Inquiry

Who is attending my Monday 3pm event?

Sample SQL query

SELECT attendee_name
FROM Events
JOIN Attendees ON Events.event_id = Attendees.event_id
WHERE event_day = ‘Monday’ AND event_time = ‘15:00:00’ AND host_id = ‘your_user_id’;

6 Likes

I agree with @supershaneski.

I have created a bot not too long ago that seeks to retrieve relevant SQL database that is updated in real-time. Depending on the nature of the user question, the bot uses either a SQL query or semantic search to retrieve relevant information and then use the information to respond back to the user. The SQL retrieval works well in practice. Through function calling I have the bot identify the relevant inputs for the SQL query from the user question. It is also trained to ask clarifying questions back to the user in case critical information required for the query are missing in the initial question.

If you are looking to get the most accurate information back from a database, then this is a fairly solid approach. In principle, vector search works too but compared to a SQL query it may not return an exact match.

1 Like

Hi,
You can use SuperDuperDB
GitHub - superduperdb

This brings AI directly to your database.
This has out of box support of RAG with database in realtime

Thanks

1 Like

I agree with @supershaneski and @jr.2509

That particular question seems more suited to an SQL query than a semantic search query. SQL response will be far more precise. It sounds like you just need someone who’s good at Text-to-SQL to help your with your prompt/action calls.

I have written Text-to-SQL prompts, not using functions or actions. From what I have done so far I can say:

  1. clearly define your table and table fields.
  2. add descriptions, beyond the field names, of what they are and what they can do.
  3. Also add clear descriptions of questions that might be asked and the way they might be asked. For example, I have a log table with the field name “type”. “query” is a value that will be inserted into that field. I let the model know that when I use the term “queries”, I mean when the field “type” value = “query”.
2 Likes

I’ve looked into this. Sounds interesting, I still don’t understand exactly how it works.

How would it work in @godfinisher900 use case?