Azure OpenAI and Cognitive Search problem with REST API

Kevin Jerusalmi 30 Reputation points
2023-09-14T10:04:08.02+00:00

Hello,
Hope this message finds you well. We work with Azure OpenAI and Azure Cognitive search, and we developed an OpenAI model that works with our data. We make API calls from Postman in order to query our model. Here is the request:

POST https://boi.openai.azure.com/openai/deployments/dep2/extensions/chat/completions?api-version=2023-08-01-preview

{
    "messages": [
        {
            "role": "user",
            "content": "Dress",
        }
    ],
    "dataSources": [
        {
            "type": "AzureCognitiveSearch",
            "parameters": {
                "endpoint": "XXXXXX",
                "key": "XXXXXX",
                "indexName": "XXXXX"
            }
        }
    ]
}

Since September 13, the api-version 2023-07-01-preview does not work anymore and this exact same request stopped working. Here is the answer we get:

{
    "id": "8460041f-f0a4-409a-8e1b-e63b85170f50",
    "model": "gpt-35-turbo-16k",
    "created": 1694684697,
    "object": "extensions.chat.completion",
    "choices": [
        {
            "index": 0,
            "finish_reason": "stop",
            "message": {
                "role": "assistant",
                "content": "The requested information is not available in the retrieved data. Please try another query or topic.",
                "end_turn": true,
                "context": {
                    "messages": [
                        {
                            "role": "tool",
                            "content": "{\"citations\": [], \"intent\": \"[]\"}",
                            "end_turn": false
                        }
                    ]
                }
            }
        }
    ]
}

The OpenAI part seems to work, but the Azure Cognitive Search does not product any result. When we query Cognitive search alone, we get:

{
    "@odata.context": "https://bayretail-sc.search.windows.net/indexes('product-gpt-index')/$metadata#docs(*)",
    "value": [
        {
            "@search.score": 5.926734,
            "Product_ID": "34",
            "Product_Name": "Boho Print Maxi Dress",
            "Price": "42.99",
            "Description": "Channel your bohemian spirit with this flowy maxi dress adorned with a boho-inspired print. The dress features a deep V-neckline and adjustable spaghetti straps. Color: Rustic Orange",
            "Gender": "Women's",
            "Url": "https://example.com/product/34"
        },
...

We can see it works perfectly. Using Cognitive search in the "dataSources" part seems to be the problem. But once again, it was still working perfectly two days ago.

Thanks for your help !

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.
948 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,916 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,782 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Deepak Khandelwal 0 Reputation points
    2023-09-28T06:35:06.5366667+00:00

    It seems you've to expand the datasources parameter in the payload, below is an example:

    Reference: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-08-01-preview/inference.json#L1110

    "dataSources": [
                {
                  "type": "AzureCognitiveSearch",
                  "parameters": {
                    "endpoint": "https://mysearchexample.search.windows.net",
                    "key": "***(admin key)",
                    "indexName": "my-chunk-index",
                    "fieldsMapping": {
                      "titleField": "productName",
                      "urlField": "productUrl",
                      "filepathField": "productFilePath",
                      "contentFields": [
                        "productDescription"
                      ],
                      "contentFieldsSeparator": "\n"
                    },
                    "topNDocuments": 5,
                    "queryType": "semantic",
                    "semanticConfiguration": "defaultConfiguration",
                    "inScope": true,
                    "roleInformation": "roleInformation"
                  }
    
    0 comments No comments

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.