cc33b2a813
Co-authored-by: ayattara <alassane.yattara@savoirfairelinux.com> Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import { useFeature } from "@/hooks/domains/features/use-feature";
|
|
import type { AgentProfileOption } from "@/lib/state/slices/settings/types";
|
|
import { AgentProfilePicker } from "@/components/settings/agent-profile-picker";
|
|
|
|
export const utilityProfileEligibility = (
|
|
profile: AgentProfileOption,
|
|
dynamicRoutingEnabled = true,
|
|
includeWorkspaceProfiles = false,
|
|
) =>
|
|
profile.enabled !== false &&
|
|
(includeWorkspaceProfiles || !profile.cli_passthrough) &&
|
|
(includeWorkspaceProfiles || profile.inference_capable === true) &&
|
|
(dynamicRoutingEnabled || profile.kind !== "dynamic") &&
|
|
(includeWorkspaceProfiles || !profile.workspace_id);
|
|
|
|
type UtilityAgentProfilePickerProps = {
|
|
profiles: AgentProfileOption[];
|
|
value: string;
|
|
onValueChange: (value: string) => void;
|
|
testId: string;
|
|
fallback?: { value: string; label: string };
|
|
unavailableValue?: string;
|
|
unavailableLabel?: string;
|
|
triggerClassName?: string;
|
|
includeWorkspaceProfiles?: boolean;
|
|
};
|
|
|
|
export function UtilityAgentProfilePicker({
|
|
profiles,
|
|
value,
|
|
onValueChange,
|
|
testId,
|
|
fallback,
|
|
unavailableValue,
|
|
unavailableLabel,
|
|
triggerClassName,
|
|
includeWorkspaceProfiles = false,
|
|
}: UtilityAgentProfilePickerProps) {
|
|
const dynamicRoutingEnabled = useFeature("dynamicAgentRouting");
|
|
return (
|
|
<AgentProfilePicker
|
|
profiles={profiles}
|
|
value={value}
|
|
onValueChange={onValueChange}
|
|
testId={testId}
|
|
fallback={fallback}
|
|
unavailableValue={unavailableValue}
|
|
unavailableLabel={unavailableLabel}
|
|
triggerClassName={triggerClassName}
|
|
iconTestId="utility-profile-agent-icon"
|
|
profileFilter={(profile) =>
|
|
utilityProfileEligibility(profile, dynamicRoutingEnabled, includeWorkspaceProfiles)
|
|
}
|
|
/>
|
|
);
|
|
}
|