+ {/* Search Header */}
+
+
+
+ setSearch(e.target.value)}
+ placeholder={placeholder}
+ className="pl-9"
+ />
+
+
+
+
+ {/* Category Filters */}
+
+ setSelectedCategory(null)}
+ >
+ All ({models.length})
+
+ {(Object.keys(CATEGORY_LABELS) as ModelCategory[]).map((cat) => {
+ const count = groupedModels[cat].length;
+ if (count === 0) return null;
+ return (
+ setSelectedCategory(cat)}
+ >
+ {CATEGORY_LABELS[cat]} ({count})
+
+ );
+ })}
+
+
+ {/* Selected Model Display */}
+ {selectedModel && (
+
+ {selectedModel.name}
+
+ {formatPricingPair(selectedModel.pricing)} |{' '}
+ {formatContextLength(selectedModel.context_length)}
+
+
+ )}
+
+ {/* Model List */}
+
+ {isError ? (
+
+ Failed to load models.{' '}
+
+
+ ) : filteredModels.length === 0 ? (
+
+ No models found matching "{search}"
+
+ ) : (
+
+ {(Object.keys(CATEGORY_LABELS) as ModelCategory[]).map((category) => {
+ const categoryModels = groupedModels[category];
+ if (categoryModels.length === 0) return null;
+
+ return (
+
+
+ {CATEGORY_LABELS[category]}
+
+ {categoryModels.map((model) => (
+
onChange(model.id)}
+ />
+ ))}
+
+ );
+ })}
+
+ )}
+
+
+ );
+}
+
+function ModelItem({
+ model,
+ isSelected,
+ onClick,
+}: {
+ model: CategorizedModel;
+ isSelected: boolean;
+ onClick: () => void;
+}) {
+ return (
+