Hugging Face style model pages at /<org>/<name>
- Model URLs are the repo path (case-insensitive, canonical redirect); /models/<id> redirects - Header with avatar, org/name + copy, task/format/arch/language/license pills, user tags, cross-links to the Hub (files @ sha, commits, community, base model) and tabs: rendered model card at the pinned commit, files, jobs - Sidebar: download card, local copy, model tree with related local models - Metadata gains author avatar and base relation (refetched once) - Proxy matcher excludes only exact /login and /api/auth/ paths Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d16bd6dfee
commit
1527fcd830
29 files changed
+4335
-269
No files matched your search
@@ -1,123 +1,14 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { ModelStatusBadge } from "@/components/model-status-badge";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { formatBytes } from "@/lib/format";
|
||||
import { LocalTime } from "@/components/local-time";
|
||||
import { modelFamilies } from "@/lib/hub/metadata";
|
||||
import { getModel } from "@/lib/library";
|
||||
import { modelTagList } from "@/lib/tags";
|
||||
import { ModelLive } from "./model-live";
|
||||
import { RemoveModelButton } from "./remove-model-button";
|
||||
import { TagEditor } from "./tag-editor";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { notFound, permanentRedirect } from "next/navigation";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { models } from "@/lib/db/schema";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function ModelPage({ params }: PageProps<"/models/[id]">) {
|
||||
/** Old URL scheme (/models/<id>): redirect to /<org>/<name>. */
|
||||
export default async function LegacyModelPage({ params }: PageProps<"/models/[id]">) {
|
||||
const { id } = await params;
|
||||
const data = await getModel(id);
|
||||
if (!data) notFound();
|
||||
const { model, files } = data;
|
||||
const modelTags = await modelTagList(model.id);
|
||||
const selected = files.filter((f) => f.selected);
|
||||
const totalBytes = selected.reduce((s, f) => s + f.size, 0);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<h1 className="text-xl font-semibold break-all">{model.repoId}</h1>
|
||||
<ModelStatusBadge status={model.status} />
|
||||
<div className="ml-auto">{model.status === "pending" && <RemoveModelButton id={model.id} />}</div>
|
||||
</div>
|
||||
<TagEditor modelId={model.id} tags={modelTags} />
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Details</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<dl className="grid grid-cols-[max-content_1fr] gap-x-6 gap-y-2 text-sm">
|
||||
<dt className="text-muted-foreground">Hub</dt>
|
||||
<dd>
|
||||
<a
|
||||
href={`https://huggingface.co/${model.repoId}/tree/${model.pinnedSha}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="underline"
|
||||
>
|
||||
huggingface.co/{model.repoId}
|
||||
</a>
|
||||
</dd>
|
||||
<dt className="text-muted-foreground">Author</dt>
|
||||
<dd>{model.repoId.split("/")[0]}</dd>
|
||||
<dt className="text-muted-foreground">Family</dt>
|
||||
<dd>{modelFamilies(model.repoId, model.baseModels).join(", ")}</dd>
|
||||
<dt className="text-muted-foreground">Base model</dt>
|
||||
<dd className="flex flex-col">
|
||||
{(model.baseModels ?? []).length === 0
|
||||
? "–"
|
||||
: model.baseModels!.map((b) => (
|
||||
<a key={b} href={`https://huggingface.co/${b}`} target="_blank" rel="noreferrer" className="underline">
|
||||
{b}
|
||||
</a>
|
||||
))}
|
||||
</dd>
|
||||
<dt className="text-muted-foreground">Architecture</dt>
|
||||
<dd>{model.architecture ?? "–"}</dd>
|
||||
<dt className="text-muted-foreground">License</dt>
|
||||
<dd>{model.license ?? "–"}</dd>
|
||||
{(model.hubTags ?? []).length > 0 && (
|
||||
<>
|
||||
<dt className="text-muted-foreground">Hub tags</dt>
|
||||
<dd className="text-xs text-muted-foreground">{model.hubTags!.join(", ")}</dd>
|
||||
</>
|
||||
)}
|
||||
<dt className="text-muted-foreground">Tracked revision</dt>
|
||||
<dd className="font-mono">{model.trackedRevision}</dd>
|
||||
<dt className="text-muted-foreground">Pinned SHA</dt>
|
||||
<dd className="font-mono break-all">{model.pinnedSha}</dd>
|
||||
<dt className="text-muted-foreground">Local path</dt>
|
||||
<dd className="font-mono break-all">$MODELS_DIR/{model.localPath}</dd>
|
||||
<dt className="text-muted-foreground">Include</dt>
|
||||
<dd className="font-mono text-xs break-all">{model.includePatterns.join(", ") || "–"}</dd>
|
||||
<dt className="text-muted-foreground">Exclude</dt>
|
||||
<dd className="font-mono text-xs break-all">{model.excludePatterns.join(", ") || "–"}</dd>
|
||||
<dt className="text-muted-foreground">Added</dt>
|
||||
<dd><LocalTime value={model.createdAt} /></dd>
|
||||
</dl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<ModelLive modelId={model.id} status={model.status} />
|
||||
|
||||
<Card className="py-0">
|
||||
<CardHeader className="pt-4">
|
||||
<CardTitle>
|
||||
Selected files · {selected.length} · {formatBytes(totalBytes)}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{files.length - selected.length} other files in the repo are not selected.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>File</TableHead>
|
||||
<TableHead className="text-right">Size</TableHead>
|
||||
<TableHead>State</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{selected.map((f) => (
|
||||
<TableRow key={f.id}>
|
||||
<TableCell className="font-mono text-xs break-all whitespace-normal">{f.path}</TableCell>
|
||||
<TableCell className="text-right tabular-nums">{formatBytes(f.size)}</TableCell>
|
||||
<TableCell className="text-sm text-muted-foreground">{f.state}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
const model = await db().query.models.findFirst({ columns: { repoId: true }, where: eq(models.id, id) });
|
||||
if (!model) notFound();
|
||||
permanentRedirect(`/${model.repoId}`);
|
||||
}
|
||||
Reference in new issue
Block a user