From 174329b690dc49c13af3a75e88922792b1dac520 Mon Sep 17 00:00:00 2001 From: Mackinnon Buck Date: Tue, 8 Apr 2025 09:31:34 -0700 Subject: [PATCH 1/3] Update Microsoft.Extensions.AI version --- core/KendoCoreService/Controllers/LLMController.cs | 7 ++++--- core/KendoCoreService/KendoCoreService.csproj | 6 +++--- core/KendoCoreService/Program.cs | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/KendoCoreService/Controllers/LLMController.cs b/core/KendoCoreService/Controllers/LLMController.cs index c68510f..232c44e 100644 --- a/core/KendoCoreService/Controllers/LLMController.cs +++ b/core/KendoCoreService/Controllers/LLMController.cs @@ -43,7 +43,7 @@ public async Task AIChatCompletion([FromBody] IList messages.Prepend(new ChatMessage(ChatRole.System, DefaultSystemPrompt)); } - var response = await _chatClient.CompleteAsync(messages, options); + var response = await _chatClient.GetResponseAsync(messages, options); return Json(response); } @@ -53,14 +53,15 @@ private void ValidateMessagesLength(IList messages) { var tokenizer = GptEncoding.GetEncoding("cl100k_base"); - foreach (var message in messages) + for (var i = 0; i < messages.Count; i++) { + var message = messages[i]; var tokens = tokenizer.Encode(message.Text); if (tokens.Count > 1000) { var truncatedTokens = tokens.Take(1000).ToList(); - message.Text = tokenizer.Decode(truncatedTokens); + messages[i] = new ChatMessage(message.Role, tokenizer.Decode(truncatedTokens)); } } } diff --git a/core/KendoCoreService/KendoCoreService.csproj b/core/KendoCoreService/KendoCoreService.csproj index 452f709..665e1b7 100644 --- a/core/KendoCoreService/KendoCoreService.csproj +++ b/core/KendoCoreService/KendoCoreService.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -10,8 +10,8 @@ - - + + diff --git a/core/KendoCoreService/Program.cs b/core/KendoCoreService/Program.cs index 430b887..c8c25ed 100644 --- a/core/KendoCoreService/Program.cs +++ b/core/KendoCoreService/Program.cs @@ -30,7 +30,7 @@ )); 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.AddControllers() .AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); From 6aff6696dcce66f8593765d6e6411857e5196856 Mon Sep 17 00:00:00 2001 From: Mackinnon Buck Date: Thu, 1 May 2025 16:21:30 -0700 Subject: [PATCH 2/3] Update MEAI version to 9.4.3-preview.1.25230.7 --- core/KendoCoreService/KendoCoreService.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/KendoCoreService/KendoCoreService.csproj b/core/KendoCoreService/KendoCoreService.csproj index 665e1b7..a8a18f5 100644 --- a/core/KendoCoreService/KendoCoreService.csproj +++ b/core/KendoCoreService/KendoCoreService.csproj @@ -10,8 +10,8 @@ - - + + From 04dc17ab17d9308faed6a0f3946bf675f75bcfaa Mon Sep 17 00:00:00 2001 From: Mackinnon Buck Date: Mon, 12 May 2025 14:38:33 -0700 Subject: [PATCH 3/3] Update MEAI version to 9.4.4-preview.1.25259.16 --- core/KendoCoreService/KendoCoreService.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/KendoCoreService/KendoCoreService.csproj b/core/KendoCoreService/KendoCoreService.csproj index a8a18f5..b79d39f 100644 --- a/core/KendoCoreService/KendoCoreService.csproj +++ b/core/KendoCoreService/KendoCoreService.csproj @@ -10,8 +10,8 @@ - - + +