Files
cobble/src/functions/backend/db/harness/harness-model-row-to-catalog.ts
T
tben c2553a4746 Add per-model generation settings to the model selector
Each text and vision harness setting now carries the generation settings
its model takes (temperature, sampling limits, penalties, seed, reasoning
effort), edited in a modal under the model pick so the harness block stays
short. Nothing is set by default, so models keep their provider's own
values until a super admin or admin changes them.

A setting is only offered and only sent when the catalog says the model
takes it: OpenRouter's supported_parameters is now stored on
harness_models and refreshed by the hourly sync. Other providers list no
parameters, so their models get them all.
2026-10-22 04:52:55 +01:00

48 lines
1.5 KiB
TypeScript

import type { BUN_SQLITE_COBBLE_HARNESS_MODELS } from "@/db/types/db";
import type { HarnessCatalogModel } from "@/src/harness/types";
type Params = {
row: BUN_SQLITE_COBBLE_HARNESS_MODELS;
};
/**
* A `harness_models` row as a catalog entry.
*/
export default function harnessModelRowToCatalog({
row,
}: Params): HarnessCatalogModel {
return {
slug: row.slug || "",
name: row.name || row.slug || "",
free: row.free == 1,
input_modalities: parseList({ text: row.input_modalities }) || ["text"],
output_modalities: parseList({ text: row.output_modalities }) || [
"text",
],
supports_tools: row.supports_tools == 1,
context_length: numberOrUndefined(row.context_length),
max_output_tokens: numberOrUndefined(row.max_output_tokens),
voices: parseList({ text: row.voices }),
supported_parameters: parseList({ text: row.supported_parameters }),
intelligence_score: numberOrUndefined(row.intelligence_score),
agentic_score: numberOrUndefined(row.agentic_score),
released_at: numberOrUndefined(row.released_at),
expires_at: numberOrUndefined(row.expires_at),
};
}
function parseList({ text }: { text?: string | null }) {
if (!text) return undefined;
try {
const value = JSON.parse(text);
return Array.isArray(value) ? value.map(String) : undefined;
} catch {
return undefined;
}
}
function numberOrUndefined(value: unknown) {
return typeof value == "number" ? value : undefined;
}