-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathImageGenServiceFactory.cs
More file actions
31 lines (28 loc) · 1.46 KB
/
ImageGenServiceFactory.cs
File metadata and controls
31 lines (28 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using MaIN.Domain.Configuration;
using MaIN.Services.Services.Abstract;
using MaIN.Services.Services.ImageGenServices;
using Microsoft.Extensions.DependencyInjection;
namespace MaIN.Services.Services.LLMService.Factory;
public class ImageGenServiceFactory(IServiceProvider serviceProvider) : IImageGenServiceFactory
{
public IImageGenService? CreateService(BackendType backendType)
{
return backendType switch
{
BackendType.OpenAi => new OpenAiImageGenService(serviceProvider.GetRequiredService<IHttpClientFactory>(),
serviceProvider.GetRequiredService<MaINSettings>()),
BackendType.Gemini => new GeminiImageGenService(serviceProvider.GetRequiredService<IHttpClientFactory>(),
serviceProvider.GetRequiredService<MaINSettings>()),
BackendType.DeepSeek => null,
BackendType.GroqCloud => null,
BackendType.Anthropic => null,
BackendType.Xai => new XaiImageGenService(serviceProvider.GetRequiredService<IHttpClientFactory>(),
serviceProvider.GetRequiredService<MaINSettings>()),
BackendType.Ollama => null,
BackendType.Self => new ImageGenService(serviceProvider.GetRequiredService<IHttpClientFactory>(),
serviceProvider.GetRequiredService<MaINSettings>()),
// Add other backends as needed
_ => throw new NotSupportedException("Not support image generation."),
};
}
}