@linxiraos/pi-catalog 1.4.13 → 1.5.0

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.
@@ -846,6 +846,7 @@ type OpenAICompatibleModelManagerBuilderOptions<TApi extends Api> = {
846
846
  entry: OpenAICompatibleModelRecord,
847
847
  defaults: ModelSpec<TApi>,
848
848
  reference: ModelSpec<TApi> | undefined,
849
+ references: Map<string, ModelSpec<TApi>>,
849
850
  ) => ModelSpec<TApi> | null;
850
851
  };
851
852
 
@@ -875,7 +876,8 @@ function createOpenAICompatibleModelManagerOptions<TApi extends Api>(
875
876
  ...(filterModel && {
876
877
  filterModel: (entry, model) => filterModel(entry, model, references),
877
878
  }),
878
- mapModel: (entry, defaults) => options.mapModel(entry, defaults, references.get(defaults.id)),
879
+ mapModel: (entry, defaults) =>
880
+ options.mapModel(entry, defaults, references.get(defaults.id), references),
879
881
  fetch: options.config?.fetch,
880
882
  }),
881
883
  options.providerId,
@@ -3255,6 +3257,27 @@ export interface MistralModelManagerConfig {
3255
3257
  fetch?: FetchImpl;
3256
3258
  }
3257
3259
 
3260
+ /**
3261
+ * Mistral's `/v1/models` lists each alias as its own row, with the canonical
3262
+ * id in `name` and the other ids in `aliases`; `mistral-vibe-cli-latest`, the
3263
+ * Vibe CLI's default, is a row named `mistral-medium-latest`. An id with no
3264
+ * bundled row of its own reuses the bundled row of the model it aliases, so it
3265
+ * keeps that model's reasoning, image input, limits, and prices. Such an id is
3266
+ * listed only for keys whose `/v1/models` returns it.
3267
+ */
3268
+ function mistralAliasReference(
3269
+ entry: OpenAICompatibleModelRecord,
3270
+ references: Map<string, ModelSpec<"openai-completions">>,
3271
+ ): ModelSpec<"openai-completions"> | undefined {
3272
+ const aliases = Array.isArray(entry.aliases) ? entry.aliases : [];
3273
+ for (const candidate of [entry.name, ...aliases]) {
3274
+ if (typeof candidate !== "string") continue;
3275
+ const reference = references.get(candidate);
3276
+ if (reference) return reference;
3277
+ }
3278
+ return undefined;
3279
+ }
3280
+
3258
3281
  /**
3259
3282
  * Mistral's `/v1/models` lists every SKU the key can call, including
3260
3283
  * embedding, OCR, moderation, transcription, and speech models, and flags chat
@@ -3271,10 +3294,11 @@ function mapMistralModel(
3271
3294
  entry: OpenAICompatibleModelRecord,
3272
3295
  defaults: ModelSpec<"openai-completions">,
3273
3296
  reference: ModelSpec<"openai-completions"> | undefined,
3297
+ references: Map<string, ModelSpec<"openai-completions">>,
3274
3298
  ): ModelSpec<"openai-completions"> | null {
3275
3299
  const capabilities = isRecord(entry.capabilities) ? entry.capabilities : undefined;
3276
3300
  if (capabilities && capabilities.completion_chat !== true) return null;
3277
- const model = mapWithBundledReference(entry, defaults, reference);
3301
+ const model = mapWithBundledReference(entry, defaults, reference ?? mistralAliasReference(entry, references));
3278
3302
  const input: ModelSpec<"openai-completions">["input"] =
3279
3303
  capabilities?.vision === true && !model.input.includes("image") ? [...model.input, "image"] : model.input;
3280
3304
  return {