import * as React from "react";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import type { ModelDatabaseRow } from "@/types/local-frontier";
export type ModelDatabaseProps = {
rows: readonly ModelDatabaseRow[];
};
function matchesSearch(row: ModelDatabaseRow, search: string): boolean {
const query = search.trim().toLowerCase();
return !query || row.searchText.includes(query);
}
function ModelRow({ row }: { row: ModelDatabaseRow }): React.JSX.Element {
return (
{row.id}
{row.name}
{row.precision}
{row.downloads}
{row.architecture}
{row.architectureDetail ? (
{row.architectureDetail}
) : null}
{row.adapterKind}
{row.totalParams} total
{row.activeParams} active
{row.residentFootprint}
{row.activeTrafficFloor} active traffic floor
{row.context}
);
}
function ModelTable({
rows,
}: {
rows: readonly ModelDatabaseRow[];
}): React.JSX.Element {
if (!rows.length) {
return (
No models match the current filters.
);
}
return (
HF model
Downloads
Architecture
Parameters
Resident footprint
Context
Calculator
{rows.map((row) => (
))}
);
}
export function ModelDatabase({ rows }: ModelDatabaseProps): React.JSX.Element {
const [search, setSearch] = React.useState("");
const filteredRows = rows.filter((row) => matchesSearch(row, search));
return (
Model Database
);
}