-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAiProvider.cs
152 lines (125 loc) · 3.68 KB
/
AiProvider.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
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
using ServiceStack;
using ServiceStack.DataAnnotations;
using ServiceStack.Model;
namespace AiServer.ServiceModel;
/// <summary>
/// An API Provider that can process tasks
/// </summary>
[Icon(Svg = Icons.Work)]
public class AiProvider
{
[AutoIncrement]
public int Id { get; set; }
/// <summary>
/// The unique name for this API Provider
/// </summary>
[Index(Unique = true)]
public string Name { get; set; }
/// <summary>
/// Override Base URL for the API Provider
/// </summary>
public string? ApiBaseUrl { get; set; }
/// <summary>
/// The Environment Variable for the API Key to use for this Provider
/// </summary>
public string? ApiKeyVar { get; set; }
/// <summary>
/// The API Key to use for this Provider
/// </summary>
public string? ApiKey { get; set; }
/// <summary>
/// Send the API Key in the Header instead of Authorization Bearer
/// </summary>
public string? ApiKeyHeader { get; set; }
/// <summary>
/// Url to check if the API is online
/// </summary>
public string? HeartbeatUrl { get; set; }
/// <summary>
/// How many requests should be made concurrently
/// </summary>
public int Concurrency { get; set; }
/// <summary>
/// What priority to give this Provider to use for processing models
/// </summary>
public int Priority { get; set; }
/// <summary>
/// Whether the Provider is enabled
/// </summary>
public bool Enabled { get; set; }
/// <summary>
/// When the Provider went offline
/// </summary>
public DateTime? OfflineDate { get; set; }
/// <summary>
/// When the Provider was created
/// </summary>
public DateTime CreatedDate { get; set; }
/// <summary>
/// The models this API Provider should process
/// </summary>
public List<AiProviderModel> Models { get; set; } = [];
/// <summary>
/// The behavior for this API Provider
/// </summary>
public string AiTypeId { get; set; }
[Ignore]
public AiType AiType { get; set; }
[Ignore] public List<string> SelectedModels => Models?.Select(x => x.ApiModel ?? x.Model).ToList() ?? [];
}
/// <summary>
/// The models this API Provider can process
/// </summary>
public class AiProviderModel
{
/// <summary>
/// Ollama Model Id
/// </summary>
public string Model { get; set; }
/// <summary>
/// What Model to use for this API Provider
/// </summary>
public string? ApiModel { get; set; }
}
public enum AiProviderType
{
OllamaAiProvider,
OpenAiProvider,
GoogleAiProvider,
AnthropicAiProvider,
}
/// <summary>
/// The behavior of the AI Provider
/// </summary>
[Icon(Svg = Icons.Type)]
public class AiType : IHasId<string>
{
/// <summary>
/// Name for this API Provider Type
/// </summary>
public string Id { get; set; }
/// <summary>
/// The AI Provider to process AI Requests
/// </summary>
public AiProviderType Provider { get; set; }
/// <summary>
/// The website for this provider
/// </summary>
public string Website { get; set; }
/// <summary>
/// The API Base Url
/// </summary>
public string ApiBaseUrl { get; set; }
/// <summary>
/// Url to check if the API is online
/// </summary>
public string? HeartbeatUrl { get; set; }
/// <summary>
/// Icon Path or URL
/// </summary>
public string? Icon { get; set; }
/// <summary>
/// Mapping of Ollama Models to API Models
/// </summary>
public Dictionary<string, string> ApiModels { get; set; } = new();
}