-
Notifications
You must be signed in to change notification settings - Fork 4
/
MauiProgram.cs
46 lines (40 loc) · 1.5 KB
/
MauiProgram.cs
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
using System.ClientModel;
using Azure;
using Azure.AI.OpenAI;
using DevExpress.Maui;
using DevExpress.Maui.Core;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Logging;
namespace DevExpress.AI.Samples.MAUIBlazor;
public static class MauiProgram {
public static MauiApp CreateMauiApp() {
ThemeManager.ApplyThemeToSystemBars = true;
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseDevExpress()
.UseDevExpressCollectionView()
.UseDevExpressControls()
.UseDevExpressEditors()
.ConfigureFonts(fonts => {
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
string azureOpenAIEndpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
string azureOpenAIKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY");
builder.Services.AddMauiBlazorWebView();
builder.Services.AddDevExpressBlazor();
builder.Services.AddDevExpressAI();
builder.Services.AddChatClient(
new AzureOpenAIClient(
new Uri(azureOpenAIEndpoint),
new ApiKeyCredential(azureOpenAIKey)
).AsChatClient("gpt4o")
);
builder.Services.AddSingleton<ISelfEncapsulationService, DxChatEncapsulationService>();
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}