-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProviderConfig.cs
More file actions
49 lines (40 loc) · 1.15 KB
/
ProviderConfig.cs
File metadata and controls
49 lines (40 loc) · 1.15 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
namespace YAOLlm;
public class ProviderConfig
{
public string Provider { get; set; }
public string Model { get; set; }
public string? DisplayName { get; set; }
public ProviderConfig(string provider, string model, string? displayName = null)
{
Provider = provider;
Model = model;
DisplayName = displayName;
}
public override string ToString()
{
if (!string.IsNullOrEmpty(DisplayName))
return $"{Provider}:{Model}:{DisplayName}";
return $"{Provider}:{Model}";
}
public static ProviderConfig? Parse(string value)
{
if (string.IsNullOrWhiteSpace(value))
return null;
var parts = value.Split(':');
if (parts.Length < 2)
return null;
var provider = parts[0].Trim();
string model;
string? displayName = null;
if (parts.Length >= 3)
{
displayName = parts[^1].Trim();
model = string.Join(':', parts[1..^1]).Trim();
}
else
{
model = parts[1].Trim();
}
return new ProviderConfig(provider, model, displayName);
}
}