-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathGitHubCopilotRequest+BYOK.swift
More file actions
161 lines (136 loc) · 4.56 KB
/
GitHubCopilotRequest+BYOK.swift
File metadata and controls
161 lines (136 loc) · 4.56 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
import Foundation
public enum BYOKProviderName: String, Codable, Equatable, Hashable, Comparable, CaseIterable {
case Azure
case Anthropic
case Gemini
case Groq
case OpenAI
case OpenRouter
public static func < (lhs: BYOKProviderName, rhs: BYOKProviderName) -> Bool {
return lhs.rawValue < rhs.rawValue
}
}
public struct BYOKModelCapabilities: Codable, Equatable, Hashable {
public var name: String
public var maxInputTokens: Int?
public var maxOutputTokens: Int?
public var toolCalling: Bool
public var vision: Bool
public init(
name: String,
maxInputTokens: Int? = nil,
maxOutputTokens: Int? = nil,
toolCalling: Bool,
vision: Bool
) {
self.name = name
self.maxInputTokens = maxInputTokens
self.maxOutputTokens = maxOutputTokens
self.toolCalling = toolCalling
self.vision = vision
}
}
public struct BYOKModelInfo: Codable, Equatable, Hashable, Comparable {
public let providerName: BYOKProviderName
public let modelId: String
public var isRegistered: Bool
public let isCustomModel: Bool
public let deploymentUrl: String?
public let apiKey: String?
public var modelCapabilities: BYOKModelCapabilities?
public init(
providerName: BYOKProviderName,
modelId: String,
isRegistered: Bool,
isCustomModel: Bool,
deploymentUrl: String?,
apiKey: String?,
modelCapabilities: BYOKModelCapabilities?
) {
self.providerName = providerName
self.modelId = modelId
self.isRegistered = isRegistered
self.isCustomModel = isCustomModel
self.deploymentUrl = deploymentUrl
self.apiKey = apiKey
self.modelCapabilities = modelCapabilities
}
public static func < (lhs: BYOKModelInfo, rhs: BYOKModelInfo) -> Bool {
if lhs.providerName != rhs.providerName {
return lhs.providerName < rhs.providerName
}
let lhsId = lhs.modelId.lowercased()
let rhsId = rhs.modelId.lowercased()
if lhsId != rhsId {
return lhsId < rhsId
}
// Fallback to preserve deterministic ordering when only case differs
return lhs.modelId < rhs.modelId
}
}
public typealias BYOKSaveModelParams = BYOKModelInfo
public struct BYOKSaveModelResponse: Codable, Equatable, Hashable {
public let success: Bool
public let message: String
}
public struct BYOKDeleteModelParams: Codable, Equatable, Hashable {
public let providerName: BYOKProviderName
public let modelId: String
public init(providerName: BYOKProviderName, modelId: String) {
self.providerName = providerName
self.modelId = modelId
}
}
public typealias BYOKDeleteModelResponse = BYOKSaveModelResponse
public struct BYOKListModelsParams: Codable, Equatable, Hashable {
public let providerName: BYOKProviderName?
public let enableFetchUrl: Bool?
public init(
providerName: BYOKProviderName? = nil,
enableFetchUrl: Bool? = nil
) {
self.providerName = providerName
self.enableFetchUrl = enableFetchUrl
}
}
public struct BYOKListModelsResponse: Codable, Equatable, Hashable {
public let models: [BYOKModelInfo]
}
public struct BYOKSaveApiKeyParams: Codable, Equatable, Hashable {
public let providerName: BYOKProviderName
public let apiKey: String
public let modelId: String?
public init(
providerName: BYOKProviderName,
apiKey: String,
modelId: String? = nil
) {
self.providerName = providerName
self.apiKey = apiKey
self.modelId = modelId
}
}
public typealias BYOKSaveApiKeyResponse = BYOKSaveModelResponse
public struct BYOKDeleteApiKeyParams: Codable, Equatable, Hashable {
public let providerName: BYOKProviderName
public init(providerName: BYOKProviderName) {
self.providerName = providerName
}
}
public typealias BYOKDeleteApiKeyResponse = BYOKSaveModelResponse
public struct BYOKListApiKeysParams: Codable, Equatable, Hashable {
public let providerName: BYOKProviderName?
public let modelId: String?
public init(providerName: BYOKProviderName? = nil, modelId: String? = nil) {
self.providerName = providerName
self.modelId = modelId
}
}
public struct BYOKApiKeyInfo: Codable, Equatable, Hashable {
public let providerName: BYOKProviderName
public let modelId: String?
public let apiKey: String?
}
public struct BYOKListApiKeysResponse: Codable, Equatable, Hashable {
public let apiKeys: [BYOKApiKeyInfo]
}