feat: add persistent model-aware reasoning effort settings
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { normalizeReasoningEffort, reasoningEffortLabel, type ReasoningCapabilities, type ReasoningEffort } from "@/lib/reasoning-effort";
|
||||
|
||||
export function ReasoningEffortControl({ capabilities, value, onChange, disabled }: {
|
||||
capabilities: ReasoningCapabilities | null;
|
||||
value: ReasoningEffort | null;
|
||||
onChange: (effort: ReasoningEffort | null) => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const effort = normalizeReasoningEffort(capabilities, value);
|
||||
const label = effort ? reasoningEffortLabel(effort)
|
||||
: `Model default${capabilities?.defaultEffort ? ` (${reasoningEffortLabel(capabilities.defaultEffort)})` : ""}`;
|
||||
return (
|
||||
<section className="rounded-lg border border-violet-300/18 bg-background/44 px-3 py-3">
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<label htmlFor="chat-reasoning-effort" className="text-xs font-semibold text-violet-100/72">Reasoning effort</label>
|
||||
<output htmlFor="chat-reasoning-effort" className="text-sm text-violet-50">{label}</output>
|
||||
</div>
|
||||
{capabilities ? (
|
||||
<>
|
||||
<input
|
||||
id="chat-reasoning-effort"
|
||||
type="range"
|
||||
min={0}
|
||||
max={capabilities.efforts.length}
|
||||
step={1}
|
||||
value={effort ? capabilities.efforts.indexOf(effort) + 1 : 0}
|
||||
onInput={(event) => onChange(capabilities.efforts[Number(event.currentTarget.value) - 1] ?? null)}
|
||||
aria-valuetext={label}
|
||||
aria-describedby="chat-reasoning-help"
|
||||
disabled={disabled}
|
||||
className="mt-2 h-8 w-full cursor-pointer accent-violet-400 disabled:cursor-default disabled:opacity-50"
|
||||
/>
|
||||
<div className="flex justify-between text-xs text-muted-foreground" aria-hidden="true">
|
||||
<span>Model default</span>
|
||||
<span>{reasoningEffortLabel(capabilities.efforts[capabilities.efforts.length - 1])}</span>
|
||||
</div>
|
||||
<p id="chat-reasoning-help" className="mt-2 text-xs text-muted-foreground">Higher effort gives the model more time to reason and can increase response time and cost.</p>
|
||||
</>
|
||||
) : (
|
||||
<p className="mt-2 text-xs text-muted-foreground">Reasoning settings aren’t available for this model. It will use its own defaults.</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user