-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (46 loc) · 1.98 KB
/
Program.cs
File metadata and controls
59 lines (46 loc) · 1.98 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using ProjectEvoDashboard.Components;
using ProjectEvoDashboard.Services;
using Microsoft.SemanticKernel;
using MudBlazor.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// Register LLM Chat Service
builder.Services.AddScoped<LlmChatService>();
// --- Hybrid Adapter & Services Registration ---
// 1. Register Kernel (MUST occur before SemanticKernelAiService)
var kernelBuilder = builder.Services.AddKernel();
builder.Services.AddMudServices(); // MudBlazor Registration
// 2. Configure OpenAI / Azure OpenAI
var aiProvider = builder.Configuration["LlmProvider:Provider"];
var aiEndpoint = builder.Configuration["LlmProvider:Endpoint"];
var aiKey = builder.Configuration["LlmProvider:ApiKey"];
var aiModel = builder.Configuration["LlmProvider:DeploymentName"];
if (!string.IsNullOrEmpty(aiEndpoint) && !string.IsNullOrEmpty(aiKey) && !string.IsNullOrEmpty(aiModel))
{
// ⚠️ Please configure your credentials in appsettings.json
kernelBuilder.AddAzureOpenAIChatCompletion(aiModel, aiEndpoint, aiKey);
Console.WriteLine($"✅ Azure OpenAI Configured: {aiModel}");
}
else
{
// Fallback or Log warning that AI services won't work without config
Console.WriteLine("⚠️ Warning: LlmProvider credentials not found in configuration.");
}
// 3. Register Application Services (Dependent on Kernel)
builder.Services.AddScoped<ProjectEvoDashboard.Services.AI.IAiService, ProjectEvoDashboard.Services.AI.SemanticKernelAiService>();
builder.Services.AddScoped<ProjectEvoDashboard.Services.AI.OpenAiNativeHandler>();
builder.Services.AddScoped<SkillEvolutionService>();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();