Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 49 additions & 36 deletions frontend/src/features/try-fair/components/model-picker-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export const ModelPicker: React.FC<ModelPickerProps> = ({
<div className="w-full md:w-28 text-left flex-1 min-w-0">
{loading ? (
<p className="text-grey text-xs animate-pulse">Loading models…</p>
) : models.length === 0 ? (
<p className="text-grey text-xs">No models available</p>
) : selectedModel ? (
<>
<p className="font-medium text-dark text-xs leading-tight">
Expand Down Expand Up @@ -127,43 +129,54 @@ export const ModelPickerContent = ({
}) => (
<div className="bg-white rounded-xl p-4 space-y-4 max-h-[70vh] overflow-y-auto">
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
{models.map((model) => {
const isSelected = selectedModel?.id === model.id;
// const tasks = model.properties["mlm:tasks"] ?? [];
return (
<button
key={model.id}
type="button"
onClick={() => onSelect(model)}
className={`text-left p-3 bg-frosted-blue rounded-lg transition-colors ${
isSelected ? "border-primary border-2" : ""
}`}
>
<div className="flex space-y-2 items-start justify-between gap-2 mb-1">
<p className="text-dark capitalize text-sm font-bold leading-tight">
{model?.properties?.title ?? ""}
</p>
{models.length > 0 ? (
models.map((model) => {
const isSelected = selectedModel?.id === model.id;
// const tasks = model.properties["mlm:tasks"] ?? [];
return (
<button
key={model.id}
type="button"
onClick={() => onSelect(model)}
className={`text-left p-3 bg-frosted-blue rounded-lg transition-colors ${
isSelected ? "border-primary border-2" : ""
}`}
>
<div className="flex space-y-2 items-start justify-between gap-2 mb-1">
<p className="text-dark capitalize text-sm font-bold leading-tight">
{model?.properties?.title ?? ""}
</p>

<span
className={`mt-0.5 shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${
isSelected ? "border-primary border-2" : ""
}`}
>
{isSelected && (
<span className="w-2 h-2 rounded-full bg-primary" />
)}
</span>
</div>
<p className="text-grey text-xs mb-0.5">
Model: {model?.properties?.["mlm:name"] ?? ""}
</p>
<p className="text-grey text-xs mb-2">
By: {model?.properties?.providers[0]?.name ?? ""}
</p>
<FeatureBadge label={model?.properties?.keywords[0] ?? ""} />
</button>
);
})}
<span
className={`mt-0.5 shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${
isSelected ? "border-primary border-2" : ""
}`}
>
{isSelected && (
<span className="w-2 h-2 rounded-full bg-primary" />
)}
</span>
</div>
<p className="text-grey text-xs mb-0.5">
Model: {model?.properties?.["mlm:name"] ?? ""}
</p>
<p className="text-grey text-xs mb-2">
By: {model?.properties?.providers[0]?.name ?? ""}
</p>
<FeatureBadge label={model?.properties?.keywords[0] ?? ""} />
</button>
);
})
) : (
<div className="col-span-2 flex flex-col items-center justify-center py-10 px-4 text-center">
<p className="text-dark font-semibold text-sm mb-1">
No models available
</p>
<p className="text-grey text-xs max-w-xs">
There are currently no models available for use.{" "}
</p>
</div>
)}
</div>
</div>
);
Loading