Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.36k stars 2k forks source link

Null filepath and URL in Azure OpenAI Response using chatCompletions #38548

Closed hind214875 closed 8 months ago

hind214875 commented 10 months ago

Describe the bug When querying Azure OpenAI with Cognitive Search integration, the expected filepath and URL within the citation responses are returning as null. The fieldsMapping configuration is intended to map a downloadable flag to the filepathField. However, despite this configuration, the response does not contain the expected values.

Exception or Stack Trace image

To Reproduce 1. 1 2. 2 3. 33 4.Configure Azure OpenAI with Cognitive Search integration using the following fieldsMapping: 3 5.Perform a query against the Azure OpenAI service. 6.Inspect the citation response, observing that filepath and URL are null.

Code Snippet code

Expected behavior The response from Azure OpenAI when using Cognitive Search should populate the filepath and URL fields, filePath true or false depende Downloadable and url the link of the document:

image

Setup (please complete the following information):

Additional context

Information Checklist

joshfree commented 10 months ago

Thanks for sharing this beta feedback @hind214875 -- @mssfang can you please follow up?

mssfang commented 9 months ago

Thank you for reporting this issue. @hind214875 Can you try update pom dependency as below?

<dependencies>
   <dependency>
     <groupId>com.azure</groupId>
     <artifactId>azure-ai-openai</artifactId>
     <version>1.0.0-beta.6</version>
   </dependency>

   <dependency>
     <groupId>com.azure</groupId>
     <artifactId>azure-search-documents</artifactId>
     <version>11.6.0-beta.7</version>
     <exclusions>
         <exclusion>
             <groupId>com.azure</groupId>
             <artifactId>azure-core-serializer-json-jackson</artifactId>
         </exclusion>
     </exclusions>
   </dependency>
 </dependencies>
github-actions[bot] commented 9 months ago

Hi @hind214875. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

hind214875 commented 9 months ago

Hi mssfang! Thank you for your reply, but unfortunately it is still not working.

mssfang commented 9 months ago

Hi mssfang! Thank you for your reply, but unfortunately it is still not working.

Thanks for the try out. Is possible we can have a sample code that can reproduce this issue?

mssfang commented 9 months ago

Is possible we can have a sample code from your side that can use to reproduce the issue?

I have tried to use following codesnippet to reproduce the issue but find there is able to get the URL and filePath.

String azureSearchIndexName = "openai-test-index-carbon-wiki"; // "hotels-vector-sample-index"

        AzureCognitiveSearchChatExtensionConfiguration searchConfiguration =
                new AzureCognitiveSearchChatExtensionConfiguration(
                        new AzureCognitiveSearchChatExtensionParameters(azureSearchEndpoint, azureSearchIndexName)
                                .setAuthentication(new OnYourDataApiKeyAuthenticationOptions(azureSearchAdminKey))
                                .setQueryType(AzureCognitiveSearchQueryType.SIMPLE) // SIMPLE, VECTOR, or Hybrid
                                .setInScope(true)
                                .setTopNDocuments(2)
                                // the deployment name of the embedding model when you are using a vector or hybrid query type
                                .setEmbeddingDependency(new OnYourDataDeploymentNameVectorizationSource("text-embedding-ada-002"))
                                .setFieldsMapping(
                                        new AzureCognitiveSearchIndexFieldMappingOptions()
                                                .setFilepathField("setupwinenv.md")
                                )
                );

        String question = "How to build carbon on Windows";
        List<ChatRequestMessage> chatMessages = new ArrayList<>();
        chatMessages.add(new ChatRequestUserMessage(question));
        ChatCompletionsOptions chatCompletionsOptions = new ChatCompletionsOptions(chatMessages)
                .setDataSources(Arrays.asList(searchConfiguration));

        ChatCompletions chatCompletions = client.getChatCompletions(deploymentOrModelId, chatCompletionsOptions);

        System.out.println("Question: " + question);
        for (ChatChoice choice : chatCompletions.getChoices()) {
            ChatResponseMessage message = choice.getMessage();
            System.out.printf("Answer: %s%n%n", message.getContent());
            // If Azure OpenAI chat extensions are configured, this array represents the incremental steps performed
            // by those extensions while processing the chat completions request.
            List<ChatResponseMessage> contextMessages = message.getContext().getMessages();
            for (ChatResponseMessage contextMessage : contextMessages) {
                System.out.println("Context Message: ");
                System.out.println("   - " + contextMessage.getContent());
            }
        }

image

image

Hi mssfang! Thank you for your reply, but unfortunately it is still not working.

github-actions[bot] commented 9 months ago

Hi @hind214875. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] commented 8 months ago

Hi @hind214875, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

hind214875 commented 8 months ago

Hi mssfang!

Sorry for the late replay, I actually tested yesterday again and this time it works i didn't change anything so i don't really know why it works now. Thank you for your help :)

mssfang commented 8 months ago

@hind214875 Glad to see that works. BTW, we have a new beta, beta.7 released that includes some breaking change and new features Text-to-Speech.

github-actions[bot] commented 8 months ago

Hi @hind214875. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.