-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMauiProgram.cs
More file actions
56 lines (48 loc) · 1.68 KB
/
MauiProgram.cs
File metadata and controls
56 lines (48 loc) · 1.68 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
using DevBites.Services;
using DevBites.ViewModels;
using DevBites.Views;
using GeminiDotnet;
using GeminiDotnet.Extensions.AI;
using Microsoft.Extensions.AI;
using OllamaSharp;
using Microsoft.Extensions.Logging;
namespace DevBites
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
DotEnvLoader.Load();
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
// AI – switch provider via AI_PROVIDER in .env
IChatClient chatClient = Constants.AiProvider.ToLowerInvariant() switch
{
"ollama" => new OllamaApiClient(Constants.OllamaEndpoint, Constants.OllamaModel),
_ => new GeminiChatClient(new GeminiClientOptions
{
ApiKey = Constants.GeminiApiKey,
ModelId = Constants.GeminiModel
})
};
builder.Services.AddSingleton(chatClient);
// Services
builder.Services.AddSingleton<IAIContentService, AIContentService>();
builder.Services.AddSingleton<IFavoritesService, FavoritesService>();
// ViewModels
builder.Services.AddTransient<FeedViewModel>();
// Pages
builder.Services.AddTransient<FeedPage>();
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}