OpenAi in Azure using C#
Program.cs located in OpenAiTest solution Requires Secrets.cs to be created with read-only AiModelName, WebsiteUri and Key properties. Assumes: 1) Azure account 2) OpenAi account, 3) Azure OpenAi account and the Secrets.cs reflects the correct answers. An alternative to this approach is to hit the OpenAi API directly. using Azure; using Azure.AI.OpenAI; using OpenAiTest; var options = new ChatCompletionsOptions(); options.Messages.Add(new ChatMessage(ChatRole.System, "You are friendly. You will be giving advice to Texas lawyers, so only use Texas state laws when quoting state laws.")); options.MaxTokens = 2000; Console.Write("Welcome to the OpenAI Copilot Test Console App!"); string prompt = string.Empty; var client = new OpenAIClient(new Uri(Secrets.WebsiteUri), new AzureKeyCredential(Secrets.Key)); while (true) { Console.ForegroundColor = ConsoleColor.White; Console.Write(">> "); prompt = Console.ReadLine()!; ...