Initial 智念AIGC platform

This commit is contained in:
inman
2026-05-29 10:26:02 +08:00
commit f9c3393f84
86 changed files with 14741 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { deleteAsset, deleteGenerationJob, getAsset, getGenerationJob } from "@/lib/server/data-store";
import { jsonError, jsonOk } from "@/lib/server/api";
import { requestOrigin } from "@/lib/server/runtime";
import { syncVideoJob } from "@/lib/server/video-generation-service";
import { deleteStoredAsset } from "@/lib/server/storage";
export const runtime = "nodejs";
export async function GET(request: Request, context: { params: Promise<{ id: string }> }) {
try {
const { id } = await context.params;
const job = await syncVideoJob(id, requestOrigin(request));
return jsonOk({ job });
} catch (error) {
return jsonError(error, 500);
}
}
export async function DELETE(_request: Request, context: { params: Promise<{ id: string }> }) {
try {
const { id } = await context.params;
const job = await getGenerationJob(id);
if (!job || job.capability !== "video.generate") return jsonError("任务不存在", 404);
const deletedAssetIds: string[] = [];
for (const assetId of job.outputAssetIds) {
const asset = await getAsset(assetId);
if (!asset) continue;
await deleteStoredAsset(asset);
await deleteAsset(asset.id);
deletedAssetIds.push(asset.id);
}
await deleteGenerationJob(id);
return jsonOk({ ok: true, deletedJobId: id, deletedAssetIds });
} catch (error) {
return jsonError(error, 500);
}
}

View File

@@ -0,0 +1,25 @@
import { listGenerationJobs } from "@/lib/server/data-store";
import { jsonError, jsonOk, readJsonBody } from "@/lib/server/api";
import { requestOrigin } from "@/lib/server/runtime";
import { submitVideoJob, type SubmitVideoJobInput } from "@/lib/server/video-generation-service";
export const runtime = "nodejs";
export async function GET() {
try {
const jobs = (await listGenerationJobs()).filter((job) => job.capability === "video.generate");
return jsonOk({ jobs });
} catch (error) {
return jsonError(error, 500);
}
}
export async function POST(request: Request) {
try {
const body = await readJsonBody<SubmitVideoJobInput & Record<string, unknown>>(request);
const job = await submitVideoJob(body, requestOrigin(request));
return jsonOk({ job }, { status: 202 });
} catch (error) {
return jsonError(error);
}
}