Revert CivitAI downloads
Removes the CivitAI work again (765dac2,a1acd8c): the API client and link parser, CIVITAI_TOKEN, adding CivitAI models, migration 0027 and the model page changes. Kaname downloads from Hugging Face only, as in 0.21.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a1acd8c0a5
commit
7d1a8fb85a
25 files changed
+17
-2849
No files matched your search
@@ -1,21 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { z } from "zod";
|
||||
import { withAuth } from "@/lib/api-auth";
|
||||
import { handleApiError } from "@/lib/api-errors";
|
||||
import { lookupCivitai } from "@/lib/civitai/lookup";
|
||||
|
||||
const Body = z.object({
|
||||
input: z.string().trim().min(1).max(2048),
|
||||
/** Another version of the same model (the version picker). */
|
||||
versionId: z.number().int().positive().optional(),
|
||||
});
|
||||
|
||||
/** Look up a CivitAI model link or id: the model, its versions and one version's files. */
|
||||
export const POST = withAuth(async (req) => {
|
||||
try {
|
||||
const body = Body.parse(await req.json());
|
||||
return NextResponse.json(await lookupCivitai(body.input, body.versionId));
|
||||
} catch (err) {
|
||||
return handleApiError(err);
|
||||
}
|
||||
});
|
||||
@@ -9,7 +9,5 @@ export const POST = withAuth<RouteContext<"/api/models/[id]/hub-check">>(async (
|
||||
const model = await getCheckedModel(id);
|
||||
if (!model) return apiError(404, "not_found", "Model not found.");
|
||||
if (model.source === "local") return apiError(409, "local_model", "This is a local model without a Hugging Face repo.");
|
||||
// Checking CivitAI for new versions comes with CivitAI updates; the Hub would report it missing.
|
||||
if (model.source === "civitai") return apiError(409, "civitai_model", "Checks for new CivitAI versions aren't available yet.");
|
||||
return NextResponse.json(await checkHub(model));
|
||||
});
|
||||
@@ -4,7 +4,7 @@ import { withAuth } from "@/lib/api-auth";
|
||||
import { apiError, handleApiError } from "@/lib/api-errors";
|
||||
import { REPO_ID_RE, SHA_RE } from "@/lib/hub/client";
|
||||
import { queueDownload } from "@/lib/jobs";
|
||||
import { addCivitaiModel, addLocalModel, addModel, ModelError } from "@/lib/models";
|
||||
import { addLocalModel, addModel, ModelError } from "@/lib/models";
|
||||
import { addTag, normalizeTagName, TagError } from "@/lib/tags";
|
||||
|
||||
const Body = z.object({
|
||||
@@ -26,33 +26,13 @@ const LocalBody = z.object({
|
||||
tags: z.array(z.string()).max(50).default([]),
|
||||
});
|
||||
|
||||
/** A CivitAI model at the version the user reviewed. */
|
||||
const CivitaiBody = z.object({
|
||||
source: z.literal("civitai"),
|
||||
modelId: z.number().int().positive(),
|
||||
versionId: z.number().int().positive(),
|
||||
track: z.enum(["latest", "pinned"]).default("latest"),
|
||||
fileIds: z.array(z.number().int().positive()).min(1).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. With
|
||||
* `source: "civitai"`, a CivitAI model pinned to a version. With `source: "local"`, add a folder
|
||||
* from the models folder that has no Hub repo instead (nothing queued).
|
||||
* `source: "local"`, add a folder from the models folder that has no Hub repo instead (nothing queued).
|
||||
*/
|
||||
export const POST = withAuth(async (req) => {
|
||||
try {
|
||||
const json = await req.json();
|
||||
if (json?.source === "civitai") {
|
||||
const body = CivitaiBody.parse(json);
|
||||
body.tags.forEach(normalizeTagName);
|
||||
const { id } = await addCivitaiModel(body);
|
||||
for (const tag of body.tags) await addTag(id, tag);
|
||||
const job = body.download ? await queueDownload(id, "initial") : null;
|
||||
return NextResponse.json({ id, jobId: job?.jobId ?? null }, { status: 201 });
|
||||
}
|
||||
if (json?.source === "local") {
|
||||
const body = LocalBody.parse(json);
|
||||
body.tags.forEach(normalizeTagName);
|
||||
|
||||
Reference in new issue
Block a user