// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.md file in the project root for full license information. // using System; using System.Threading.Tasks; using Azure; using Azure.AI.OpenAI; using Azure.Identity; using OpenAI; using OpenAI.Assistants; class Program { static async Task Main(string[] args) { var assistantId = Environment.GetEnvironmentVariable("ASSISTANT_ID") ?? ""; var threadId = args.Length > 0 ? args[0] : null; // Validate environment variables var openAIAPIKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? ""; var openAIEndpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? ""; if (string.IsNullOrEmpty(openAIAPIKey) || openAIAPIKey.StartsWith(" { Console.WriteLine($"{char.ToUpper(role[0]) + role.Substring(1)}: {content}\n"); }); } // User interaction loop while (true) { Console.Write("User: "); var userPrompt = Console.ReadLine(); if (string.IsNullOrEmpty(userPrompt) || userPrompt == "exit") break; Console.Write("\nAssistant: "); await assistant.GetResponseAsync(userPrompt, content => { Console.Write(content); }); } Console.WriteLine($"Bye! (ThreadId: {assistant.Thread?.Id})"); } }