feat: 初始化NewLife Studio项目,完成基础框架与数据管理模块
何炳宏 authored at 2026-05-26 12:09:09
820.00 B
NewLife.Studio
using NewLife.Studio.AI.Providers;

namespace NewLife.Studio.AI;

/// <summary>AI Provider 工厂</summary>
public static class AIProviderFactory
{
    /// <summary>根据 ProviderType 创建对应的 IAIProvider</summary>
    public static IAIProvider Create(HttpClient httpClient, string providerType, string endpoint, string apiKey, string model)
    {
        return providerType.ToLowerInvariant() switch
        {
            "openai" => new OpenAIProvider(httpClient, endpoint, apiKey, model),
            "azure" => new OpenAIProvider(httpClient, endpoint, apiKey, model), // Azure 也是兼容 API
            "ollama" => new OpenAIProvider(httpClient, endpoint, apiKey, model), // Ollama 也是兼容 API
            _ => throw new ArgumentException($"Unknown provider type: {providerType}")
        };
    }
}