semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: [BUG] When working with Semantic Kernel, while invoking ChatCompletion API, unable to specify data sources

Open jsquire opened this issue 1 year ago • 4 comments

Issue Transfer

This issue has been transferred from the Azure SDK for .NET repository, #43783.

Please be aware that @chetan-d-mahajan is the author of the original issue and include them for any questions or replies.

Details

Library name and version

Microsoft.SemanticKernel, Microsoft.SemanticKernel.ChatCompletion

Describe the bug

When calling the OpenAI's chat completion API, the SDK doesn't provide an option to specify extra field such as "data_sources"

https://learn.microsoft.com/en-us/azure/ai-services/openai/references/on-your-data?tabs=rest#context

Expected behavior

the SKD should support additional parameter to chat completions API

Actual behavior

the SKD doesn't support additional parameter to chat completions API

Reproduction Steps

Microsoft.SemanticKernel.ChatCompletion.IChatCompletionService.GetStreamingChatMessageContentsAsync()

This method doesn't accept additional parameters to query data on custom data sources

Environment

VS 2022 .NET 6.0 Windows

jsquire avatar Apr 30 '24 13:04 jsquire

@jsquire you can specify the data source like this

var config = new AzureOpenAIChatCompletionWithDataConfig
{
    CompletionApiKey = "xxx",
    CompletionApiVersion = "2023-08-01-preview",
    CompletionEndpoint = "https://xxx.openai.azure.com",
    CompletionModelId = "gpt432k",
    DataSourceApiKey = "xxxx",
    DataSourceEndpoint = "https://xxx.search.windows.net",
    DataSourceIndex = "xx-index"
};
builder.Services.AddKernel().AddAzureOpenAIChatCompletion(
             config:config
             );
builder.Services.AddSingleton<KernelPlugin>(sp => KernelPluginFactory.CreateFromType<WeatherPlugin>(serviceProvider: sp));

https://github.com/microsoft/semantic-kernel/issues/6019

rupeshtech avatar Apr 30 '24 13:04 rupeshtech

Thanks, @rupeshtech, but as stated, I am just the person who transferred this issue to the proper repository. You'll want to discuss with @chetan-d-mahajan, the author of the original issue.

jsquire avatar Apr 30 '24 13:04 jsquire

hello @rupeshtech , thanks for the comment we are going to give a try and we will let you know. @chetan-d-mahajan

Rtoribiog avatar Apr 30 '24 14:04 Rtoribiog

Hi @rupeshtech

Thanks for your comment.

I tried with your suggestion and it doesn't work, the response from OpenAI API is empty which means that it isn't able to connect & fetch the data from the Azure AI search index.

Seems like the .NET SDK doesn't support data source yet. https://github.com/microsoft/semantic-kernel/issues/6112

image

@Rtoribiog

chetan-d-mahajan avatar May 06 '24 06:05 chetan-d-mahajan