How can I make sure that OpenAI API only answers my questions with information from my provided data? (Chat with Azure OpenAI models using your own data)

Syedbabar Ali 405 Reputation points
2023-09-21T11:09:07.1533333+00:00

How can I make sure that OpenAI API only answers my questions with information from my provided in cognitive search index.

I have deployed a chatbot which using Azure OpenAI API on Azure App Service that answers questions from my provided data.

(Chat with Azure OpenAI models using your own data)

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,355 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,101 questions
0 comments No comments
{count} votes

Accepted answer
  1. brtrach-MSFT 17,741 Reputation points Microsoft Employee Moderator
    2023-10-03T16:40:15.3166667+00:00

    @Syedbabar Ali To make sure that OpenAI API only answers your questions with information from your provided data, you can use Azure Cognitive Search to index your data and then use the search results to generate responses using OpenAI API.

    1. Here are the general steps to follow:
      Create an Azure Cognitive Search index and import your data into it. You can follow the steps in the Quickstart: Create a search index using REST APIs to create an index and import data into it.
    2. Use the Azure Cognitive Search REST API to query the index and retrieve relevant search results based on the user's question. You can use the Search Documents REST API to query the index and retrieve relevant search results. Here's an example of a search query:
    POST https://[<span class=" active-doc-3" data-doc-items="3">service name].search.windows.net/indexes/[index name]/docs/search?api-version=[api-version[2](#doc-pos=3)</span>]
    Content-Type: application/json
    api-key: [admin key]
    
    {
      "search": "your search query",
      "queryType": "full",
      "searchFields": "comma-separated list of fields to search in",
      "select": "comma-separated list of fields to retrieve",
      "highlight": "comma-separated list of fields to highlight",
      "filter": "filter expression",
      "orderby": "comma-separated list of fields to sort by",
      "skip": "number of search results to skip",
      "top": "number of search results to retrieve"
    }
    
    1. Pass the search results to the OpenAI API to generate a response that is based on the retrieved search results. You can use the Azure Cognitive Services Text Analytics API to analyze the search results and extract relevant information. Then, you can pass this information to the OpenAI API to generate a response that is based on the retrieved search results.

    By doing this, you can ensure that the responses generated by the OpenAI API are based on the data that you have provided in your Azure Cognitive Search index.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.