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 3ce577228..f1c646086 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 @@ -1,9 +1,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using System; +using System.Collections.Generic; using System.Globalization; using System.Net.Http; using System.Net.Http.Headers; +using System.Text; using System.Threading.Tasks; using Volo.Abp.Http.Client.Authentication; using Volo.Abp.MultiTenancy; @@ -20,7 +22,7 @@ public class HttpAITool Context = context; } - public async virtual Task InvokeAsync() + public async virtual Task InvokeAsync(IDictionary? paramters = null) { // Abp远程服务适配 //var remoteService = Context.ToolDefinition.GetRemoteServiceOrNull(); @@ -63,14 +65,35 @@ public class HttpAITool var httpClientFactory = Context.ServiceProvider.GetRequiredService(); var httpClient = httpClientFactory.CreateHttpAIToolClient(); + var requestUri = Context.ToolDefinition.GetHttpEndpoint(); + + if (paramters?.Count > 0) + { + var isFirstParam = true; + var urlBuilder = new StringBuilder(); + foreach (var paramter in paramters) + { + if (paramter.Value == null) + { + continue; + } + urlBuilder.Append(isFirstParam ? "?" : "&"); + urlBuilder.Append(paramter.Key + $"=" + System.Net.WebUtility.UrlEncode(paramter.Value.ToString())); + + isFirstParam = false; + } + + requestUri = requestUri.RemovePostFix("/") + urlBuilder.ToString(); + } + var httpRequestMessage = new HttpRequestMessage( Context.ToolDefinition.GetHttpMethod(), - Context.ToolDefinition.GetHttpEndpoint()); + requestUri); var headers = Context.ToolDefinition.GetHttpHeaders(); foreach (var header in headers) { - httpRequestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value); + httpRequestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value.ToString()); } if (Context.ToolDefinition.IsUseHttpCurrentAccessToken()) diff --git a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/en.json b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/en.json index 36672f8ec..cfefdb598 100644 --- a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/en.json +++ b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/en.json @@ -1,7 +1,7 @@ { "culture": "en", "texts": { - "Tools:GetApplicationConfiguration": "Get Application Configuration", + "Tools:GetApplicationConfiguration": "Get the application configuration. When the user does not explicitly request it, the IncludeLocalizationResources parameter needs to be passed, with the parameter value set to false.", "HttpAITool:Endpoint": "Endpoint", "HttpAITool:Method": "Method", "HttpAITool:Headers": "Headers", diff --git a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/zh-Hans.json b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/zh-Hans.json index 4f62a73de..9afdba714 100644 --- a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Tools.Http/LINGYUN/Abp/AI/Tools/Http/Localization/Resources/zh-Hans.json @@ -1,7 +1,7 @@ { "culture": "zh-Hans", "texts": { - "Tools:GetApplicationConfiguration": "获取应用程序配置", + "Tools:GetApplicationConfiguration": "获取应用程序配置, 用户未明确要求时需要传递IncludeLocalizationResources参数,参数值为false.", "HttpAITool:Endpoint": "请求地址", "HttpAITool:Method": "请求方法", "HttpAITool:Headers": "请求头",