AZURE AI - CHATGPT WITH RAG
====================================
ELEMENT DESCRIPTION
----------------------------------
AZURE AI - CHATGPT WITH RAG provides ChatGPT- like streaming capabilities, supporting your own data source.
STEP-BY-STEP SETUP
--------------------------------
0) Follow this tutorial :
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/use-your-data?tabs=ai-search.
You will get both your Azure OpenAI Key and optionally your Azure AI Search key if you bring your on data.
1) Register on plugins.wiseable.io. Create a new Credential which associates your BUBBLE APP URL, AZURE OPENAI KEY and AZURE AI SEARCH KEY.
The registration service will generate your PUBLIC ACCESS KEY. This key serves as a secure proxy for your real API key. It allows your application to communicate with the service without exposing your real API key. Since this PUBLIC ACCESS KEY is explicitly tied to your registered BUBBLE APP URL, it can only be used from that domain, ensuring that even if the key is publicly visible, it remains safe and cannot be misused by unauthorized sources.
2) In the Plugin Settings, enter your PUBLIC ACCESS KEY generated at the previous step.
3) Add the AZURE AI - CHATGPT WITH RAG to the page on which the chat must be integrated. Select the RESULT DATA TYPE as Threads (Azure AI).
4) Add an element supporting input text for the use prompt.
5) Integrate the logic into your application using the following AZURE AI - CHATGPT WITH RAG element's states and actions:
FIELDS:
- RESULT DATA TYPE : Must always be selected as Threads (Azure AI).
Each of the following information is available either in your Azure Portal or Azure AI Studio. Those information are also consolidated in the Chat Playground of the latter, "Show Code" section.
- RESOURCE NAME : You can find the RESOURCE NAME is in the Azure Portal . It is the name of your Azure Open AI resource. You may also for https://<RESOURCE NAME>.openai.azure.com under Endpoints section. You may hide this data from eavesdroppers by using GET DATA FROM AN EXTERNAL API > AZURE AI - ENCRYPT and set this field as result of this API.
- DEPLOYMENT NAME : The deployment name of the model, deployed in Azure AI Studio. You may hide this data from eavesdroppers by using GET DATA FROM AN EXTERNAL API > AZURE AI - ENCRYPT and set this field as result of this API.
- API VERSION : The API version to use for this operation. This follows the YYYY-MM-DD[-preview] format. See also
https://azure.microsoft.com/en-us/documentation/articles/search-api-versions. You may hide this data from eavesdroppers by using GET DATA FROM AN EXTERNAL API > AZURE AI - ENCRYPT and set this field as result of this API.
- ROLE INFORMATION : Define the role of the AI assistant. You may hide this data from eavesdroppers by using GET DATA FROM AN EXTERNAL API > AZURE AI - ENCRYPT and set this field as result of this API.
- MAX TOKENS : The maximum number of tokens to generate in the completion. The token count of your prompt plus MAX TOKENS can't exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
AZURE AI SEARCH EXTENSION CONFIGURATION
The Microsoft Azure OpenAI service allows users to integrate their own data with advanced language models like GPTs. This integration enables more accurate and specific responses, as the models can access and reference the user's data directly. Supported data formats include text, markdown, HTML, Word, PowerPoint, and PDF files. Data can be sourced from Azure storage containers, local files, or URLs.
- SEARCH SERVICE NAME : You can find the SEARCH SERVICE NAME is in the Azure Portal . It is the name of your Azure Search AI resource. You may also for https://<SEARCH SERVICE NAME>.search.windows.net under Endpoints section.
- SEARCH INDEX NAME : Enter the SEARCH INDEX NAME that will be used to reference this data source. A new Azure Search Index with the provided name will be generated after data ingestion is complete.
- QUERY TYPE : Query type. The values are: simple | semantic | vector | vectorSimpleHybrid | vectorSemanticHybrid. See
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/use-your-data?tabs=ai-search#search-options - EMBEDDING DEPLOYMENT NAME : To use a vector model as part of your data, enter here the DEPLOYMENT NAME of your EMBEDDING MODEL. An example of embedding model is text-embedding-ada-002. The name is your choice upon embedding model deployment.
- TOP N DOCUMENTS : This parameter is an integer that can be set to 3, 5, 10, or 20, and controls the number of document chunks provided to the large language model for formulating the final response. By default, this is set to 5. The search process can be noisy and sometimes, due to chunking, relevant information might be spread across multiple chunks in the search index. Selecting a top-K number, like 5, ensures that the model can extract relevant information, despite the inherent limitations of search and chunking. However, increasing the number too high can potentially distract the model. Additionally, the maximum number of documents that can be effectively used depends on the version of the model, as each has a different context size and capacity for handling documents. If you find that responses are missing important context, try increasing this parameter.
- STRICTNESS : Determines the system's aggressiveness in filtering search documents based on their similarity scores. The system queries Azure Search or other document stores, then decides which documents to provide to large language models like ChatGPT. Filtering out irrelevant documents can significantly enhance the performance of the end-to-end chatbot. Some documents are excluded from the top-K results if they have low similarity scores before forwarding them to the model. This is controlled by an integer value ranging from 1 to 5. Setting this value to 1 means that the system will minimally filter documents based on search similarity to the user query. Conversely, a setting of 5 indicates that the system will aggressively filter out documents, applying a very high similarity threshold. If you find that the chatbot omits relevant information, lower the filter's strictness (set the value closer to 1) to include more documents. Conversely, if irrelevant documents distract the responses, increase the threshold (set the value closer to 5).
EVENTS :
- ERROR : Event triggered when an error occurs.
- STREAMING STARTED : Event triggered when the streaming starts.
- STREAMING ENDED : Event triggered when the streaming ends.
- CALL FUNCTION : Event triggered when a function triggers, as define in FUNCTIONS of SEND USER PROMPT action.
- THREADS TO SAVE: Event triggered when any of the thread has changed.
- READY: Event triggered when this element's fields have been set and element is ready to serve requests.
EXPOSED STATES:
Use any element able to show/process the data of interest (such as a Group with a Text field) stored within the result of the following states of the AZURE AI - CHATGPT WITH RAG :
- ERROR : Error message upon Error event trigger.
- IS STREAMING : Returns true when streaming is in progress.
- FUNCTION NAME : Name of the function, set upon CALL FUNCTION event.
- FUNCTION ARGUMENTS : Arguments of the function, set upon CALL FUNCTION event.
- FUNCTION CALL ID : Unique identifier of the function call, set upon CALL FUNCTION event.
- LATEST STOP REASON : Latest stop reason of the AI engine, populated upon STREAMING ENDED event.
- ALL THREADS : List of threads containing a list of role and message content.
- ALL THREADS (RAW DATA) : String containing All Current Threads in JSON format. You may use this string to load threads in "Load Threads" action.
ELEMENT ACTIONS - TRIGGERED IN WORKFLOW:.
- SEND USER PROMPT : Send Prompt to the specified Thread ID, which is autogenerated if not set.
Inputs Fields :
- PROMPT : The user prompt.
- THREAD ID : Send the user prompt to this Thread ID. A valid Thread ID is one of the exposed state ALL THREADS. Autogenerated if not set.
- FUNCTIONS : Array containing functions definition. See
https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models#basic-concepts - TEMPERATURE : What sampling temperature to use, between 0 and 2. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 for ones with a well-defined answer.
- SET THREAD TITLE : Set a custom Thread Title of a given Thread ID.
Inputs Fields :
- THREAD ID : Set the title to this Thread ID. A valid Thread ID is one of the exposed state ALL THREADS.
- TiTTLE : New title
- SEND FUNCTION RESULT : Send the function results. See
https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models#basic-concepts Inputs Fields :
- FUNCTION CALL ID : Unique identifier of the function call from FUNCTION CALL ID state, which is set upon set upon CALL FUNCTION event.
- FUNCTION RESULT : Result of the function to pass.
- TEMPERATURE : What sampling temperature to use, between 0 and 2. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 for ones with a well-defined answer.
- PASS USER REQUEST FUNCTIONS : Pass the functions definitions from the user request into this function result, this is useful when the function result refers to other functions.
- DELETE THREAD ID : Delete the specified Thread ID.
Inputs Fields :
- THREAD ID : Thread ID to delete. A valid Thread ID is one of the exposed state ALL THREADS.
- LOAD THREADS : Load the threads.
Inputs Fields :
- THREADS (RAW DATA) : String formatted as JSON-safe, containing the threads in JSON format.
6) (Optional) Add the AZURE AI - MARKDOWN & LATEX PARSER element to display markdown formatting
IMPLEMENTATION EXAMPLE
======================
Feel free to browse the app editor in the Service URL for an implementation example.
TROUBLESHOOTING
================
Any plugin related error will be posted to the the Logs tab, "Server logs" section of your App Editor.
Make sure that "Plugin server side output" and "Plugin server side output" is selected in "Show Advanced".
> Server Logs Details:
https://manual.bubble.io/core-resources/bubbles-interface/logs-tab#server-logsPERFORMANCE CONSIDERATIONS
===========================
N/A
QUESTIONS ?
===========
Contact us at
[email protected] for any additional feature you would require or support question.