Last active
July 4, 2024 02:41
-
-
Save amul047/f9821c1a834c2a86434c6e4dde7a5e18 to your computer and use it in GitHub Desktop.
RAG with `Azure Search` (Retrieval) and (Augmented) `Azure OpenAI` (Generation) using `Microsoft.SemanticKernel.Connectors.OpenAI` `1.15.1`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Azure; | |
using Azure.AI.OpenAI; | |
var prompt = ".."; | |
var azureOpenaiEndpoint = "https://...openai.azure.com/"; | |
var azureOpenaiApiKey= ".."; | |
var azureOpenAiDeploymentName = ".."; | |
var azureSearchApiKey= ".."; | |
var azureSearchEndpoint = "https://...search.windows.net"; | |
var azureSearchIndexName = ".."; | |
var openAiClient = new OpenAIClient(new Uri(azureOpenaiEndpoint), new AzureKeyCredential(azureOpenaiApiKey)); | |
var chatCompletions = openAiClient.GetChatCompletions(new ChatCompletionsOptions | |
{ | |
DeploymentName = azureOpenAiDeploymentName, | |
Messages = | |
{ | |
new ChatRequestUserMessage(prompt), | |
}, | |
AzureExtensionsOptions = new AzureChatExtensionsOptions | |
{ | |
Extensions = | |
{ | |
new AzureSearchChatExtensionConfiguration | |
{ | |
Authentication = new OnYourDataApiKeyAuthenticationOptions(azureSearchApiKey), | |
SearchEndpoint = new Uri(azureSearchEndpoint), | |
IndexName = azureSearchIndexName, | |
} | |
} | |
} | |
}); | |
Console.WriteLine(chatCompletions.Value.Choices.First().Message.Content); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment