Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 3x 28x 28x 19x 28x 28x 28x 28x 23x 5x 10x 1x 3x 2x | import type { CostProfileInfo, LighterModelPreview } from "@/objects/Agent";
import { QUERY_KEYS } from "@/services/query_keys";
import { useApiHandler } from "@/services/useApiHandler";
import { useQuery } from "@tanstack/react-query";
import React from "react";
/**
* How much pipeline work each of an agent's answers does — its cost profile
* (svc-core `app/util/cost_profiles.py`, svc-ai `app/agents/effort.py`).
*
* The choices come from `GET /app/agents/cost-profiles`, with whether the
* platform has measured each on its gold datasets. One that has not is
* offered as such — chosen, never defaulted — with the way to measure it on
* this agent first: an evaluation with the Cost profiles preset.
*
* With `agentId`, a profile that has a lighter model do some of the work
* (Economy) says which model this agent would use here, or why none — an
* agent already on its maker's lightest model gains nothing from it.
*/
const CostProfilePicker: React.FC<{
value?: string | null;
onChange: (key: string) => void;
saving?: boolean;
agentId?: string;
}> = ({ value, onChange, saving = false, agentId }) => {
const { getApiHandler } = useApiHandler();
const { data } = useQuery<CostProfileInfo[] | null>({
queryKey: [QUERY_KEYS.GET.COST_PROFILES, agentId ?? null],
queryFn: () => getApiHandler().agent_router.costProfiles(agentId),
staleTime: agentId ? 60_000 : Infinity,
});
// Bound explicitly: TS 5.0.2 cannot infer react-query v5's generic here.
const profiles: CostProfileInfo[] = Array.isArray(data) ? data : [];
const current = value ?? "thorough";
const unmeasured = profiles.some((p) => !p.measured);
if (profiles.length === 0) {
return (
<p className="text-xs text-gray-400 italic">
Cost profiles are unavailable right now.
</p>
);
}
return (
<div className="space-y-2">
<div role="radiogroup" aria-label="Cost profile" className="space-y-2">
{profiles.map((profile) => (
<label
key={profile.key}
className="flex items-start gap-3 cursor-pointer"
>
<input
type="radio"
name="cost-profile"
className="mt-0.5 size-4 shrink-0 accent-violet-600"
checked={current === profile.key}
disabled={saving}
onChange={() => onChange(profile.key)}
/>
<span className="min-w-0">
<span className="flex flex-wrap items-center gap-2 text-sm font-medium text-gray-800 dark:text-gray-200">
{profile.label}
{!profile.measured && (
<span className="text-[10px] font-medium uppercase tracking-wide px-1.5 py-0.5 rounded bg-amber-50 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300">
Not yet measured
</span>
)}
</span>
<span className="block text-xs text-gray-500 dark:text-gray-400 mt-0.5">
{profile.description}
</span>
{profile.lighter && (
<span className="block text-[11px] text-gray-500 dark:text-gray-400 mt-1">
{lighterText(profile.lighter)}
</span>
)}
</span>
</label>
))}
</div>
{unmeasured && (
<p className="text-[11px] text-gray-500 dark:text-gray-400">
A profile not yet measured has not been shown to answer as well as
Thorough on CHAIN-R's gold datasets. Try it on this agent
first: in an evaluation, add the <strong>Cost profiles</strong>{" "}
preset and compare each profile's score and cost per answer.
</p>
)}
</div>
);
};
/** What a profile's lighter model would be for this agent, in a sentence. */
export const lighterText = (lighter: LighterModelPreview): string =>
lighter.display_name || lighter.model_name
? `Uses ${lighter.display_name || lighter.model_name} for triage, checks and simple answers.`
: (lighter.note ?? "No lighter model is available for this agent.");
export default CostProfilePicker;
|