-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Expand file tree
/
Copy pathAIServiceTypeRegistry.cs
More file actions
189 lines (178 loc) · 7.73 KB
/
AIServiceTypeRegistry.cs
File metadata and controls
189 lines (178 loc) · 7.73 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.PowerToys.Settings.UI.Library;
/// <summary>
/// Centralized registry for AI service type metadata.
/// </summary>
public static class AIServiceTypeRegistry
{
private static readonly Dictionary<AIServiceType, AIServiceTypeMetadata> MetadataMap = new()
{
[AIServiceType.AzureAIInference] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.AzureAIInference,
DisplayName = "Azure AI Inference",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/Azure.svg",
IsOnlineService = true,
LegalDescription = "AdvancedPaste_AzureAIInference_LegalDescription",
TermsLabel = "AdvancedPaste_AzureAIInference_TermsLabel",
TermsUri = new Uri("https://azure.microsoft.com/support/legal/"),
PrivacyLabel = "AdvancedPaste_AzureAIInference_PrivacyLabel",
PrivacyUri = new Uri("https://privacy.microsoft.com/privacystatement"),
},
[AIServiceType.AzureOpenAI] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.AzureOpenAI,
DisplayName = "Azure OpenAI",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/AzureAI.svg",
IsOnlineService = true,
LegalDescription = "AdvancedPaste_AzureOpenAI_LegalDescription",
TermsLabel = "AdvancedPaste_AzureOpenAI_TermsLabel",
TermsUri = new Uri("https://azure.microsoft.com/support/legal/"),
PrivacyLabel = "AdvancedPaste_AzureOpenAI_PrivacyLabel",
PrivacyUri = new Uri("https://privacy.microsoft.com/privacystatement"),
},
[AIServiceType.FoundryLocal] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.FoundryLocal,
DisplayName = "Foundry Local",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/FoundryLocal.svg",
IsOnlineService = false,
IsLocalModel = true,
LegalDescription = "AdvancedPaste_FoundryLocal_LegalDescription", // Resource key for localized description
},
[AIServiceType.Google] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.Google,
DisplayName = "Google",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/Gemini.svg",
IsOnlineService = true,
LegalDescription = "AdvancedPaste_Google_LegalDescription",
TermsLabel = "AdvancedPaste_Google_TermsLabel",
TermsUri = new Uri("https://ai.google.dev/gemini-api/terms"),
PrivacyLabel = "AdvancedPaste_Google_PrivacyLabel",
PrivacyUri = new Uri("https://support.google.com/gemini/answer/13594961"),
},
[AIServiceType.Mistral] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.Mistral,
DisplayName = "Mistral",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/Mistral.svg",
IsOnlineService = true,
LegalDescription = "AdvancedPaste_Mistral_LegalDescription",
TermsLabel = "AdvancedPaste_Mistral_TermsLabel",
TermsUri = new Uri("https://mistral.ai/terms-of-service/"),
PrivacyLabel = "AdvancedPaste_Mistral_PrivacyLabel",
PrivacyUri = new Uri("https://mistral.ai/privacy-policy/"),
},
[AIServiceType.ML] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.ML,
DisplayName = "Windows ML",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/WindowsML.svg",
LegalDescription = "AdvancedPaste_LocalModel_LegalDescription",
IsAvailableInUI = false,
IsOnlineService = false,
IsLocalModel = true,
},
[AIServiceType.Ollama] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.Ollama,
DisplayName = "Ollama",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/Ollama.svg",
// Ollama provide online service, but we treat it as local model at first version since it can is known for local model.
IsOnlineService = false,
IsLocalModel = true,
LegalDescription = "AdvancedPaste_LocalModel_LegalDescription",
TermsLabel = "AdvancedPaste_Ollama_TermsLabel",
TermsUri = new Uri("https://ollama.org/terms"),
PrivacyLabel = "AdvancedPaste_Ollama_PrivacyLabel",
PrivacyUri = new Uri("https://ollama.org/privacy"),
},
[AIServiceType.Onnx] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.Onnx,
DisplayName = "ONNX",
LegalDescription = "AdvancedPaste_LocalModel_LegalDescription",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/Onnx.svg",
IsOnlineService = false,
IsAvailableInUI = false,
},
[AIServiceType.OpenAI] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.OpenAI,
DisplayName = "OpenAI",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/OpenAI.light.svg",
IsOnlineService = true,
LegalDescription = "AdvancedPaste_OpenAI_LegalDescription",
TermsLabel = "AdvancedPaste_OpenAI_TermsLabel",
TermsUri = new Uri("https://openai.com/terms"),
PrivacyLabel = "AdvancedPaste_OpenAI_PrivacyLabel",
PrivacyUri = new Uri("https://openai.com/privacy"),
},
[AIServiceType.Unknown] = new AIServiceTypeMetadata
{
ServiceType = AIServiceType.Unknown,
DisplayName = "Unknown",
IconPath = "ms-appx:///Assets/Settings/Icons/Models/OpenAI.light.svg",
IsOnlineService = false,
IsAvailableInUI = false,
},
};
/// <summary>
/// Get metadata for a specific service type.
/// </summary>
public static AIServiceTypeMetadata GetMetadata(AIServiceType serviceType)
{
return MetadataMap.TryGetValue(serviceType, out var metadata)
? metadata
: MetadataMap[AIServiceType.Unknown];
}
/// <summary>
/// Get metadata for a service type from its string representation.
/// </summary>
public static AIServiceTypeMetadata GetMetadata(string serviceType)
{
var type = serviceType.ToAIServiceType();
return GetMetadata(type);
}
/// <summary>
/// Get icon path for a service type.
/// </summary>
public static string GetIconPath(AIServiceType serviceType)
{
return GetMetadata(serviceType).IconPath;
}
/// <summary>
/// Get icon path for a service type from its string representation.
/// </summary>
public static string GetIconPath(string serviceType)
{
return GetMetadata(serviceType).IconPath;
}
/// <summary>
/// Get all service types available in the UI.
/// </summary>
public static IEnumerable<AIServiceTypeMetadata> GetAvailableServiceTypes()
{
return MetadataMap.Values.Where(m => m.IsAvailableInUI);
}
/// <summary>
/// Get all online service types available in the UI.
/// </summary>
public static IEnumerable<AIServiceTypeMetadata> GetOnlineServiceTypes()
{
return GetAvailableServiceTypes().Where(m => m.IsOnlineService);
}
/// <summary>
/// Get all local service types available in the UI.
/// </summary>
public static IEnumerable<AIServiceTypeMetadata> GetLocalServiceTypes()
{
return GetAvailableServiceTypes().Where(m => m.IsLocalModel);
}
}