Using Firestore Collection Query Output in OpenAI Assistant Prompt
Hi - I'm trying to use the output from a Firestore Collection Query in the prompt of a subsequent OpenAI assistant node. Unfortunately, if I input the query's 'Document Data' object directly in the assistant prompt, the value returns undefined at runtime 😢 . (The query itself is succesful, I've validated that).
I assume the Query output needs to be transformed somehow in order to be used in the assistant prompt, but I'm not sure how? I've tried the Parse and Stringify JSON nodes and neither worked. Does anyone have insight into what I have to do to the object in order to utilize?
Thanks in advance!
9 Replies
It sounds like you need to transform the output from the Firestore Collection Query into a format that the OpenAI assistant node can understand. You may need to extract specific values from the 'Document Data' object and format them appropriately before passing them to the assistant prompt.
To achieve this, you can use the "Set Variable" node to extract and format the data from the Firestore query result. Here's a general approach:
1. Firestore Collection Query Node: Ensure your query is correctly fetching the data.
2. Set Variable Node: Use this node to extract specific fields from the 'Document Data' object and format them as needed.
3. OpenAI Assistant Node: Use the formatted data from the "Set Variable" node in your prompt.
For more detailed guidance, please refer to the BuildShip documentation on Firestore Collection Query and Set Variable Node.
If you need further assistance, please submit your query via the in-app support button.
@Al_B You can refer to this answer - You can make the query outside the Assistant node and then add an empty node inside the Assistant then store the variable output of the Firestore Collection Query node to make your workflow work, alternatively, you can add the use our Firestore Collection Video - https://www.youtube.com/watch?v=B0g0FWqWSLg. Also answered another workaround here as well - https://discord.com/channels/853498675484819476/1257809665484652686/1258085989167927319.
BuildShip
YouTube
Streaming AI Assistant on FlutterFlow with BuildShip Template
Learn how to get streaming response from AI Assistant connected to your database and tools on FlutterFlow with BuildShip. This is a full stack template.
Cloneables here:
BuildShip Template: https://buildship.app/remix?template=streaming-assistant-flutterflow
FlutterFlow Marketplace App: https://marketplace.flutterflow.io/item/xvsvtzyflKhmxN7UVa...
Hi @Gaurav Chadha - Thanks for the response. My request is different from the other workaround you referenced as I don't want to run Query Collection as a function of the Assistant. I already run the Query Collection as an independent node before the Assistant node; I instead want to use that Collection output directly in the Assistant prompt (see screenshot).
Am I understanding correctly that in this case, the best practice is to store the output as an empty node within the Assistant, then provide the Assistant with instructions that it needs to run the empty node Function to grab that value?
Hi @699325537612726394,
In your case, you can indeed use the output of the Query Collection node directly in the Assistant prompt. The best practice would be to store the output of the Query Collection node in a variable or a data store node, and then reference that variable or data store within your Assistant node.
For detailed steps and best practices on how to achieve this, please refer to the BuildShip documentation on Using Variables and Data Stores.
If you need further assistance, please submit your request via the in-app support button.
In case someone else runs into this issue, I found the best solution in this case was to create an empty node with code to transform the Firestore output into JSON string. (I used ChatGPT to generate this code.) I then reference the empty node's output directly in the Assistant's user prompt.
To me, this is much more preferable than storing the empty node as a function within the assistant. Functions require additional instructions to the Assistant to access, which can sometimes be unreliable and take additional processing time.
It sounds like you're using a custom script node to transform Firestore output into a JSON string and then referencing this node's output directly in the Assistant's user prompt. This approach can indeed be more efficient and reliable.
For more details on customizing nodes and working with script nodes in BuildShip, you can refer to the following documentation:
- Script Node
If you have further questions or need specific guidance, please submit your query via the in-app support button.
Script Node – BuildShip
A unified resource to start building your backend with low-code. Dive into triggers, nodes, and step-by-step guidance to jumpstart your workflow creation.
Hey guys im trying to make a knowledge assistant to create listing knowledge for my ai assistant. I have openai assistant and supabase hooked up to an external chat interface. Works well just need help with the prompt i think
AI Support Bot Information
<@1295207223902863374> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human!
Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers.
Please note: Team members will review and answer the questions on best efforts basis.
AI Response
You can start by looking into existing templates that utilize OpenAI and Supabase in a chat or assistant setup. Here are a few relevant templates you may find insightful:
1. Chat with Supabase: This template helps you create a personal assistant designed to manage and provide information about a set of users stored in your Supabase database【4:0†buildship-site.json】.
2. OpenAI Assistant - Chat: This template provides a simple way to create a chatbot with BuildShip and the OpenAI API【4:0†buildship-site.json】.
3. FlutterFlow Streaming Assistant with Supabase: You can use this template to build an OpenAI Assistant for FlutterFlow apps with Supabase, allowing for streaming responses in real-time【4:3†buildship-site.json】.
These templates can serve as a foundational guide or an inspiration to help you draft effective prompts and implement features for your knowledge assistant. You can modify and tailor the structure to fit your specific use cases.
If you need further details on any of these workflows or additional assistance, consider exploring the templates through your BuildShip interface.
BuildShip AI Support