import { type ComboboxItem, Select } from "@mantine/core"; import { useEffect, useState } from "react"; import { wllamaModels } from "../../modules/wllama"; export default function WllamaModelSelect({ value, onChange, }: { value: string; onChange: (value: string) => void; }) { const [wllamaModelOptions] = useState( Object.entries(wllamaModels) .sort(([, a], [, b]) => a.fileSizeInMegabytes - b.fileSizeInMegabytes) .map(([value, { label, fileSizeInMegabytes }]) => ({ label: `${fileSizeInMegabytes} MB • ${label}`, value, })), ); useEffect(() => { const isCurrentModelValid = wllamaModelOptions.some( (model) => model.value === value, ); if (!isCurrentModelValid && wllamaModelOptions.length > 0) { onChange(wllamaModelOptions[0].value); } }, [onChange, wllamaModelOptions, value]); return (