Joy
Joy3mo ago

Save chat history Buildship, FlutterFlow and Supabase

I've had a nightmare trying to save chat history. I've successfully implemented the new streaming feature with Flutterflow and Buildship and I've been able to add the variable for threadid. However, the headers output from buildship does not expose the response stream message, so that I can update a page state variable and correctly link it so it can be saved in supabase. I'm trying to save each entry (user and assistant) into supabase and without being able to update the page state variable with the response stream message, it's not working. Can someone please help me asap. As it stands, the response stream is only in the form of raw body text, and flutterflow keeps sharing an empty string or null when I use the raw body text output to supabase. The only time it's added, is if update the page state variable in the "action flow - on message" but when I do that, I'm not able to add other variables. Please help
No description
No description
6 Replies
AI Support
AI Support3mo ago
To save chat history via the AI Assistant nodes to any database, you can follow the steps below: 1. Thread ID: Your OpenAI Assistant node already uses a threadId for maintaining the chat history, which is also being returned from the Assistant node for reference. This can be used as the Document ID in the collection for storing the chat history externally. 2. Messages: The OpenAI Assistant also returns an output called messages which is an array of the entire chat history associated with the threadId. This is the data we need to store in our database (or process as required and then store depending upon your use case). 3. BuildShip Database Integration: Add a "Create Document" node from the BuildShip Database Integration. Give it a Collection Name. The Document ID needs to be the threadId as returned from the AI Assistant node. Pass in the messages output from the OpenAI Assistant node as the Data to be added/updated, as:
{
"fieldName": Messages
}
{
"fieldName": Messages
}
4. Merge Field: Make sure to set the Merge field for the Create Document node as false. This would entirely update the messages field every time, as the items get added to the chat history. For more detailed guidance, refer to the AI Assistant Builder Guide. If you continue to face issues, please submit your query via the in-app support button for further assistance. This solution is marked as answered ✅ Error storing the answer. Please try again.
Joy
Joy3mo ago
But what if I’m trying to use one of your streaming open ai assistant templates
AI Support
AI Support3mo ago
To use one of the streaming OpenAI Assistant templates in BuildShip, you can refer to the detailed documentation provided for the OpenAI Streaming Assistant. This will guide you through the process of setting up and utilizing the template. For more information, please visit the OpenAI Streaming Assistant documentation page. If you have further questions or need specific assistance, please submit your query via the in-app support button.
OpenAI Streaming Assistant Node – BuildShip
The OpenAI Streaming Assistant Node allows you to integrate the OpenAI Assistant API into your workflows and receive responses in a streamed format.
Gaurav Chadha
Gaurav Chadha3mo ago
Hi @Joy, We'll be having a live streaming on BuildShip FlutterFlow streaming API - https://www.youtube.com/live/H4xx_7M0TDQa This workshop will cover examples and the templates ans usecases.
BuildShip
YouTube
Streaming API Workshop with BuildShip x FlutterFlow
In this comprehensive workshop, you will learn how to build and use Streaming APIs in your apps using BuildShip and FlutterFlow. From Text streaming to AI As...
Hubertus
Hubertus3mo ago
Hi @Gaurav Chadha , have followed all steps and the Assistant Streaming is working, my question is how can i handle the "Document Retrieval" tool, can we add a icon to upload an image or make a picture and then upload it? Or should the image first stored in a database and then sent the URL with the "Document Retrieal" tool? Would be nice if there is a short video or explanation for this thank you in advance
AI Support
AI Support3mo ago
To handle the "Document Retrieval" tool in BuildShip and add an icon to upload an image or take a picture, you can follow these general steps: 1. Image Upload: Add an icon or button to your interface that allows users to upload an image or take a picture. 2. Store Image: Store the uploaded image in a database or a storage service. You will need to generate a URL for the stored image. 3. Document Retrieval Tool: Use the generated URL to retrieve the document using the "Document Retrieval" tool. For a more detailed explanation or video, please refer to the BuildShip documentation or submit a request via the in-app support button for specific guidance. You can also check the documentation for any related tutorials or videos: BuildShip Documentation. If you need further assistance, please submit your query via the in-app support button. Error storing the answer. Please try again.