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.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import type { HarnessKind } from "@/src/dict/harness-dict";
|
|
import type {
|
|
HarnessFormValue,
|
|
HarnessSettingsFormObject,
|
|
} from "@/src/types";
|
|
|
|
type Params = {
|
|
form: HarnessSettingsFormObject;
|
|
saved: HarnessSettingsFormObject;
|
|
};
|
|
|
|
/**
|
|
* The harness settings that differ from what is saved, ready to send.
|
|
*/
|
|
export default function changedHarnessSettings({ form, saved }: Params) {
|
|
return (Object.keys(form) as HarnessKind[]).flatMap((harness) => {
|
|
const value = form[harness];
|
|
|
|
if (!value || isSame({ a: value, b: saved[harness] })) return [];
|
|
|
|
return [{ harness, ...value }];
|
|
});
|
|
}
|
|
|
|
function isSame({ a, b }: { a: HarnessFormValue; b?: HarnessFormValue }) {
|
|
return (
|
|
Boolean(b) &&
|
|
Boolean(a.inherit) == Boolean(b!.inherit) &&
|
|
a.model_id == b!.model_id &&
|
|
(a.provider_id ?? null) == (b!.provider_id ?? null) &&
|
|
a.fallback == b!.fallback &&
|
|
a.enabled == b!.enabled &&
|
|
(a.voice || "") == (b!.voice || "") &&
|
|
paramsKey({ params: a.params }) == paramsKey({ params: b!.params })
|
|
);
|
|
}
|
|
|
|
/**
|
|
* The generation settings as one comparable string.
|
|
*/
|
|
export function paramsKey({
|
|
params,
|
|
}: {
|
|
params?: Record<string, number | string>;
|
|
}) {
|
|
const entries = Object.entries(params || {}).sort(([a], [b]) =>
|
|
a.localeCompare(b),
|
|
);
|
|
|
|
return JSON.stringify(entries);
|
|
}
|