From fef156fbee02f69e101aaa75bf99a9bff695ae4f Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 21 May 2026 10:15:22 +0800 Subject: [PATCH] feat: Add request body to the http tool --- .../LINGYUN/Abp/AI/Tools/Http/HttpAITool.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/HttpAITool.cs b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/HttpAITool.cs index f1c646086..df2c7a791 100644 --- a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/HttpAITool.cs +++ b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/HttpAITool.cs @@ -8,6 +8,7 @@ using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using Volo.Abp.Http.Client.Authentication; +using Volo.Abp.Json; using Volo.Abp.MultiTenancy; using Volo.Abp.Timing; using Volo.Abp.Tracing; @@ -22,7 +23,9 @@ public class HttpAITool Context = context; } - public async virtual Task InvokeAsync(IDictionary? paramters = null) + public async virtual Task InvokeAsync( + IDictionary? paramters = null, + object? body = null) { // Abp远程服务适配 //var remoteService = Context.ToolDefinition.GetRemoteServiceOrNull(); @@ -90,6 +93,12 @@ public class HttpAITool Context.ToolDefinition.GetHttpMethod(), requestUri); + if (body != null) + { + var jsonSerializer = Context.ServiceProvider.GetRequiredService(); + httpRequestMessage.Content = new StringContent(jsonSerializer.Serialize(body)); + } + var headers = Context.ToolDefinition.GetHttpHeaders(); foreach (var header in headers) { @@ -148,6 +157,7 @@ public class HttpAITool //X-Requested-With requestMessage.Headers.Add("X-Requested-With", "XMLHttpRequest"); + requestMessage.Headers.Add("X-Requested-From", "abp-ai-httptool"); //Timezone var currentTimezoneProvider = Context.ServiceProvider.GetRequiredService();