diff --git a/src/chat/CustomerSupport/CustomerSupport.csproj b/src/chat/CustomerSupport/CustomerSupport.csproj index 557a3d5..e316cd1 100644 --- a/src/chat/CustomerSupport/CustomerSupport.csproj +++ b/src/chat/CustomerSupport/CustomerSupport.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/src/chat/CustomerSupport/ProductManualService.cs b/src/chat/CustomerSupport/ProductManualService.cs index 12fb911..7d176ba 100644 --- a/src/chat/CustomerSupport/ProductManualService.cs +++ b/src/chat/CustomerSupport/ProductManualService.cs @@ -26,7 +26,7 @@ public async Task InsertManualChunksAsync(IEnumerable manualChunks) public async Task> GetManualChunksAsync(string query, int? productId, int? limit = 5) { - var queryEmbedding = await _embeddingGenerator.GenerateEmbeddingVectorAsync(query); + var queryEmbedding = await _embeddingGenerator.GenerateVectorAsync(query); var filter = new VectorSearchFilter() diff --git a/src/chat/CustomerSupport/Program.cs b/src/chat/CustomerSupport/Program.cs index 5edc7f9..9255801 100644 --- a/src/chat/CustomerSupport/Program.cs +++ b/src/chat/CustomerSupport/Program.cs @@ -12,13 +12,15 @@ IChatClient chatClient = useOpenAIChat ? Utils.CreateAzureOpenAIClient(openAIEndpoint, useManagedIdentity) - .AsChatClient("chat") + .GetChatClient("chat") + .AsIChatClient() : new OllamaApiClient(new Uri(ollamaEndpoint), "llama3.2"); IEmbeddingGenerator> embeddingGenerator = useOpenAIEmbeddings ? Utils.CreateAzureOpenAIClient(openAIEndpoint, useManagedIdentity) - .AsEmbeddingGenerator("embeddingsmall") : + .GetEmbeddingClient("embeddingsmall") + .AsIEmbeddingGenerator() : new OllamaApiClient(new Uri(ollamaEndpoint), "all-minilm"); // Configure product manual service diff --git a/src/microsoft-extensions-ai/abstraction-implementations/AbstractionImplementationExamples/AbstractionImplementationExamples.csproj b/src/microsoft-extensions-ai/abstraction-implementations/AbstractionImplementationExamples/AbstractionImplementationExamples.csproj index 399f051..1d74419 100644 --- a/src/microsoft-extensions-ai/abstraction-implementations/AbstractionImplementationExamples/AbstractionImplementationExamples.csproj +++ b/src/microsoft-extensions-ai/abstraction-implementations/AbstractionImplementationExamples/AbstractionImplementationExamples.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/AzureAIInferenceExamples.csproj b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/AzureAIInferenceExamples.csproj index da8d035..0977ce0 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/AzureAIInferenceExamples.csproj +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/AzureAIInferenceExamples.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Caching.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Caching.cs index 2c6c92d..76590c5 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Caching.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Caching.cs @@ -16,7 +16,7 @@ public static async Task Caching() var endpoint = new Uri("https://models.inference.ai.azure.com"); var credential = new AzureKeyCredential(Environment.GetEnvironmentVariable("GH_TOKEN")); - IChatClient client = new ChatCompletionsClient(endpoint, credential).AsChatClient("gpt-4o-mini") + IChatClient client = new ChatCompletionsClient(endpoint, credential).AsIChatClient("gpt-4o-mini") .AsBuilder() .UseDistributedCache(cache) .Build(); diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Chat.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Chat.cs index 0570f43..c4c0123 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Chat.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Chat.cs @@ -12,7 +12,7 @@ public static async Task Chat() IChatClient client = new ChatCompletionsClient(endpoint, credential) - .AsChatClient(modelId); + .AsIChatClient(modelId); Console.WriteLine(await client.GetResponseAsync("What is AI?")); } diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ConversationHistory.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ConversationHistory.cs index 016b816..29b3ee1 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ConversationHistory.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ConversationHistory.cs @@ -12,7 +12,7 @@ public static async Task ConversationHistory() var credential = new AzureKeyCredential(Environment.GetEnvironmentVariable("GH_TOKEN")); IChatClient client = - new ChatCompletionsClient(endpoint, credential).AsChatClient(modelId); + new ChatCompletionsClient(endpoint, credential).AsIChatClient(modelId); List conversation = [ diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/DependencyInjection.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/DependencyInjection.cs index 6ecdd8d..aacfd65 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/DependencyInjection.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/DependencyInjection.cs @@ -17,7 +17,7 @@ public static async Task DependencyInjection() builder.Services.AddDistributedMemoryCache(); builder.Services.AddChatClient(services => services.GetRequiredService() - .AsChatClient("gpt-4o-mini")) + .AsIChatClient("gpt-4o-mini")) .UseDistributedCache() .Build(); diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Middleware.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Middleware.cs index cb8311a..46cda9e 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Middleware.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Middleware.cs @@ -39,7 +39,7 @@ public static async Task Middleware() var aiInferenceClient = new Azure.AI.Inference.ChatCompletionsClient(endpoint, credential) - .AsChatClient(modelId); + .AsIChatClient(modelId); var client = aiInferenceClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/OpenTelemetry.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/OpenTelemetry.cs index ce63164..13ebd9b 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/OpenTelemetry.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/OpenTelemetry.cs @@ -23,7 +23,7 @@ public static async Task OpenTelemetryExample() IChatClient aiInferenceClient = new ChatCompletionsClient(endpoint, credential) - .AsChatClient(modelId); + .AsIChatClient(modelId); IChatClient client = aiInferenceClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Streaming.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Streaming.cs index 7046b67..2c1cdb5 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Streaming.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/Streaming.cs @@ -10,7 +10,7 @@ public static async Task Streaming() var modelId = "gpt-4o-mini"; var credential = new AzureKeyCredential(Environment.GetEnvironmentVariable("GH_TOKEN")); - IChatClient client = new ChatCompletionsClient(endpoint, credential).AsChatClient(modelId); + IChatClient client = new ChatCompletionsClient(endpoint, credential).AsIChatClient(modelId); await foreach (var update in client.GetStreamingResponseAsync("What is AI?")) { diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbedding.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbedding.cs index 1578568..640c7da 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbedding.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbedding.cs @@ -11,9 +11,9 @@ public static async Task TextEmbedding() var credential = new AzureKeyCredential(Environment.GetEnvironmentVariable("GH_TOKEN")); IEmbeddingGenerator> generator = - new EmbeddingsClient(endpoint, credential).AsEmbeddingGenerator(modelId); + new EmbeddingsClient(endpoint, credential).AsIEmbeddingGenerator(modelId); - var embedding = await generator.GenerateEmbeddingVectorAsync("What is AI?"); + var embedding = await generator.GenerateVectorAsync("What is AI?"); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbeddingCaching.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbeddingCaching.cs index 61dda9f..a42a68f 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbeddingCaching.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/TextEmbeddingCaching.cs @@ -18,7 +18,7 @@ public static async Task TextEmbeddingCaching() var credential = new AzureKeyCredential(Environment.GetEnvironmentVariable("GH_TOKEN")); IEmbeddingGenerator> generator = - new EmbeddingsClient(endpoint, credential).AsEmbeddingGenerator(modelId) + new EmbeddingsClient(endpoint, credential).AsIEmbeddingGenerator(modelId) .AsBuilder() .UseDistributedCache(cache) .Build(); @@ -27,7 +27,7 @@ public static async Task TextEmbeddingCaching() foreach (var prompt in prompts) { - var embedding = await generator.GenerateEmbeddingVectorAsync(prompt); + var embedding = await generator.GenerateVectorAsync(prompt); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ToolCalling.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ToolCalling.cs index 6088202..cae295c 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ToolCalling.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIInferenceExamples/ToolCalling.cs @@ -20,7 +20,7 @@ public static async Task ToolCalling() var credential = new AzureKeyCredential(Environment.GetEnvironmentVariable("GH_TOKEN")); IChatClient client = - new ChatCompletionsClient(endpoint, credential).AsChatClient(modelId) + new ChatCompletionsClient(endpoint, credential).AsIChatClient(modelId) .AsBuilder() .UseFunctionInvocation() .Build(); diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/AzureAIWebAPI.csproj b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/AzureAIWebAPI.csproj index 8812cc0..d64d62d 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/AzureAIWebAPI.csproj +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/AzureAIWebAPI.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/Program.cs b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/Program.cs index 34f71a6..6c3dee9 100644 --- a/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/Program.cs +++ b/src/microsoft-extensions-ai/azure-ai-inference/AzureAIWebAPI/Program.cs @@ -16,7 +16,7 @@ new AzureKeyCredential(builder.Configuration["AI:AzureAIInference:Key"]))); builder.Services.AddChatClient(services => services.GetRequiredService() - .AsChatClient(builder.Configuration["AI:AzureAIInference:Chat:ModelId"])); + .AsIChatClient(builder.Configuration["AI:AzureAIInference:Chat:ModelId"])); var app = builder.Build(); diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/AzureOpenAIExamples.csproj b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/AzureOpenAIExamples.csproj index 028d3f6..ece9779 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/AzureOpenAIExamples.csproj +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/AzureOpenAIExamples.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Caching.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Caching.cs index cf597ba..8c41181 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Caching.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Caching.cs @@ -17,7 +17,8 @@ public static async Task Caching() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); IChatClient client = azureOpenAIClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Chat.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Chat.cs index 6055646..c872a74 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Chat.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Chat.cs @@ -10,7 +10,8 @@ public static async Task Chat() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsChatClient(modelId: "gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); Console.WriteLine(await client.GetResponseAsync("What is AI?")); } diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ConversationHistory.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ConversationHistory.cs index e929156..ed0f38f 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ConversationHistory.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ConversationHistory.cs @@ -10,7 +10,8 @@ public static async Task ConversationHistory() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsChatClient(modelId: "gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); List conversation = [ diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/DependencyInjection.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/DependencyInjection.cs index cc1c838..9f483b8 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/DependencyInjection.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/DependencyInjection.cs @@ -16,7 +16,7 @@ public static async Task DependencyInjection() new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential())); builder.Services.AddDistributedMemoryCache(); - builder.Services.AddChatClient(services => services.GetRequiredService().AsChatClient("gpt-4o-mini")) + builder.Services.AddChatClient(services => services.GetRequiredService().GetChatClient("gpt-4o-mini").AsIChatClient()) .UseDistributedCache(); var app = builder.Build(); diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Middleware.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Middleware.cs index ec53a29..a3234d2 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Middleware.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Middleware.cs @@ -38,7 +38,8 @@ public static async Task Middleware() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); IChatClient client = azureOpenAIClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/OpenTelemetry.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/OpenTelemetry.cs index 681aead..1c5e469 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/OpenTelemetry.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/OpenTelemetry.cs @@ -21,7 +21,8 @@ public static async Task OpenTelemetryExample() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); IChatClient client = azureOpenAIClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Streaming.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Streaming.cs index 886b572..61966a1 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Streaming.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/Streaming.cs @@ -10,7 +10,8 @@ public static async Task Streaming() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsChatClient(modelId: "gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); await foreach (var update in client.GetStreamingResponseAsync("What is AI?")) { diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbedding.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbedding.cs index 118002a..91248f0 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbedding.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbedding.cs @@ -10,9 +10,10 @@ public static async Task TextEmbedding() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsEmbeddingGenerator("text-embedding-3-small"); + .GetEmbeddingClient("text-embedding-3-small") + .AsIEmbeddingGenerator(); - var embedding = await generator.GenerateEmbeddingVectorAsync("What is AI?"); + var embedding = await generator.GenerateVectorAsync("What is AI?"); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbeddingCaching.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbeddingCaching.cs index ce3ffa2..91fffd3 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbeddingCaching.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/TextEmbeddingCaching.cs @@ -17,7 +17,8 @@ public static async Task TextEmbeddingCaching() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsEmbeddingGenerator("text-embedding-3-small"); + .GetEmbeddingClient("text-embedding-3-small") + .AsIEmbeddingGenerator(); IEmbeddingGenerator> generator = azureOpenAIGenerator .AsBuilder() @@ -28,7 +29,7 @@ public static async Task TextEmbeddingCaching() foreach (var prompt in prompts) { - var embedding = await generator.GenerateEmbeddingVectorAsync(prompt); + var embedding = await generator.GenerateVectorAsync(prompt); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ToolCalling.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ToolCalling.cs index 0a14604..786c422 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ToolCalling.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIExamples/ToolCalling.cs @@ -19,7 +19,8 @@ public static async Task ToolCalling() new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")), new DefaultAzureCredential()) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); IChatClient client = azureOpenAIClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/AzureOpenAIWebAPI.csproj b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/AzureOpenAIWebAPI.csproj index 8397767..e420972 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/AzureOpenAIWebAPI.csproj +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/AzureOpenAIWebAPI.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/Program.cs b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/Program.cs index 057ab29..51e3cec 100644 --- a/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/Program.cs +++ b/src/microsoft-extensions-ai/azure-openai/AzureOpenAIWebAPI/Program.cs @@ -17,10 +17,12 @@ )); builder.Services.AddChatClient(services => services.GetRequiredService() - .AsChatClient(builder.Configuration["AI:AzureOpenAI:Chat:ModelId"] ?? "gpt-4o-mini")); + .GetChatClient(builder.Configuration["AI:AzureOpenAI:Chat:ModelId"] ?? "gpt-4o-mini") + .AsIChatClient()); builder.Services.AddEmbeddingGenerator(services => services.GetRequiredService() - .AsEmbeddingGenerator(builder.Configuration["AI:AzureOpenAI:Embedding:ModelId"] ?? "text-embedding-3-small")); + .GetEmbeddingClient(builder.Configuration["AI:AzureOpenAI:Embedding:ModelId"] ?? "text-embedding-3-small") + .AsIEmbeddingGenerator()); var app = builder.Build(); @@ -28,6 +30,6 @@ await client.GetResponseAsync(message, cancellationToken: default)); app.MapPost("/embedding", async (IEmbeddingGenerator> client, [FromBody] string message) => - await client.GenerateEmbeddingAsync(message)); + await client.GenerateAsync(message)); app.Run(); diff --git a/src/microsoft-extensions-ai/ollama/OllamaExamples/OllamaExamples.csproj b/src/microsoft-extensions-ai/ollama/OllamaExamples/OllamaExamples.csproj index 4b54751..a1b69af 100644 --- a/src/microsoft-extensions-ai/ollama/OllamaExamples/OllamaExamples.csproj +++ b/src/microsoft-extensions-ai/ollama/OllamaExamples/OllamaExamples.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbedding.cs b/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbedding.cs index b00329a..b973f3e 100644 --- a/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbedding.cs +++ b/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbedding.cs @@ -9,7 +9,7 @@ public static async Task TextEmbedding() IEmbeddingGenerator> generator = new OllamaEmbeddingGenerator(endpoint, modelId: modelId); - var embedding = await generator.GenerateEmbeddingVectorAsync("What is AI?"); + var embedding = await generator.GenerateVectorAsync("What is AI?"); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbeddingCaching.cs b/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbeddingCaching.cs index 25f9fa1..588d442 100644 --- a/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbeddingCaching.cs +++ b/src/microsoft-extensions-ai/ollama/OllamaExamples/TextEmbeddingCaching.cs @@ -23,7 +23,7 @@ public static async Task TextEmbeddingCaching() foreach(var prompt in prompts) { - var embedding = await generator.GenerateEmbeddingVectorAsync("What is AI?"); + var embedding = await generator.GenerateVectorAsync("What is AI?"); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/ollama/OllamaWebAPI/OllamaWebAPI.csproj b/src/microsoft-extensions-ai/ollama/OllamaWebAPI/OllamaWebAPI.csproj index 374105e..56727b7 100644 --- a/src/microsoft-extensions-ai/ollama/OllamaWebAPI/OllamaWebAPI.csproj +++ b/src/microsoft-extensions-ai/ollama/OllamaWebAPI/OllamaWebAPI.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/microsoft-extensions-ai/ollama/OllamaWebAPI/Program.cs b/src/microsoft-extensions-ai/ollama/OllamaWebAPI/Program.cs index f325137..92524e5 100644 --- a/src/microsoft-extensions-ai/ollama/OllamaWebAPI/Program.cs +++ b/src/microsoft-extensions-ai/ollama/OllamaWebAPI/Program.cs @@ -22,6 +22,6 @@ await client.GetResponseAsync(message, cancellationToken: default)); app.MapPost("/embedding", async (IEmbeddingGenerator> client, [FromBody] string message) => - await client.GenerateEmbeddingAsync(message)); + await client.GenerateAsync(message)); app.Run(); diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/Caching.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/Caching.cs index 93a525e..8bcd429 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/Caching.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/Caching.cs @@ -14,7 +14,7 @@ public static async Task Caching() IChatClient openaiClient = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini").AsIChatClient(); IChatClient client = openaiClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/Chat.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/Chat.cs index 5e3f614..3edbe73 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/Chat.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/Chat.cs @@ -7,7 +7,8 @@ public static async Task Chat() { IChatClient client = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); Console.WriteLine(await client.GetResponseAsync("What is AI?")); } diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/ConversationHistory.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/ConversationHistory.cs index a7d604e..f6b9b2b 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/ConversationHistory.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/ConversationHistory.cs @@ -7,7 +7,8 @@ public static async Task ConversationHistory() { IChatClient client = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); List conversation = [ diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/DependencyInjection.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/DependencyInjection.cs index 5235d21..c969a54 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/DependencyInjection.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/DependencyInjection.cs @@ -11,7 +11,7 @@ public static async Task DependencyInjection() builder.Services.AddSingleton(new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY"))); builder.Services.AddDistributedMemoryCache(); - builder.Services.AddChatClient(services => services.GetRequiredService().AsChatClient("gpt-4o-mini")) + builder.Services.AddChatClient(services => services.GetRequiredService().GetChatClient("gpt-4o-mini").AsIChatClient()) .UseDistributedCache(); var app = builder.Build(); diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/Middleware.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/Middleware.cs index 761b8ac..fa9f236 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/Middleware.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/Middleware.cs @@ -35,7 +35,7 @@ public static async Task Middleware() IChatClient openaiClient = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini").AsIChatClient(); IChatClient client = openaiClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenAIExamples.csproj b/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenAIExamples.csproj index f0d76ef..26e6155 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenAIExamples.csproj +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenAIExamples.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenTelemetry.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenTelemetry.cs index 50cce19..ab2b025 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenTelemetry.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/OpenTelemetry.cs @@ -18,7 +18,7 @@ public static async Task OpenTelemetryExample() IChatClient openaiClient = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini").AsIChatClient(); IChatClient client = openaiClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/Streaming.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/Streaming.cs index ede1c34..cce9acc 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/Streaming.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/Streaming.cs @@ -7,7 +7,7 @@ public static async Task Streaming() { IChatClient client = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini").AsIChatClient(); await foreach (var update in client.GetStreamingResponseAsync("What is AI?")) { diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbedding.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbedding.cs index 0e037f3..ada6509 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbedding.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbedding.cs @@ -7,9 +7,10 @@ public static async Task TextEmbedding() { IEmbeddingGenerator> generator = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsEmbeddingGenerator("text-embedding-3-small"); + .GetEmbeddingClient("text-embedding-3-small") + .AsIEmbeddingGenerator(); - var embedding = await generator.GenerateEmbeddingVectorAsync("What is AI?"); + var embedding = await generator.GenerateVectorAsync("What is AI?"); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbeddingCaching.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbeddingCaching.cs index daa6cb4..927cbdd 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbeddingCaching.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/TextEmbeddingCaching.cs @@ -14,7 +14,8 @@ public static async Task TextEmbeddingCaching() IEmbeddingGenerator> openAIGenerator = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsEmbeddingGenerator("text-embedding-3-small"); + .GetEmbeddingClient("text-embedding-3-small") + .AsIEmbeddingGenerator(); IEmbeddingGenerator> generator = openAIGenerator .AsBuilder() @@ -25,7 +26,7 @@ public static async Task TextEmbeddingCaching() foreach (var prompt in prompts) { - var embedding = await generator.GenerateEmbeddingVectorAsync(prompt); + var embedding = await generator.GenerateVectorAsync(prompt); Console.WriteLine(string.Join(", ", embedding.ToArray())); } diff --git a/src/microsoft-extensions-ai/openai/OpenAIExamples/ToolCalling.cs b/src/microsoft-extensions-ai/openai/OpenAIExamples/ToolCalling.cs index 5c3cf6b..03bd88a 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIExamples/ToolCalling.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIExamples/ToolCalling.cs @@ -16,7 +16,8 @@ public static async Task ToolCalling() IChatClient openaiClient = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")) - .AsChatClient("gpt-4o-mini"); + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); IChatClient client = openaiClient .AsBuilder() diff --git a/src/microsoft-extensions-ai/openai/OpenAIWebAPI/OpenAIWebAPI.csproj b/src/microsoft-extensions-ai/openai/OpenAIWebAPI/OpenAIWebAPI.csproj index 0452e2c..7cc3f74 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIWebAPI/OpenAIWebAPI.csproj +++ b/src/microsoft-extensions-ai/openai/OpenAIWebAPI/OpenAIWebAPI.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/microsoft-extensions-ai/openai/OpenAIWebAPI/Program.cs b/src/microsoft-extensions-ai/openai/OpenAIWebAPI/Program.cs index 9ecb134..18c6450 100644 --- a/src/microsoft-extensions-ai/openai/OpenAIWebAPI/Program.cs +++ b/src/microsoft-extensions-ai/openai/OpenAIWebAPI/Program.cs @@ -12,10 +12,10 @@ builder.Services.AddSingleton(new OpenAIClient(builder.Configuration["AI:OpenAI:Key"])); builder.Services.AddChatClient(services => - services.GetRequiredService().AsChatClient(builder.Configuration["AI:OpenAI:Chat:ModelId"] ?? "gpt-4o-mini")); + services.GetRequiredService().GetChatClient(builder.Configuration["AI:OpenAI:Chat:ModelId"] ?? "gpt-4o-mini").AsIChatClient()); builder.Services.AddEmbeddingGenerator(services => - services.GetRequiredService().AsEmbeddingGenerator(builder.Configuration["AI:OpenAI:Embedding:ModelId"] ?? "text-embedding-3-small")); + services.GetRequiredService().GetEmbeddingClient(builder.Configuration["AI:OpenAI:Embedding:ModelId"] ?? "text-embedding-3-small").AsIEmbeddingGenerator()); var app = builder.Build(); @@ -23,6 +23,6 @@ await client.GetResponseAsync(message, cancellationToken: default)); app.MapPost("/embedding", async (IEmbeddingGenerator> client, [FromBody] string message) => - await client.GenerateEmbeddingAsync(message)); + await client.GenerateAsync(message)); app.Run(); diff --git a/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj b/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj index 6291156..e1c60f0 100644 --- a/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj +++ b/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/Program.cs b/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/Program.cs index 959ec7c..5d2bf28 100644 --- a/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/Program.cs +++ b/src/quickstarts/azure-openai/extensions-ai/01-HikeBenefitsSummary/Program.cs @@ -17,7 +17,8 @@ IChatClient client = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential(new DefaultAzureCredentialOptions())) - .AsChatClient(deployment); + .GetChatClient(deployment) + .AsIChatClient(); // Create and print out the prompt string prompt = $""" diff --git a/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/ChatAppAI.csproj b/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/ChatAppAI.csproj index a99f6e7..b6a3a82 100644 --- a/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/ChatAppAI.csproj +++ b/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/ChatAppAI.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/Program.cs b/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/Program.cs index 897687b..46975d5 100644 --- a/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/Program.cs +++ b/src/quickstarts/azure-openai/extensions-ai/02-build-chat-app/Program.cs @@ -13,7 +13,8 @@ IChatClient chatClient = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential()) - .AsChatClient(deployment); + .GetChatClient(deployment) + .AsIChatClient(); // Start the conversation with context for the AI model List chatHistory = new() diff --git a/src/quickstarts/azure-openai/extensions-ai/04-function-calling/FunctionCallingAI.csproj b/src/quickstarts/azure-openai/extensions-ai/04-function-calling/FunctionCallingAI.csproj index 0f999cc..90ae1e7 100644 --- a/src/quickstarts/azure-openai/extensions-ai/04-function-calling/FunctionCallingAI.csproj +++ b/src/quickstarts/azure-openai/extensions-ai/04-function-calling/FunctionCallingAI.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/quickstarts/azure-openai/extensions-ai/04-function-calling/Program.cs b/src/quickstarts/azure-openai/extensions-ai/04-function-calling/Program.cs index d0b54e7..52d8fd3 100644 --- a/src/quickstarts/azure-openai/extensions-ai/04-function-calling/Program.cs +++ b/src/quickstarts/azure-openai/extensions-ai/04-function-calling/Program.cs @@ -12,7 +12,7 @@ string deployment = config["AZURE_OPENAI_GPT_NAME"]; IChatClient client = - new ChatClientBuilder(new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential()).AsChatClient(deployment)) + new ChatClientBuilder(new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential()).GetChatClient(deployment).AsIChatClient()) .UseFunctionInvocation() .Build(); @@ -39,5 +39,5 @@ You are a hiking enthusiast who helps people discover fun hikes in their area. Y Console.WriteLine($"{chatHistory.Last().Role} >>> {chatHistory.Last()}"); var response = await client.GetResponseAsync(chatHistory, chatOptions); -chatHistory.Add(new ChatMessage(ChatRole.Assistant, response.Message.Contents)); +chatHistory.Add(new ChatMessage(ChatRole.Assistant, response.Text)); Console.WriteLine($"{chatHistory.Last().Role} >>> {chatHistory.Last()}"); diff --git a/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj b/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj index 0b7be1f..9c9902e 100644 --- a/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj +++ b/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/01-HikeBenefitsSummary.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/Program.cs b/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/Program.cs index 1338118..817c95a 100644 --- a/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/Program.cs +++ b/src/quickstarts/openai/extensions-ai/01-HikeBenefitsSummary/Program.cs @@ -15,7 +15,7 @@ // Create the IChatClient IChatClient client = - new OpenAIClient(key).AsChatClient(model); + new OpenAIClient(key).GetChatClient(model).AsIChatClient(); // Create and print out the prompt string prompt = $""" diff --git a/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/ExtensionsOpenAI.csproj b/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/ExtensionsOpenAI.csproj index 45e6945..d3a30eb 100644 --- a/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/ExtensionsOpenAI.csproj +++ b/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/ExtensionsOpenAI.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/Program.cs b/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/Program.cs index 28bd2b2..a0ec976 100644 --- a/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/Program.cs +++ b/src/quickstarts/openai/extensions-ai/02-build-chat-app/openai/Program.cs @@ -1,4 +1,8 @@ -using Microsoft.Extensions.Configuration; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.AI; using OpenAI; @@ -8,7 +12,7 @@ // Create the IChatClient IChatClient chatClient = - new OpenAIClient(key).AsChatClient(model ?? "gpt-4o"); + new OpenAIClient(key).GetChatClient(model ?? "gpt-4o").AsIChatClient(); // Start the conversation with context for the AI model List chatHistory = new() diff --git a/src/quickstarts/openai/extensions-ai/04-function-calling/openai/FunctionCallingAI.csproj b/src/quickstarts/openai/extensions-ai/04-function-calling/openai/FunctionCallingAI.csproj index 5b333cc..a5faa7b 100644 --- a/src/quickstarts/openai/extensions-ai/04-function-calling/openai/FunctionCallingAI.csproj +++ b/src/quickstarts/openai/extensions-ai/04-function-calling/openai/FunctionCallingAI.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/src/quickstarts/openai/extensions-ai/04-function-calling/openai/Program.cs b/src/quickstarts/openai/extensions-ai/04-function-calling/openai/Program.cs index 0e36942..7b24363 100644 --- a/src/quickstarts/openai/extensions-ai/04-function-calling/openai/Program.cs +++ b/src/quickstarts/openai/extensions-ai/04-function-calling/openai/Program.cs @@ -1,4 +1,8 @@ -using Microsoft.Extensions.AI; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Extensions.AI; using Microsoft.Extensions.Configuration; using OpenAI; @@ -7,7 +11,7 @@ string? key = config["OpenAIKey"]; IChatClient client = - new ChatClientBuilder(new OpenAIClient(key).AsChatClient(model ?? "gpt-4o")) + new ChatClientBuilder(new OpenAIClient(key).GetChatClient(model ?? "gpt-4o").AsIChatClient()) .UseFunctionInvocation() .Build(); @@ -34,5 +38,5 @@ You are a hiking enthusiast who helps people discover fun hikes in their area. Y Console.WriteLine($"{chatHistory.Last().Role} >>> {chatHistory.Last()}"); var response = await client.GetResponseAsync(chatHistory, chatOptions); -chatHistory.Add(new ChatMessage(ChatRole.Assistant, response.Message.Contents)); +chatHistory.Add(new ChatMessage(ChatRole.Assistant, response.Text)); Console.WriteLine($"{chatHistory.Last().Role} >>> {chatHistory.Last()}");