Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions packages/core/src/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export async function syncProvider<SourceModel>(
): Promise<SyncResult> {
console.log(`\nSyncing ${provider.name}...`);

const { models: existing, brokenSymlinks } = await readExisting(provider.modelsDir);
const existingState = await readExisting(provider.modelsDir);
const { models: existing, brokenSymlinks } = existingState;
let { modelMetadata } = existingState;
const sourceModels = provider.parseModels(await provider.fetchModels());
const desired = new Map<string, { model: z.infer<typeof SyncedAuthoredModel>; content: string }>();
const desiredMetadata = new Map<string, { model: z.infer<typeof ModelMetadata>; content: string }>();
Expand Down Expand Up @@ -163,13 +165,28 @@ export async function syncProvider<SourceModel>(
});
}

const translatedModel = provider.preserveBaseModels === false
? translated.model
: preserveBaseModel(translated.model, existing.get(relativePath)?.authored);
const translatedBase = "base_model" in translatedModel ? translatedModel.base_model : undefined;
let resolvedReasoning: boolean | undefined;
if (translatedBase !== undefined) {
if (translated.metadata?.id === translatedBase) {
resolvedReasoning = translated.metadata.model.reasoning;
} else {
modelMetadata ??= await readModelMetadata(provider.modelsDir);
const canonicalReasoning = modelMetadata[translatedBase]?.reasoning;
resolvedReasoning = typeof canonicalReasoning === "boolean" ? canonicalReasoning : undefined;
}
} else {
resolvedReasoning = existing.get(relativePath)?.toml.reasoning;
}
const parsed = SyncedAuthoredModel.safeParse(stripUndefined({
id: translated.id,
...preserveReasoningOptions(
provider.preserveBaseModels === false
? translated.model
: preserveBaseModel(translated.model, existing.get(relativePath)?.authored),
translatedModel,
existing.get(relativePath)?.authored,
resolvedReasoning,
),
}));
if (!parsed.success) {
Expand Down Expand Up @@ -319,7 +336,12 @@ export function preserveBaseModel(model: SyncedModel, existing: ExistingModel |
export function preserveReasoningOptions(
model: SyncedModel,
existing: ExistingModel | undefined,
resolvedReasoning: boolean | undefined = existing?.reasoning,
): SyncedModel {
if ((model.reasoning ?? resolvedReasoning) === false) {
const { reasoning_options: _reasoningOptions, ...withoutReasoningOptions } = model;
return withoutReasoningOptions as SyncedModel;
}
if (model.reasoning_options !== undefined || existing?.reasoning_options === undefined) return model;
return {
...model,
Expand Down Expand Up @@ -392,7 +414,7 @@ async function readExisting(modelsDir: string) {
existing.set(file, { authored, toml, symlink });
}

return { models: existing, brokenSymlinks };
return { models: existing, brokenSymlinks, modelMetadata };
}

async function isSymlink(filePath: string) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/sync/providers/ovhcloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function buildOvhcloudModel(
last_updated: lastUpdated,
attachment,
reasoning,
reasoning_options: reasoning ? existing?.reasoning_options : undefined,
temperature: temperature || undefined,
tool_call: toolCall,
structured_output: structuredOutput || undefined,
Expand Down
54 changes: 54 additions & 0 deletions packages/core/test/ovhcloud-sync.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { expect, test } from "bun:test";
import path from "node:path";

import { buildOvhcloudModel, type OvhcloudModel } from "../src/sync/providers/ovhcloud.js";

const model: OvhcloudModel = {
id: "Qwen3-32B",
name: "Qwen3-32B",
created: 1_752_655_628,
hugging_face_id: "Qwen/Qwen3-32B",
context_length: 32_768,
max_output_length: 32_768,
supported_features: ["reasoning"],
};

test("OVHcloud sync preserves authored reasoning options", () => {
const synced = buildOvhcloudModel(model, {
release_date: "2025-07-16",
last_updated: "2025-07-16",
reasoning_options: [{ type: "toggle" }],
});

expect(synced.reasoning_options).toEqual([{ type: "toggle" }]);
});

test("OVHcloud sync omits reasoning options for non-reasoning models", () => {
const synced = buildOvhcloudModel(
{ ...model, supported_features: [] },
{ reasoning_options: [{ type: "toggle" }] },
);

expect(synced.reasoning_options).toBeUndefined();
});

test("OVHcloud reasoning models declare the exact provider control matrix", async () => {
const modelsDir = path.join(import.meta.dirname, "..", "..", "..", "providers", "ovhcloud", "models");
const expected = {
"gpt-oss-20b": [{ type: "effort", values: ["low", "medium", "high"] }],
"gpt-oss-120b": [{ type: "effort", values: ["low", "medium", "high"] }],
"qwen3-32b": [{ type: "toggle" }],
"qwen3.5-9b": [{ type: "effort", values: ["none", "low", "medium", "high"] }],
"qwen3.5-397b-a17b": [{ type: "effort", values: ["none", "low", "medium", "high"] }],
"qwen3.6-27b": [{ type: "effort", values: ["none", "minimal", "low", "medium", "high"] }],
};

for (const [id, reasoningOptions] of Object.entries(expected)) {
const authored = Bun.TOML.parse(await Bun.file(path.join(modelsDir, `${id}.toml`)).text()) as {
reasoning?: boolean;
reasoning_options?: unknown;
};
expect(authored.reasoning, id).toBe(true);
expect(authored.reasoning_options, id).toEqual(reasoningOptions);
}
});
Loading
Loading