From 9bea4fa503636c0c04f9d712277b6bb8e28560c3 Mon Sep 17 00:00:00 2001 From: enisn Date: Fri, 12 Sep 2025 16:07:00 +0300 Subject: [PATCH] Remove ChatClientWithTools due it's already possible by configuring default ME I --- .../Abp/AI/Delegates/ChatClientWithTools.cs | 73 ------------------- .../ChatClientWithToolsExtensions.cs | 21 ------ 2 files changed, 94 deletions(-) delete mode 100644 framework/src/Volo.Abp.AI.Abstractions/Volo/Abp/AI/Delegates/ChatClientWithTools.cs delete mode 100644 framework/src/Volo.Abp.AI/Volo/Abp/AI/Extensions/ChatClientWithToolsExtensions.cs diff --git a/framework/src/Volo.Abp.AI.Abstractions/Volo/Abp/AI/Delegates/ChatClientWithTools.cs b/framework/src/Volo.Abp.AI.Abstractions/Volo/Abp/AI/Delegates/ChatClientWithTools.cs deleted file mode 100644 index 92463a4dd9..0000000000 --- a/framework/src/Volo.Abp.AI.Abstractions/Volo/Abp/AI/Delegates/ChatClientWithTools.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.AI; - -namespace Volo.Abp.AI.Delegates; - -public class ChatClientWithTools : DelegatingChatClient -{ - public IList Tools { get; private set; } - - public ChatToolMode? ToolMode { get; private set; } - - public bool? AllowMultipleToolCalls { get; private set; } - - public ChatClientWithTools(IChatClient innerClient, IEnumerable tools, ChatToolMode? toolMode = null, bool? allowMultipleToolCalls = null) - : base(innerClient) - { - Tools = tools.ToList(); - ToolMode = toolMode; - AllowMultipleToolCalls = allowMultipleToolCalls; - } - - public override Task GetResponseAsync( - IEnumerable messages, - ChatOptions? options = null, - CancellationToken cancellationToken = default) - { - return base.GetResponseAsync( - messages, - BuildChatOptions(options), - cancellationToken - ); - } - - public override IAsyncEnumerable GetStreamingResponseAsync( - IEnumerable messages, - ChatOptions? options = null, - CancellationToken cancellationToken = default) - { - return base.GetStreamingResponseAsync( - messages, - BuildChatOptions(options), - cancellationToken - ); - } - - private ChatOptions BuildChatOptions(ChatOptions? options) - { - options ??= new ChatOptions(); - - options.Tools ??= new List(); - - foreach (var tool in Tools) - { - options.Tools.Add(tool); - } - - if (ToolMode is not null) - { - options.ToolMode = ToolMode; - } - - if (AllowMultipleToolCalls is not null) - { - options.AllowMultipleToolCalls = AllowMultipleToolCalls.Value; - } - - return options; - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AI/Volo/Abp/AI/Extensions/ChatClientWithToolsExtensions.cs b/framework/src/Volo.Abp.AI/Volo/Abp/AI/Extensions/ChatClientWithToolsExtensions.cs deleted file mode 100644 index 982e5bdbad..0000000000 --- a/framework/src/Volo.Abp.AI/Volo/Abp/AI/Extensions/ChatClientWithToolsExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.AI; -using Volo.Abp.AI.Delegates; - -namespace Volo.Abp.AI.Extensions; - -public static class ChatClientWithToolsExtensions -{ - public static ChatClientBuilder UseTools( - this ChatClientBuilder builder, - IEnumerable tools, - ChatToolMode? toolMode = null, - bool? allowMultipleToolCalls = null) - { - return builder.Use(chatClient - => new ChatClientWithTools(chatClient, tools, toolMode, allowMultipleToolCalls)); - } -} \ No newline at end of file