Example I am following:

https://github.com/Azure/azure-sdk-for-java/blob/azure-ai-openai_1.0.0-beta.5/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/ChatCompletionsWithYourData.java

My methods:

public String getChatResponse(String question) {

    LOGGER.info("Getting chat response...");

    List<ChatMessage> chatMessages = new ArrayList<>();
    chatMessages.add(new ChatMessage(ChatRole.USER, question));

    ChatCompletionsOptions opts = new ChatCompletionsOptions(chatMessages);

    // Your Azure Cognitive Search endpoint, admin key, and index name
    AzureChatExtensionConfiguration extensionConfiguration = getAzureChatExtensionConfiguration();
    opts.setDataSources(List.of(extensionConfiguration));

    var chatCompletions = openAIClient.getChatCompletions(gptChatDeploymentModelId, opts);

    return chatCompletions.getChoices().get(0).getMessage().getContent();
  }

  private AzureChatExtensionConfiguration getAzureChatExtensionConfiguration() {
    String azureSearchEndpoint = "https://%s.search.windows.net".formatted(azureSearchService);

    AzureCognitiveSearchChatExtensionConfiguration cognitiveSearchConfiguration =
        new AzureCognitiveSearchChatExtensionConfiguration(
            azureSearchEndpoint, azureSearchAdminKey, azureSearchIndexName);

    return new AzureChatExtensionConfiguration(
        AzureChatExtensionType.AZURE_COGNITIVE_SEARCH,
        BinaryData.fromObject(cognitiveSearchConfiguration));
  }

What I have done:

Changed from Azure Europe West region to France Central. Tried different models, they all return same error:

2023-11-28T13:57:59.803+01:00 INFO 15259 --- [nio-8080-exec-1] etChatCompletionsWithAzureExtensionsSync : {"az.sdk.message":"HTTP request","method":"POST","url":"https://openai-test-solujic-france-central.openai.azure.com/openai/deployments/gpt-4-0613/extensions/chat/completions?api-version=2023-09-01-preview","tryCount":"1","Date":"Tue, 28 Nov 2023 12:57:59 GMT","Content-Length":"760","api-key":"REDACTED","Content-Type":"application/json","x-ms-client-request-id":"13c3ca94-0f3b-4898-a9d6-7235b150b126","accept":"application/json","User-Agent":"azsdk-java-azure-ai-openai/1.0.0-beta.5 (21.0.1; Linux; 6.2.0-37-generic)","contentLength":760,"body":"{"messages":[{"role":"system","content":"You will be honest but also respectful.","name":null,"function_call":null,"context":null},{"role":"system","content":"Your name is Jack.)","name":null,"function_call":null,"context":null},{"role":"user","content":"\"What is chess?\"","name":null,"function_call":null,"context":null}],"max_tokens":null,"temperature":null,"top_p":null,"logit_bias":null,"user":null,"n":null,"stop":null,"presence_penalty":null,"frequency_penalty":null,"stream":null,"model":null,"functions":null,"function_call":null,"dataSources":[{"type":"AzureCognitiveSearch","parameters":{"endpoint":"https://sigit-chatbot-ai-search.search.windows.net","key":"cfuzGtmV4hLSNE4fW0WV8rLggaZK8MoifD8uJZRCapAzSeD2cAK0","indexName":"sigitchatbotindex"}}]}"} 2023-11-28T13:58:00.428+01:00 INFO 15259 --- [nio-8080-exec-1] etChatCompletionsWithAzureExtensionsSync : {"az.sdk.message":"HTTP response","contentLength":"133","statusCode":400,"url":"https://openai-test-solujic-france-central.openai.azure.com/openai/deployments/gpt-4-0613/extensions/chat/completions?api-version=2023-09-01-preview","durationMs":620,"Date":"Tue, 28 Nov 2023 12:58:00 GMT","x-ms-region":"REDACTED","Content-Length":"133","x-envoy-upstream-service-time":"REDACTED","x-content-type-options":"REDACTED","apim-request-id":"REDACTED","Content-Type":"application/json; charset=UTF-8","Strict-Transport-Security":"REDACTED","x-ms-client-request-id":"13c3ca94-0f3b-4898-a9d6-7235b150b126","body":"{"error": {"requestid": "8df99a0d-b779-43a4-9e7d-6f90d0131c64", "code": 400, "message": "Functions are not supported at this time."}}"} 2023-11-28T13:58:00.440+01:00 ERROR 15259 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: com.azure.core.exception.HttpResponseException: Status code 400, "{"error": {"requestid": "8df99a0d-b779-43a4-9e7d-6f90d0131c64", "code": 400, "message": "Functions are not supported at this time."}}"] with root cause

com.azure.core.exception.HttpResponseException: Status code 400, "{"error": {"requestid": "8df99a0d-b779-43a4-9e7d-6f90d0131c64", "code": 400, "message": "Functions are not supported at this time."}}"

The problem I have is understanding why the message "Functions are not supported at this time.". I don't quite understand where the functions are being used or called. I understand its some kind of Azure Open AI feature, but to my understanding I am not using them. On the Azure AI Studio everything works fine (the chat feature with BYOD data source set).

When I look at the code provided in the github link above it seems that everything is the same.

Searching online I found this thread but it seems that the python client is a bit different then Java one since it has create method that takes functions as parameter.

Note: azure-ai-openai maven pom dependency version is 1.0.0-beta.5 same as the example in the github.

1

There are 1 answers

0
solujic On BEST ANSWER

It seems like a bug on the azure-search-documents dependency.

The fix is to add azure-core-serializer-json-jackson exclusion to the pom.xml

        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-search-documents</artifactId>
            <version>${azure-search.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.azure</groupId>
                    <artifactId>azure-core-serializer-json-jackson</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

As explained in this thread: https://github.com/Azure/azure-sdk-for-java/issues/36054