yavsc/src/Yavsc.Org/Program.cs

41 lines
1.4 KiB
C#
Raw Normal View History

2023-03-19 17:57:55 +00:00
2026-05-30 18:20:17 +01:00
using Anthropic.SDK;
2023-03-20 21:48:32 +00:00
using Microsoft.AspNetCore;
2026-05-30 18:20:17 +01:00
using Yavsc.Abstract.Interfaces;
2024-11-06 13:00:34 +00:00
using Yavsc.Extensions;
2023-03-19 17:57:55 +00:00
2023-03-20 21:48:32 +00:00
namespace Yavsc
2023-03-19 17:57:55 +00:00
{
2023-03-26 20:41:42 +01:00
public class Program
2023-03-20 21:48:32 +00:00
{
2025-06-29 11:52:57 +01:00
public static async Task Main(string[] args)
2023-03-20 21:48:32 +00:00
{
2024-02-25 18:05:10 +00:00
var builder = WebApplication.CreateBuilder(args);
2026-05-30 18:20:17 +01:00
// Anthropic client
builder.Services.AddSingleton<AnthropicClient>(_ =>
new AnthropicClient(
new APIAuthentication(
builder.Configuration["ANTHROPIC_API_KEY"]
?? throw new InvalidOperationException("ANTHROPIC_API_KEY manquante")
)
)
);
// Service de modération
if (builder.Environment.IsDevelopment())
builder.Services.AddScoped<IModerationService, MockModerationService>();
else
builder.Services.AddScoped<IModerationService, ClaudeModerationService>();
2024-11-06 13:00:34 +00:00
builder.Configuration
2026-05-30 18:20:17 +01:00
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables()
.Build();
2025-06-29 11:52:57 +01:00
var app = await builder.ConfigureWebAppServices().ConfigurePipeline();
2024-02-25 18:05:10 +00:00
app.Run();
2023-03-20 21:48:32 +00:00
}
}
2023-03-19 17:57:55 +00:00
}