- 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,39 @@
|
||||
import { eq, isNull } from "drizzle-orm";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { models } from "@/lib/db/schema";
|
||||
import { getRepoInfo } from "./client";
|
||||
import type { RepoMetadata } from "./metadata";
|
||||
|
||||
/** Columns to write on `models` for fetched Hub metadata. */
|
||||
export function metadataColumns(meta: RepoMetadata) {
|
||||
return {
|
||||
baseModels: meta.baseModels,
|
||||
architecture: meta.architecture,
|
||||
pipelineTag: meta.pipelineTag,
|
||||
license: meta.license,
|
||||
hubTags: meta.hubTags,
|
||||
metadataFetchedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Hub metadata for models that don't have it yet (added before metadata existed).
|
||||
* Returns how many were updated; failures are reported but don't stop the others.
|
||||
*/
|
||||
export async function backfillMetadata(onError: (repoId: string, err: unknown) => void): Promise<number> {
|
||||
const missing = await db()
|
||||
.select({ id: models.id, repoId: models.repoId, pinnedSha: models.pinnedSha })
|
||||
.from(models)
|
||||
.where(isNull(models.metadataFetchedAt));
|
||||
let updated = 0;
|
||||
for (const m of missing) {
|
||||
try {
|
||||
const info = await getRepoInfo(m.repoId, m.pinnedSha);
|
||||
await db().update(models).set(metadataColumns(info.metadata)).where(eq(models.id, m.id));
|
||||
updated++;
|
||||
} catch (err) {
|
||||
onError(m.repoId, err);
|
||||
}
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
Reference in new issue
Block a user