using Alipay.EasySDK.Factory; using Alipay.EasySDK.Kernel; using Alipay.EasySDK.Kernel.Util; using Alipay.EasySDK.Payment.FaceToFace.Models; using Dm.util; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Domain; using Yi.Framework.AiHub.Domain.AiGateWay; using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorAzureDatabricks.Chats; using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorAzureOpenAI.Chats; using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorAzureOpenAI.Images; using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorDeepSeek.Chats; using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorSiliconFlow.Embeddings; using Yi.Framework.AiHub.Domain.Shared; using Yi.Framework.AiHub.Domain.Shared.Dtos.OpenAi; using Yi.Framework.Mapster; namespace Yi.Framework.AiHub.Domain { [DependsOn( typeof(YiFrameworkAiHubDomainSharedModule), typeof(YiFrameworkMapsterModule), typeof(AbpDddDomainModule) )] public class YiFrameworkAiHubDomainModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { var configuration = context.Services.GetConfiguration(); var services = context.Services; // Configure(configuration.GetSection("AiGateWay")); services.AddKeyedTransient( nameof(AzureOpenAiChatCompletionCompletionsService)); services.AddKeyedTransient( nameof(AzureDatabricksChatCompletionsService)); services.AddKeyedTransient( nameof(DeepSeekChatCompletionsService)); services.AddKeyedTransient( nameof(AzureOpenAIServiceImageService)); services.AddKeyedTransient( nameof(SiliconFlowTextEmbeddingService)); //ai模型特殊性兼容处理 Configure(options => { options.Handles.add(request => { request.CompatibleCodeCompletion(); }); options.Handles.Add(request => { if (request.Model == "o1") { request.Temperature = null; } }); options.Handles.Add(request => { if (request.Model.StartsWith("o3-mini") || request.Model.StartsWith("o4-mini")) { request.MaxCompletionTokens = request.MaxTokens; request.MaxTokens = null; request.Temperature = null; } }); options.Handles.Add(request => { if (request.Stream == true) { request.StreamOptions = new ThorStreamOptions() { IncludeUsage = true }; } }); }); //配置支付宝支付 var config = configuration.GetSection("Alipay").Get(); Factory.SetOptions(config); } public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context) { try { // 2. 发起API调用(以创建当面付收款二维码为例) var response = Factory.Payment.Page() .Pay("YiXin Ai Vip", "2234567234891", "0.01","https://ccnetcore.com/pay/Alipay/test"); // 3. 处理响应或异常 if (ResponseChecker.Success(response)) { Console.WriteLine("调用成功"); Console.WriteLine(response.Body); } else { Console.WriteLine("调用失败,原因:" + response.Body); } } catch (Exception ex) { Console.WriteLine("调用遭遇异常,原因:" + ex.Message); throw ex; } } } }