- 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
+35
-9
@@ -1,12 +1,14 @@
|
||||
import "server-only";
|
||||
import { and, asc, desc, eq, sql } from "drizzle-orm";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { modelFiles, models } from "@/lib/db/schema";
|
||||
import { modelFiles, models, modelTags, tags } from "@/lib/db/schema";
|
||||
import { modelFamilies } from "@/lib/hub/metadata";
|
||||
import { quantGroup } from "@/lib/selection";
|
||||
import type { Tag } from "@/lib/tags";
|
||||
|
||||
export type LibraryRow = Awaited<ReturnType<typeof listLibrary>>[number];
|
||||
|
||||
/** Models with their selected-file totals and a short "which quant" label. */
|
||||
/** Models with selected-file totals, quant labels, Hub metadata and user tags. */
|
||||
export async function listLibrary() {
|
||||
const d = db();
|
||||
const rows = await d
|
||||
@@ -19,6 +21,11 @@ export async function listLibrary() {
|
||||
status: models.status,
|
||||
createdAt: models.createdAt,
|
||||
downloadedAt: models.downloadedAt,
|
||||
baseModels: models.baseModels,
|
||||
architecture: models.architecture,
|
||||
pipelineTag: models.pipelineTag,
|
||||
license: models.license,
|
||||
hubTags: models.hubTags,
|
||||
fileCount: sql<number>`count(${modelFiles.id})`,
|
||||
totalBytes: sql<number>`coalesce(sum(${modelFiles.size}), 0)`,
|
||||
})
|
||||
@@ -31,17 +38,24 @@ export async function listLibrary() {
|
||||
.select({ modelId: modelFiles.modelId, path: modelFiles.path })
|
||||
.from(modelFiles)
|
||||
.where(eq(modelFiles.selected, true));
|
||||
const quants = new Map<string, Set<string>>();
|
||||
for (const f of selected) {
|
||||
const g = quantGroup(f.path);
|
||||
if (!g) continue;
|
||||
if (!quants.has(f.modelId)) quants.set(f.modelId, new Set());
|
||||
quants.get(f.modelId)!.add(g);
|
||||
}
|
||||
const quants = groupBy(selected, (f) => f.modelId, (f) => quantGroup(f.path));
|
||||
|
||||
const tagRows = await d
|
||||
.select({ modelId: modelTags.modelId, id: tags.id, name: tags.name })
|
||||
.from(modelTags)
|
||||
.innerJoin(tags, eq(tags.id, modelTags.tagId))
|
||||
.orderBy(asc(tags.slug));
|
||||
const tagsByModel = new Map<string, Tag[]>();
|
||||
for (const t of tagRows) tagsByModel.set(t.modelId, [...(tagsByModel.get(t.modelId) ?? []), { id: t.id, name: t.name }]);
|
||||
|
||||
return rows.map((r) => ({
|
||||
...r,
|
||||
author: r.repoId.split("/")[0],
|
||||
families: modelFamilies(r.repoId, r.baseModels),
|
||||
baseModels: r.baseModels ?? [],
|
||||
hubTags: r.hubTags ?? [],
|
||||
quants: [...(quants.get(r.id) ?? [])].sort(),
|
||||
tags: tagsByModel.get(r.id) ?? [],
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -56,3 +70,15 @@ export async function getModel(id: string) {
|
||||
.orderBy(asc(modelFiles.path));
|
||||
return { model, files };
|
||||
}
|
||||
|
||||
function groupBy<T>(items: T[], key: (t: T) => string, value: (t: T) => string | null) {
|
||||
const out = new Map<string, Set<string>>();
|
||||
for (const item of items) {
|
||||
const v = value(item);
|
||||
if (v == null) continue;
|
||||
const k = key(item);
|
||||
if (!out.has(k)) out.set(k, new Set());
|
||||
out.get(k)!.add(v);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Reference in new issue
Block a user