@staticeng/opencode-litellm 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mapping.js +22 -5
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/mapping.js
CHANGED
|
@@ -2,6 +2,7 @@ import { deepMerge } from "./merge.js";
|
|
|
2
2
|
const DEFAULT_MODES = new Set(["chat", "responses"]);
|
|
3
3
|
const NON_CHAT_MODES = new Set(["embedding", "rerank"]);
|
|
4
4
|
const TEXT_MODALITY = "text";
|
|
5
|
+
const OPENCODE_MODALITIES = new Set(["text", "audio", "image", "video", "pdf"]);
|
|
5
6
|
const TEXT_ONLY_MODELS = new Set(["minimax-m2.7", "minimax_m2.7"]);
|
|
6
7
|
const NUMERIC_MODEL_INFO_FIELDS = new Set([
|
|
7
8
|
"input_cost_per_token",
|
|
@@ -32,6 +33,9 @@ const MODEL_INFO_FIELDS = new Set([
|
|
|
32
33
|
"output_modalities",
|
|
33
34
|
"supported_params",
|
|
34
35
|
]);
|
|
36
|
+
function supportedModalities(values) {
|
|
37
|
+
return unique(values).filter((modality) => OPENCODE_MODALITIES.has(modality));
|
|
38
|
+
}
|
|
35
39
|
function isRecord(value) {
|
|
36
40
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
41
|
}
|
|
@@ -226,13 +230,13 @@ function modalities(model) {
|
|
|
226
230
|
};
|
|
227
231
|
}
|
|
228
232
|
return {
|
|
229
|
-
input:
|
|
233
|
+
input: supportedModalities([
|
|
230
234
|
TEXT_MODALITY,
|
|
231
235
|
...(model.model_info?.supported_modalities ?? []),
|
|
232
236
|
...(model.model_info?.supports_vision ? ["image"] : []),
|
|
233
237
|
...(model.model_info?.supports_pdf_input ? ["pdf"] : []),
|
|
234
238
|
]),
|
|
235
|
-
output:
|
|
239
|
+
output: supportedModalities([TEXT_MODALITY, ...(model.model_info?.output_modalities ?? [])]),
|
|
236
240
|
};
|
|
237
241
|
}
|
|
238
242
|
function supportsReasoning(model) {
|
|
@@ -257,6 +261,16 @@ function generatedModel(model) {
|
|
|
257
261
|
...(model.model_info?.supports_function_calling || model.model_info?.supports_tool_choice ? { tool_call: true } : {}),
|
|
258
262
|
};
|
|
259
263
|
}
|
|
264
|
+
function finalizedModel(model, override) {
|
|
265
|
+
const input = supportedModalities(model.modalities?.input ?? [TEXT_MODALITY]);
|
|
266
|
+
const output = supportedModalities(model.modalities?.output ?? [TEXT_MODALITY]);
|
|
267
|
+
const attachmentOverride = typeof override?.attachment === "boolean" ? override.attachment : undefined;
|
|
268
|
+
return {
|
|
269
|
+
...model,
|
|
270
|
+
modalities: { input, output },
|
|
271
|
+
attachment: attachmentOverride ?? input.some((modality) => modality === "image" || modality === "pdf"),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
260
274
|
function v2Variants(model) {
|
|
261
275
|
const variants = model.variants;
|
|
262
276
|
if (!isRecord(variants))
|
|
@@ -288,8 +302,9 @@ function v2Model(model, baseURL) {
|
|
|
288
302
|
capabilities: {
|
|
289
303
|
tools: model.tool_call ?? false,
|
|
290
304
|
reasoning: model.reasoning ?? false,
|
|
291
|
-
|
|
292
|
-
|
|
305
|
+
attachment: model.attachment ?? false,
|
|
306
|
+
input: supportedModalities(model.modalities?.input ?? [TEXT_MODALITY]),
|
|
307
|
+
output: supportedModalities(model.modalities?.output ?? [TEXT_MODALITY]),
|
|
293
308
|
},
|
|
294
309
|
...(v2Cost(model) ? { cost: v2Cost(model) } : {}),
|
|
295
310
|
...(model.limit ? { limit: { ...model.limit } } : {}),
|
|
@@ -303,7 +318,9 @@ export function mapModels(response, options = {}) {
|
|
|
303
318
|
.map((model) => {
|
|
304
319
|
const name = modelName(model);
|
|
305
320
|
const generated = generatedModel(model);
|
|
306
|
-
return name && generated
|
|
321
|
+
return name && generated
|
|
322
|
+
? [name, finalizedModel(deepMerge(generated, options.overrides?.[name]), options.overrides?.[name])]
|
|
323
|
+
: undefined;
|
|
307
324
|
})
|
|
308
325
|
.filter((entry) => Boolean(entry)));
|
|
309
326
|
}
|
package/dist/types.d.ts
CHANGED