Error The extensions chat completions operation must have at least one extension.

Justin See 5 Reputation points
2023-12-01T07:40:54.95+00:00

I'm using API to POST to https://xxx.openai.azure.com/openai/deployments/AutoFlowGPT16k/extensions/chat/completions?api-version=2023-07-01-preview with the JSON body below:

The Error message that came back: "The extensions chat completions operation must have at least one extension."

It works in Chat PlayGround. Please advise. Thank you!

{
2  "messages": [
3    {
4      "role": "system",
5      "content": "You are a Sales agent whose primary goal is to help potential customers understand what our product is about and why customers should buy it. You are friendly and concise. You only provide factual answers to queries, and do not provide answers that are not related to Sales."
6    }
7  ],
8  "temperature": 0,
9  "top_p": 1,
10  "frequency_penalty": 0,
11  "presence_penalty": 0,
12  "max_tokens": 800,
13  "stop": null,
14  "azureSearchEndpoint": "https://xxx.search.windows.net",
15  "azureSearchKey": "***",
16  "azureSearchIndexName": "xxx"
17}
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,309 questions
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. Sedat SALMAN 13,180 Reputation points
    2023-12-01T09:32:13.62+00:00

    In the context of the Azure OpenAI Service, extensions are additional services or features that can be integrated into your chat model to enhance its capabilities or provide specific functionalities.

    {
      "messages": [
        {
          "role": "system",
          "content": "xsxsxsxsxsxsxsxsxsxsx"
        }
      ],
      "temperature": 0,
      "top_p": 1,
      "frequency_penalty": 0,
      "presence_penalty": 0,
      "max_tokens": 800,
      "stop": null,
      "extensions": [
        {
          "type": "azure_search",
          "configuration": {
            "endpoint": "https://xxx.search.windows.net",
            "key": "YOUR_AZURE_SEARCH_KEY",
            "indexName": "YOUR_AZURE_SEARCH_INDEX_NAME"
          }
        }
      ]
    }
    
    

    https://learn.microsoft.com/en-us/azure/cognitive-services/openai/overview

    https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

    0 comments No comments

  2. Justin See 5 Reputation points
    2023-12-04T04:42:19.91+00:00

    It was working in PlayGround, now PlayGround shows the same error. 2023-12-04 12_41_06-Chat playground _ Azure OpenAI Studio and 4 more pages - Personal - Microsoft​ E


  3. DevTom 0 Reputation points
    2024-01-02T15:27:54.22+00:00

    Hi,

    the genearted JSON from the AI Studio is not correct, you need to use dataSources in the body:

    {
    2  "messages": [
    3    {
    4      "role": "system",
    5      "content": "You are a Sales agent whose primary goal is to help potential customers understand what our product is about and why customers should buy it. You are friendly and concise. You only provide factual answers to queries, and do not provide answers that are not related to Sales."
    6    }
    7  ],
    8  "temperature": 0,
    9  "top_p": 1,
    10  "frequency_penalty": 0,
    11  "presence_penalty": 0,
    12  "max_tokens": 800,
    13  "stop": null,
    "dataSources": [
            {
              "type": "AzureCognitiveSearch",
              "parameters": {
                "endpoint": "https://***.search.windows.net",
                "key": "***",
                "indexName": "***"
              }
            }
          ]
    }
    
    0 comments No comments

  4. IsraTech Support 0 Reputation points
    2024-05-14T22:19:41.9533333+00:00

    Good day,

    the JSON/Python code generated is still incorrect. Here is a working syntax for the AzureCognitiveSearch functionality:

    import openai, os, requests
    
    openai.api_type = "azure"
    openai.api_version = "2023-10-01-preview" # Version
    # Azure OpenAI setup
    openai.api_base = "https://xxxxxxx.openai.azure.com" # Add your endpoint here
    openai.api_key = 'azure_openai_api_key' #os.getenv("OPENAI_API_KEY")
    deployment_id = "gpt-35-turbo" # Add your deployment ID here
    # Azure AI Search setup
    search_endpoint = "https://xxxxxxx.search.windows.net"; # Add your Azure AI Search endpoint here
    search_key = os.getenv("SEARCH_KEY"); # Add your Azure AI Search admin key here
    search_index_name = "search_indexer_name"; # Add your Azure AI Search index name here
    
    
    def setup_byod(deployment_id: str) -> None:
        """Sets up the OpenAI Python SDK to use your own data for the chat endpoint.
        :param deployment_id: The deployment ID for the model to use with your own data.
        To remove this configuration, simply set openai.requestssession to None.
        """
        class BringYourOwnDataAdapter(requests.adapters.HTTPAdapter):
            def send(self, request, **kwargs):
                request.url = f"{openai.api_base}/openai/deployments/{deployment_id}/extensions/chat/completions?api-version={openai.api_version}"
                return super().send(request, **kwargs)
        session = requests.Session()
        # Mount a custom adapter which will use the extensions endpoint for any call using the given `deployment_id`
        session.mount(
            prefix=f"{openai.api_base}/openai/deployments/{deployment_id}",
            adapter=BringYourOwnDataAdapter()
        )
        openai.requestssession = session
    
    
    setup_byod(deployment_id)
    message_text = [{"role": "user", "content": "What are the differences between Azure Machine Learning and Azure AI services?"}]
    
    completion = openai.ChatCompletion.create(
        messages=message_text,
        deployment_id=deployment_id,
        dataSources=[
          {
          "type": "AzureCognitiveSearch",
          "parameters": {
            "endpoint": search_endpoint,
            "index_name": search_index_name,
            "semantic_configuration": "default",
            "query_type": "vectorSemanticHybrid",
            "fields_mapping": {},
            "in_scope": True,
            "role_information": "You are an AI assistant that helps people find information.",
            "filter": None,
            "strictness": 3,
            "top_n_documents": 5,
            "authentication": {
              "type": "api_key",
              "key": search_key
            },
            "embedding_dependency": {
              "type": "deployment_name",
              "deployment_name": "your_AI_indexer_name" # Your indexer name here
            },
            "key": search_key,
            "indexName": search_index_name
          }
        }],
        temperature=0,
        top_p=1,
        max_tokens=800,
        stop=[],
        stream=False
    )
    print(completion)
    

    According to the error message I received, other dataSource types are: 'AzureCognitiveSearch', 'Elasticsearch', 'AzureCosmosDB', 'Pinecone', 'AzureMLIndex', 'Microsoft365', 'SharePoint'

    0 comments No comments