@@ -72,4 +72,141 @@ extension MistralService {
7272 return . cancelled
7373 }
7474 }
75+
76+ func decode( model: Mistral . ModelResponse ) -> Model {
77+ var name = String ? . none
78+ var family = String ? . none
79+ var maxOutput = Int ? . none
80+ var contextWindow = Int ? . none
81+
82+ if model. id. hasPrefix ( " codestral " ) {
83+ family = " Codestral "
84+ switch model. id {
85+ case " codestral-latest " :
86+ name = " Codestral (latest) "
87+ case " codestral-2405 " :
88+ name = " Codestral (2405) "
89+ case " codestral-mamba-latest " :
90+ name = " Codestral Mamba (latest) "
91+ case " codestral-mamba-2407 " :
92+ name = " Codestral Mamba (2407) "
93+ default :
94+ name = model. id
95+ }
96+ }
97+
98+ if model. id. hasPrefix ( " mistral-large " ) {
99+ family = " Mistral Large "
100+ switch model. id {
101+ case " mistral-large-latest " :
102+ name = " Mistral Large (latest) "
103+ case " mistral-large-2402 " :
104+ name = " Mistral Large (2402) "
105+ case " mistral-large-2407 " :
106+ name = " Mistral Large (2407) "
107+ default :
108+ name = model. id
109+ }
110+ }
111+
112+ if model. id. hasPrefix ( " mistral-medium " ) {
113+ family = " Mistral Medium "
114+ switch model. id {
115+ case " mistral-medium " :
116+ name = " Mistral Medium "
117+ case " mistral-medium-latest " :
118+ name = " Mistral Medium (latest) "
119+ case " mistral-medium-2312 " :
120+ name = " Mistral Medium (2312) "
121+ default :
122+ name = model. id
123+ }
124+ }
125+
126+ if model. id. hasPrefix ( " mistral-small " ) {
127+ family = " Mistral Small "
128+ switch model. id {
129+ case " mistral-small " :
130+ name = " Mistral Small "
131+ case " mistral-small-latest " :
132+ name = " Mistral Small (latest) "
133+ case " mistral-small-2312 " :
134+ name = " Mistral Small (2312) "
135+ case " mistral-small-2402 " :
136+ name = " Mistral Small (2402) "
137+ case " mistral-small-2409 " :
138+ name = " Mistral Small (2409) "
139+ default :
140+ name = model. id
141+ }
142+ }
143+
144+ if model. id. hasPrefix ( " mistral-tiny " ) {
145+ family = " Mistral Tiny "
146+ switch model. id {
147+ case " mistral-tiny " :
148+ name = " Mistral Tiny "
149+ case " mistral-tiny-latest " :
150+ name = " Mistral Tiny (latest) "
151+ case " mistral-tiny-2312 " :
152+ name = " Mistral Tiny (2312) "
153+ case " mistral-tiny-2407 " :
154+ name = " Mistral Tiny (2407) "
155+ default :
156+ name = model. id
157+ }
158+ }
159+
160+ if model. id. hasPrefix ( " pixtral " ) {
161+ family = " Pixtral "
162+ switch model. id {
163+ case " pixtral-12b " :
164+ name = " Pixtral 12b "
165+ case " pixtral-12b-latest " :
166+ name = " Pixtral 12b (latest) "
167+ case " pixtral-12b-2409 " :
168+ name = " Pixtral 12b (2409) "
169+ default :
170+ name = model. id
171+ }
172+ }
173+
174+ if model. id. hasPrefix ( " open-mistral " ) {
175+ family = " Open Mistral "
176+ switch model. id {
177+ case " open-mistral-7b " :
178+ name = " Open Mistral 7b "
179+ case " open-mistral-nemo " :
180+ name = " Open Mistral Nemo "
181+ case " open-mistral-nemo-2407 " :
182+ name = " Open Mistral Nemo (2407) "
183+ default :
184+ name = model. id
185+ }
186+ }
187+
188+ if model. id. hasPrefix ( " open-mixtral " ) {
189+ family = " Open Mixtral "
190+ switch model. id {
191+ case " open-mixtral-8x22b " :
192+ name = " Open Mixtral 8x22b "
193+ case " open-mixtral-8x22b-2404 " :
194+ name = " Open Mixtral 8x22b (2404) "
195+ case " open-mixtral-8x7b " :
196+ name = " Open Mixtral 8x7b "
197+ default :
198+ name = model. id
199+ }
200+ }
201+
202+ return Model (
203+ id: model. id,
204+ family: family,
205+ name: name,
206+ owner: model. ownedBy,
207+ contextWindow: contextWindow,
208+ maxOutput: maxOutput,
209+ trainingCutoff: nil
210+ )
211+ }
75212}
0 commit comments