-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAIConfigurationState.cs
More file actions
36 lines (29 loc) · 996 Bytes
/
AIConfigurationState.cs
File metadata and controls
36 lines (29 loc) · 996 Bytes
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
namespace EssentialCSharp.Chat;
public enum AIServiceMode
{
Disabled,
Local,
Azure
}
public sealed record AIConfigurationState(AIServiceMode Mode)
{
public const string DevelopmentUnavailableMessage =
"AI chat is unavailable for this local run. Start the site with Aspire local AI or configure Azure AI to enable chat.";
public bool IsAvailable => Mode is AIServiceMode.Local or AIServiceMode.Azure;
public bool IsDisabled => Mode == AIServiceMode.Disabled;
public bool UsesLocalAI => Mode == AIServiceMode.Local;
public bool UsesAzureAI => Mode == AIServiceMode.Azure;
public static AIConfigurationState From(AIOptions? options)
{
options ??= new AIOptions();
if (!string.IsNullOrWhiteSpace(options.Endpoint))
{
return new(AIServiceMode.Azure);
}
if (options.UseLocalAI)
{
return new(AIServiceMode.Local);
}
return new(AIServiceMode.Disabled);
}
}