mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-05 20:44:07 +08:00
fix: plugin effort compress
This commit is contained in:
@@ -164,7 +164,10 @@ Deno.test("official model discovery excludes hidden models and puts the default
|
||||
display_name: "GPT First",
|
||||
supported_in_api: true,
|
||||
visibility: "list",
|
||||
supported_reasoning_efforts: ["low", "medium"],
|
||||
supported_reasoning_levels: [
|
||||
{ effort: "low", description: "Fast responses" },
|
||||
{ effort: "medium", description: "Balanced" },
|
||||
],
|
||||
},
|
||||
{ slug: "gpt-second", supported_in_api: true, visibility: "list" },
|
||||
{ slug: "gpt-hidden", supported_in_api: true, visibility: "hidden" },
|
||||
@@ -172,7 +175,7 @@ Deno.test("official model discovery excludes hidden models and puts the default
|
||||
],
|
||||
});
|
||||
assertEquals(models.map((model) => model.id), ["gpt-second", "gpt-first"]);
|
||||
assertEquals(models[1].capabilities, { thinking: true, images: true });
|
||||
assertEquals(models[1].capabilities, { images: true });
|
||||
assertEquals(models[1].privateData, { reasoningEfforts: ["low", "medium"] });
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,11 @@ function positiveInteger(value: unknown): number | null {
|
||||
}
|
||||
|
||||
function parseReasoningEfforts(model: Record<string, unknown>): string[] {
|
||||
const source = model.supported_reasoning_efforts ??
|
||||
const source = model.supported_reasoning_levels ??
|
||||
model.supportedReasoningLevels ??
|
||||
model.reasoning_levels ??
|
||||
model.reasoningLevels ??
|
||||
model.supported_reasoning_efforts ??
|
||||
model.supportedReasoningEfforts ??
|
||||
model.reasoning_efforts ??
|
||||
model.reasoningEfforts;
|
||||
@@ -61,10 +65,6 @@ export function parseOfficialModels(body: unknown): ModelDefinition[] {
|
||||
seen.add(id);
|
||||
const efforts = parseReasoningEfforts(model);
|
||||
const description = text(model.description);
|
||||
const contextWindowTokens = positiveInteger(
|
||||
model.context_window_tokens ?? model.contextWindowTokens ?? model.context_window ??
|
||||
model.contextWindow,
|
||||
);
|
||||
const maxOutputTokens = positiveInteger(
|
||||
model.max_output_tokens ?? model.maxOutputTokens ?? model.max_completion_tokens ??
|
||||
model.maxCompletionTokens,
|
||||
@@ -74,9 +74,8 @@ export function parseOfficialModels(body: unknown): ModelDefinition[] {
|
||||
displayName: text(model.display_name ?? model.displayName ?? model.title ?? model.name) ??
|
||||
id,
|
||||
...(description ? { description } : {}),
|
||||
...(contextWindowTokens !== null ? { contextWindowTokens } : {}),
|
||||
...(maxOutputTokens !== null ? { maxOutputTokens } : {}),
|
||||
capabilities: { thinking: efforts.length > 0, images: true },
|
||||
capabilities: { images: true },
|
||||
privateData: { reasoningEfforts: efforts },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -160,9 +160,8 @@ Deno.test("model discovery parses both language-models and standard list shapes"
|
||||
});
|
||||
assertEquals(richModels.map((model) => model.id), ["grok-4", "grok-3-mini"]);
|
||||
assertEquals(richModels[0].displayName, "Grok 4");
|
||||
assertEquals(richModels[0].contextWindowTokens, 256_000);
|
||||
assertEquals(richModels[0].capabilities, { thinking: false, images: true });
|
||||
assertEquals(richModels[1].capabilities, { thinking: false, images: false });
|
||||
assertEquals(richModels[0].capabilities, { images: true });
|
||||
assertEquals(richModels[1].capabilities, { images: false });
|
||||
|
||||
const plainModels = parseGrokModels({ data: [{ id: "grok-4-fast" }] });
|
||||
assertEquals(plainModels.map((model) => model.id), ["grok-4-fast"]);
|
||||
|
||||
@@ -9,12 +9,12 @@ export const FALLBACK_MODELS: ModelDefinition[] = [
|
||||
{
|
||||
id: "grok-4.6",
|
||||
displayName: "Grok 4.6",
|
||||
capabilities: { thinking: false, images: true },
|
||||
capabilities: { images: true },
|
||||
},
|
||||
{
|
||||
id: "grok-4.5",
|
||||
displayName: "Grok 4.5",
|
||||
capabilities: { thinking: false, images: true },
|
||||
capabilities: { images: true },
|
||||
},
|
||||
];
|
||||
|
||||
@@ -28,15 +28,6 @@ function text(value: unknown): string | null {
|
||||
return typeof value === "string" && value.trim() ? value.trim() : null;
|
||||
}
|
||||
|
||||
function positiveInteger(value: unknown): number | null {
|
||||
const parsed = typeof value === "number"
|
||||
? value
|
||||
: typeof value === "string"
|
||||
? Number(value)
|
||||
: NaN;
|
||||
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : null;
|
||||
}
|
||||
|
||||
function modalities(value: unknown): string[] {
|
||||
return Array.isArray(value)
|
||||
? value.flatMap((item) => (typeof item === "string" ? [item.toLowerCase()] : []))
|
||||
@@ -66,15 +57,10 @@ export function parseGrokModels(body: unknown): ModelDefinition[] {
|
||||
if (!id || seen.has(id)) continue;
|
||||
seen.add(id);
|
||||
const inputs = modalities(model?.input_modalities ?? model?.inputModalities);
|
||||
const contextWindowTokens = positiveInteger(
|
||||
model?.context_window ?? model?.contextWindow ?? model?.max_prompt_length,
|
||||
);
|
||||
models.push({
|
||||
id,
|
||||
displayName: displayName(id),
|
||||
...(contextWindowTokens !== null ? { contextWindowTokens } : {}),
|
||||
capabilities: {
|
||||
thinking: false,
|
||||
images: inputs.length === 0 || inputs.includes("image"),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user