📝 How to use
Initially set the OpenAI Project API key in the plugin settings page or you can set it as a parameter in each of the Actions. You need to call the ‘Create Assistant and Vector Store’ action once in your application to setup the OpenAI Assistan and Vector Store in the OpenAI account. To upload the RAG document to the OpenAI Vector Store, use the ‘Upload RAG Document From URI’ action. To get answer’s to queries, use the ‘Send Query To Assistant’ action.
________________________________________
⚙️ Components
🔧 Actions
🛠️ Create Assistant and Vector Store: For an OpenAI account, this action needs to be called only once to setup the Assistant and Vector Store in it. The Assistant will be named ‘OpenAI RAG DocQuery Assistant’ and the Vector Store will be named ‘OpenAI RAG DocQuery Storage’.
If the OpenAI Project API key is not set in the plugin setting page, it needs to be set in the field ‘OpenAI API Key’. After the action completes, it returns the following fields:
• Success (yes/no) – Indicates if the operation was successful or not
• Assistant ID (text) – The ID of the Assistant created within the OpenAI account. This should be stored somewhere as this will be required when calling the other Actions.
• Vector Store ID (text) – The ID of the Vector Store created within the OpenAI account. This should be stored somewhere as this will be required when calling the other Actions.
• Error Message (text) – The error message if the Action fails to complete.
📤 Upload RAG Document From URI: This action is used to upload documents to the OpenAI Vector store. Scanned documents or image only based documents are not supported. The contents of these documents are what is used for the AI model to answer queries. When a file is uploaded, it is added on to the storage and does not replace the existing file even if the file name is the same. If the requirement is to replace, then you need to go to the OpenAI account, click on Dashboard -> Storage, select the initial file and delete it; otherwise the assistant will utilize all relevant content from all the files to answer the user query.
If the OpenAI Project API key is not set in the plugin setting page, it needs to be set in the field ‘OpenAI API Key’.
URL from where the document can be downloaded needs to be set in the field ‘Document URL’.
Vector Store Id, which was returned after the completion of the ‘Create Assistant and Vector Store’ Action needs to be set in the field ‘Vector Store ID’.
File name with the extension of the document to be uploaded can be set in the field ‘File Name’. This is an optional field and if it is omitted, the logic within the Action will try and derive the file name and extension from the given URL.
After the action completes, it returns the following fields:
• Success (yes/no) – Indicates if the operation was successful or not
• File ID (text) – The ID of the file that was created in the OpenAI File Storage.
• Document URL (text) – The URL that was provided in the field ‘Document URL’.
• Error Message (text) – The error message if the Action fails to complete.
🗣️ Send Query To Assistant: This action is what sends a user query to the OpenAI assistant and get a response with citations from it. You can maintain a chat history(conversation) with the user and the AI Assistant by maintaining the ‘Conversation ID’ field that would be created at the start of each conversation and passed back in the first response.
If the OpenAI Project API key is not set in the plugin setting page, it needs to be set in the field ‘OpenAI API Key’.
Assistant Id, which was returned after the completion of the ‘Create Assistant and Vector Store’ Action needs to be set in the field ‘Assistant ID’.
Vector Store Id, which was returned after the completion of the ‘Create Assistant and Vector Store’ Action needs to be set in the field ‘Vector Store ID’.
If the field ‘Conversation Id’ is kept empty, the plugin considers this as a new conversation and will create a new conversation id for it. This id will be returned after the Action completes in the field ‘Conversation Id’. To maintain the conversation history, pass the received ‘Conversation Id’ in the follow up calls to this Action.
Pass the user query in the field ‘User Query’.
After the action completes, it returns the following fields:
• Success (yes/no) – Indicates if the operation was successful or not
• Able to Answer (yes/no) – Indicates if the Assistant is able to answer the user query. Some times the uploaded document does not have adequate information to answer or the query is not clear enough, in which case the returned field ‘Response’ will contain and clarifications the Assistant requires to answer the query.
• Why Unable to Answer(text) – If the field, ‘Able to Answer’ is set to ‘no’, this field will contain the reason why the Assistant was not able to answer.
• Response (text) – This field contains the Assistant response to the user query.
• Conversation ID (text) – Id that uniquely identify a conversation between a user and the AI assistant. At the start of a conversation between a user and an Assistant, OpenAI creates a conversation id. This id is what is used to identify the conversation history by the Assistant.
• Assistant ID (text) – The Id of the OpenAI assistant used to respond to the user query.
• Vector Store ID (text) – The Vector Store Id where the documents used for responding to the user query is stored.
• Error Message (text) – The error message if the Action fails to complete.
• Citations (array - text) – This is an array of text containing the citations. Each text in the array is a JSON string containing the following information of each citation:
document – ‘Name of the document where this citation was retrieved from’.
heading: The main heading of the citation.
citation: The section of the document that was used to respond to the user query.
🔗 Link to test app editor -
https://bubble.io/page?id=openai-rag-docquery-test&tab=tabs-1&name=test&type=page🔗 Link to demo page -
https://openai-rag-docquery-test.bubbleapps.io/version-test/test