Skip to content

[QUERY]Why is ChatMessageContext.Citations ChunkId field is empty after calling completion.GetMessageContext() #49223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aorlenko opened this issue Apr 3, 2025 · 1 comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@aorlenko
Copy link

aorlenko commented Apr 3, 2025

Library name and version

Azure.AI.OpenAI

Query/Question

I'm using Azure.AI.OpenAI library version 2.1.0 and data source as Azure search index with chunked data.
When I'm getting results back after calling to CompleteChatAsync, I need to have access to all Citations and their ChunkId properties.

The code I'm using:

            var azureClient = new AzureOpenAIClient(
                new Uri(gptUrl),
                new System.ClientModel.ApiKeyCredential(gptKey),
                new AzureOpenAIClientOptions()
                {
                    NetworkTimeout = TimeSpan.FromSeconds(30),
                });

            ChatClient chatClient = azureClient.GetChatClient(gptName);

            var completionOptions = new ChatCompletionOptions()
            {
            };

                var azureSearchDataSource = new AzureSearchChatDataSource()
                {
                    InScope = false,
                    QueryType = DataSourceQueryType.Simple,
                    FieldMappings = new DataSourceFieldMappings(),
                    Endpoint = new Uri(_appSettings.SearchServiceEndpoint),
                    IndexName = xxx,
                    Authentication = DataSourceAuthentication.FromApiKey(_appSettings.SearchServiceKey),
                    TopNDocuments = _appSettings.AzureSearchTopNDocuments
                };

                azureSearchDataSource.FieldMappings.ContentFieldNames.Add("content");
                azureSearchDataSource.FieldMappings.ContentFieldNames.Add("date");
                azureSearchDataSource.FieldMappings.TitleFieldName = "title";
                azureSearchDataSource.FieldMappings.FilePathFieldName = "url";
                azureSearchDataSource.FieldMappings.UrlFieldName = "externalUrl";

                completionOptions.AddDataSource(azureSearchDataSource);

                ChatCompletion completion = await chatClient.CompleteChatAsync(
                [
                new SystemChatMessage(systemMessage),
                ..contextMessages,
                new UserChatMessage(userMessage),
                ], completionOptions);

                var messageContext = completion.GetMessageContext();

All works and citations are retrieved, but the messageContext Citations objects always have ChunkId="0".
Though in my Azure search index, there are always chunk_id values populated.
Are there any additional steps or setup I need to do, in order to get ChunkId values back?
Thanks.

Environment

.NET 8

Hosting: Azure App Service on Windows.

Packages:

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Apr 3, 2025
@jsquire jsquire added Service Attention Workflow: This issue is responsible by Azure service team. Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenAI and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Apr 3, 2025
Copy link

github-actions bot commented Apr 3, 2025

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @ralph-msft @trrwilson.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

2 participants