Which is better performing for ai chat app?

Which option is a better repeating group data source for an ai chat app?

1. do a search for messages where a messages chat session = current chat session.

or

2. current chat sessions list of messages

Do a search for messages

1 Like

Thanks @georgecollier! I trust your opinion so I’ll dig a bit here.

If immediate feedback to the user is the priority, would your answer be the same?

Bubble is usually quick w/ real time updates on do a search for but not all the time. When user presses send button on chat input - they need to immediately see it in the list. I’ve found this unreliable and slower on do a search.

Chat session’s list of messages is quicker and more reliable to update the repeating group. Here’s why I think:

  1. Faster: Bubble doesn’t have to query the database every time. The messages are already linked to the current chat session and loaded into memory, so it’s way more efficient.
  2. Lower WU units: “Do a search for…” hits your database API and counts toward your app’s capacity usage…I don’t care about cost for this question. But this also implies slower response.
  3. Live updates reliability: Bubble reliably updates the repeating group when new messages are added.

this feels like a @sudsy style performance question.

Depends where you’re creating the things (messages) too. But this is also something you can easily test

Things are created on front end. Here’e how:

user message: front end workflow for create message and add this message to chat sessions list of messages.

ai assistant messages: front end trigger to external llm api with streaming on, with API response a front end workflow to create message and add this message to chat sessions list of messages.

I tested both. list of messages is better. but I’m wondering if there’s a way to trigger refresh on do a search vs the usual deleayed polling style of bubble

You don’t actually need to fetch the full list of messages in the chat session , just store the chat session ID in each message. That way you reduce one extra step in the flow.

Use a “search_for” action to query messages from that chat session by ID.
Then when sending a new message, follow this flow:

  1. Create a user message (with the chat session ID)
  2. Clear the input field
  3. Call the AI stream (get the response)
  4. Create a system message
  5. Display the AI’s streamed reply

This makes the messaging UI fast and smooth.

yes but consider when the user creates a message. it takes long for it to appear in the repeating group.

When user types “help me ai with…” into input and presses “SEND”. It will not always appear in the chat messages list. So from the users perspective, the message they just sent to AI was never created. There’s a delay…users expect it to immediately appear.

especially when in low cell reception.

It depends. I have an AI Chat exactly as I described above, and the user’s message appears immediately, but everything has to be in a single workflow for the click event on the button, for example. If each action is in custom events, for example, it won’t work, because the bubble will wait for each custom event to finish, and it will wait for the stream to finish to update the search.

My example workflow is below:

1 Like

I also have a chat in my app and I use “Do a Search”.
The message is created immediately.

As @carlovsk.edits pointed, it is all inside a single workflow and the first step is to create this message…

1 Like

do a search seems to be winning. And the arguments are very good!

1 Like