-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathModelIdentifier.Provider.swift
More file actions
208 lines (186 loc) · 4.91 KB
/
ModelIdentifier.Provider.swift
File metadata and controls
208 lines (186 loc) · 4.91 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//
// Copyright (c) Vatsal Manot
//
import CorePersistence
import Foundation
import Swallow
extension ModelIdentifier {
@HadeanIdentifier("bagog-golir-jisap-mozop")
@RuntimeDiscoverable
public enum Provider: Hashable, Sendable {
case _Anthropic
case _Apple
case _Fal
case _Mistral
case _Groq
case _xAI
case _Ollama
case _OpenAI
case _Gemini
case _Perplexity
case _Jina
case _VoyageAI
case _Cohere
case _ElevenLabs
case _TogetherAI
case unknown(String)
public static var apple: Self {
Self._Apple
}
public static var fal: Self {
self._Fal
}
public static var openAI: Self {
Self._OpenAI
}
public static var anthropic: Self {
Self._Anthropic
}
public static var groq: Self {
Self._Groq
}
public static var xAI: Self {
Self._xAI
}
public static var gemini: Self {
Self._Gemini
}
public static var perplexity: Self {
Self._Perplexity
}
public static var jina: Self {
Self._Jina
}
public static var voyageAI: Self {
Self._VoyageAI
}
public static var cohere: Self {
Self._Cohere
}
public static var elevenLabs: Self {
Self._ElevenLabs
}
public static var togetherAI: Self {
Self._TogetherAI
}
}
}
// MARK: - Conformances
extension ModelIdentifier.Provider: CustomStringConvertible {
public var description: String {
switch self {
case ._Anthropic:
return "Anthropic"
case ._Apple:
return "Apple"
case ._Fal:
return "Fal"
case ._Mistral:
return "Mistral"
case ._Groq:
return "Groq"
case ._xAI:
return "xAI"
case ._Ollama:
return "Ollama"
case ._OpenAI:
return "OpenAI"
case ._Gemini:
return "Gemini"
case ._Perplexity:
return "Perplexity"
case ._Jina:
return "Perplexity"
case ._VoyageAI:
return "VoyageAI"
case ._Cohere:
return "Cohere"
case ._ElevenLabs:
return "ElevenLabs"
case ._TogetherAI:
return "TogetherAI"
case .unknown(let provider):
return provider
}
}
}
extension ModelIdentifier.Provider: RawRepresentable {
public var rawValue: String {
switch self {
case ._Anthropic:
return "anthropic"
case ._Apple:
return "apple"
case ._Fal:
return "fal"
case ._Mistral:
return "mistral"
case ._Groq:
return "groq"
case ._xAI:
return "xai"
case ._Ollama:
return "ollama"
case ._OpenAI:
return "openai"
case ._Gemini:
return "gemini"
case ._Perplexity:
return "perplexity"
case ._Jina:
return "jina"
case ._VoyageAI:
return "voyageai"
case ._Cohere:
return "cohere"
case ._ElevenLabs:
return "elevenlabs"
case ._TogetherAI:
return "togetherai"
case .unknown(let provider):
return provider
}
}
public init(rawValue: String) {
switch rawValue {
case Self._Anthropic.rawValue:
self = ._Anthropic
case Self._Apple.rawValue:
self = ._Apple
case Self._Fal.rawValue:
self = ._Fal
case Self._Mistral.rawValue:
self = ._Mistral
case Self._Groq.rawValue:
self = ._Groq
case Self._xAI.rawValue:
self = ._xAI
case Self._OpenAI.rawValue:
self = ._OpenAI
case Self._Gemini.rawValue:
self = ._Gemini
case Self._Perplexity.rawValue:
self = ._Perplexity
case Self._Jina.rawValue:
self = ._Jina
case Self._VoyageAI.rawValue:
self = ._VoyageAI
case Self._Cohere.rawValue:
self = ._Cohere
case Self._ElevenLabs.rawValue:
self = ._ElevenLabs
case Self._TogetherAI.rawValue:
self = ._TogetherAI
default:
self = .unknown(rawValue)
}
}
}
extension ModelIdentifier.Provider: Codable {
public init(from decoder: Decoder) throws {
try self.init(rawValue: String(from: decoder))
}
public func encode(to encoder: Encoder) throws {
try rawValue.encode(to: encoder)
}
}