Azure OpenAI API and Azure AI Search

chaymr 181 Reputation points
2024-01-17T10:59:11.89+00:00

My C# project uses the latest Azure OpenAI API nuget and Azure AI Search (ACS) as the data source in the GetChatCompletionsAsync call. However, since yesterday, I've been encountering a validation error when trying to hit the service. Any ideas on how to resolve this issue?

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,815 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ramr-msft 17,821 Reputation points
    2024-01-17T11:08:44.01+00:00

    Thanks for the question, This issue has been fixed as confirmed in the following github issue. https://github.com/Azure/azure-sdk-for-net/issues/41138

            var client = new OpenAIClient(new Uri(_apiBase), new AzureKeyCredential(_apiKey!));
    
            var primeText = "...";
    
            AzureCognitiveSearchChatExtensionConfiguration searchExtensionConfig = new()
            {
                SearchEndpoint = new Uri(_searchEndpoint),
                IndexName = _searchIndexName,
                Authentication = new OnYourDataApiKeyAuthenticationOptions(_searchKey),
                DocumentCount = 10,
                Strictness = 1,
                RoleInformation = primeText
            };
    
            var chatCompletionsOptions = new ChatCompletionsOptions()
            {
                DeploymentName = _deploymentId,
                Messages =  {
                    new ChatRequestSystemMessage(primeText)
                },
                AzureExtensionsOptions = new AzureChatExtensionsOptions()
                {
                    Extensions = { searchExtensionConfig }
                },
                Temperature = 0.8f
    
            };
         
    
            var response = await client.GetChatCompletionsAsync(chatCompletionsOptions);
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.