- Rename the app to Kaname - Hub metadata per model (base models, architecture, license, Hub tags), backfilled by the worker for existing models - Library search across repo/author/family/quant/tags and multi-select facet filters (author, family, quant, tag, status) kept in the URL - Custom tags (model page editor, on add, click-to-filter) - README rewritten around a quick install, with banner and screenshots - deploy/compose.yaml: models in a host folder (KANAME_MODELS_DIR) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2167ea0950
commit
67191b3e16
37 files changed
+2028
-206
No files matched your search
@@ -0,0 +1,10 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { withAuth } from "@/lib/api-auth";
|
||||
import { removeTag } from "@/lib/tags";
|
||||
|
||||
/** Detach a tag from a model. */
|
||||
export const DELETE = withAuth<RouteContext<"/api/models/[id]/tags/[tagId]">>(async (_req, { params }) => {
|
||||
const { id, tagId } = await params;
|
||||
await removeTag(id, tagId);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { z } from "zod";
|
||||
import { withAuth } from "@/lib/api-auth";
|
||||
import { apiError, handleApiError } from "@/lib/api-errors";
|
||||
import { addTag, TagError } from "@/lib/tags";
|
||||
|
||||
const Body = z.object({ name: z.string() });
|
||||
|
||||
/** Attach a tag to a model (creates the tag on first use). */
|
||||
export const POST = withAuth<RouteContext<"/api/models/[id]/tags">>(async (req, { params }) => {
|
||||
const { id } = await params;
|
||||
try {
|
||||
const { name } = Body.parse(await req.json());
|
||||
return NextResponse.json(await addTag(id, name), { status: 201 });
|
||||
} catch (err) {
|
||||
if (err instanceof TagError) return apiError(err.status, err.code, err.message);
|
||||
return handleApiError(err);
|
||||
}
|
||||
});
|
||||
@@ -5,6 +5,7 @@ import { apiError, handleApiError } from "@/lib/api-errors";
|
||||
import { REPO_ID_RE, SHA_RE } from "@/lib/hub/client";
|
||||
import { queueDownload } from "@/lib/jobs";
|
||||
import { addModel, ModelError } from "@/lib/models";
|
||||
import { addTag, normalizeTagName, TagError } from "@/lib/tags";
|
||||
|
||||
const Body = z.object({
|
||||
repoId: z.string().regex(REPO_ID_RE),
|
||||
@@ -13,22 +14,25 @@ const Body = z.object({
|
||||
include: z.array(z.string().min(1).max(1024)).max(10_000),
|
||||
exclude: z.array(z.string().min(1).max(1024)).max(1_000),
|
||||
download: z.boolean().default(true),
|
||||
tags: z.array(z.string()).max(50).default([]),
|
||||
});
|
||||
|
||||
/** Add a model to the library, pinned to the SHA the user reviewed, and queue its download. */
|
||||
export const POST = withAuth(async (req) => {
|
||||
try {
|
||||
const body = Body.parse(await req.json());
|
||||
body.tags.forEach(normalizeTagName); // validate before anything is written
|
||||
const { id } = await addModel({
|
||||
repoId: body.repoId,
|
||||
revision: body.revision,
|
||||
sha: body.sha,
|
||||
rule: { include: body.include, exclude: body.exclude },
|
||||
});
|
||||
for (const tag of body.tags) await addTag(id, tag);
|
||||
const job = body.download ? await queueDownload(id) : null;
|
||||
return NextResponse.json({ id, jobId: job?.jobId ?? null }, { status: 201 });
|
||||
} catch (err) {
|
||||
if (err instanceof ModelError) return apiError(err.status, err.code, err.message);
|
||||
if (err instanceof ModelError || err instanceof TagError) return apiError(err.status, err.code, err.message);
|
||||
return handleApiError(err);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { withAuth } from "@/lib/api-auth";
|
||||
import { listTags } from "@/lib/tags";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
/** All user tags with usage counts. */
|
||||
export const GET = withAuth(async () => NextResponse.json(await listTags()));
|
||||
Reference in new issue
Block a user