feat: 新增claude接口转换支持

This commit is contained in:
chenchun
2025-10-11 15:25:43 +08:00
parent 29dc1ae250
commit 345ed80ec8
21 changed files with 2161 additions and 30 deletions

View File

@@ -10,6 +10,8 @@ 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.ThorClaude.Chats;
using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorCustomOpenAI.Chats;
using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorDeepSeek.Chats;
using Yi.Framework.AiHub.Domain.AiGateWay.Impl.ThorSiliconFlow.Embeddings;
using Yi.Framework.AiHub.Domain.Managers.Fuwuhao;
@@ -31,21 +33,43 @@ namespace Yi.Framework.AiHub.Domain
var configuration = context.Services.GetConfiguration();
var services = context.Services;
// Configure<AiGateWayOptions>(configuration.GetSection("AiGateWay"));
#region OpenAi ChatCompletion
services.AddKeyedTransient<IChatCompletionService, AzureOpenAiChatCompletionCompletionsService>(
nameof(AzureOpenAiChatCompletionCompletionsService));
services.AddKeyedTransient<IChatCompletionService, AzureDatabricksChatCompletionsService>(
nameof(AzureDatabricksChatCompletionsService));
services.AddKeyedTransient<IChatCompletionService, DeepSeekChatCompletionsService>(
nameof(DeepSeekChatCompletionsService));
services.AddKeyedTransient<IChatCompletionService, OpenAiChatCompletionsService>(
nameof(OpenAiChatCompletionsService));
#endregion
#region Anthropic ChatCompletion
services.AddKeyedTransient<IAnthropicChatCompletionService, CustomOpenAIAnthropicChatCompletionsService>(
nameof(CustomOpenAIAnthropicChatCompletionsService));
services.AddKeyedTransient<IAnthropicChatCompletionService, AnthropicChatCompletionsService>(
nameof(AnthropicChatCompletionsService));
#endregion
#region Image
services.AddKeyedTransient<IImageService, AzureOpenAIServiceImageService>(
nameof(AzureOpenAIServiceImageService));
#endregion
#region Embedding
services.AddKeyedTransient<ITextEmbeddingService, SiliconFlowTextEmbeddingService>(
nameof(SiliconFlowTextEmbeddingService));
#endregion
//ai模型特殊性兼容处理
Configure<SpecialCompatibleOptions>(options =>
{
@@ -82,20 +106,18 @@ namespace Yi.Framework.AiHub.Domain
request.MaxTokens = 16384;
}
});
options.AnthropicHandles.add(request => { });
});
//配置支付宝支付
var config = configuration.GetSection("Alipay").Get<Config>();
Factory.SetOptions(config);
//配置服务号
Configure<FuwuhaoOptions>(configuration.GetSection("Fuwuhao"));
services.AddHttpClient();
}
public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
{
}
}
}