34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using GymLogAI.Application.Interfaces;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace GymLogAI.AI;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddAiServices(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services
|
|
.AddOptions<OpenRouterOptions>()
|
|
.Bind(configuration.GetSection(OpenRouterOptions.SectionName));
|
|
|
|
services.AddHttpClient<OpenRouterChatClient>((serviceProvider, client) =>
|
|
{
|
|
var options = serviceProvider.GetRequiredService<Microsoft.Extensions.Options.IOptions<OpenRouterOptions>>().Value;
|
|
client.BaseAddress = new Uri(options.BaseUrl);
|
|
});
|
|
|
|
services.AddHttpClient<OpenRouterEmbeddingClient>((serviceProvider, client) =>
|
|
{
|
|
var options = serviceProvider.GetRequiredService<Microsoft.Extensions.Options.IOptions<OpenRouterOptions>>().Value;
|
|
client.BaseAddress = new Uri(options.BaseUrl);
|
|
});
|
|
|
|
services.AddScoped<IWorkoutParser, WorkoutParserAIService>();
|
|
services.AddScoped<IWorkoutRecommendationGenerator, WorkoutRecommendationAIService>();
|
|
services.AddScoped<IEmbeddingService, StubEmbeddingService>();
|
|
|
|
return services;
|
|
}
|
|
}
|