45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
|
|
const textPartSchema = z.object({
|
|
type: z.enum(["text"]),
|
|
text: z.string().min(1).max(2000),
|
|
});
|
|
|
|
const filePartSchema = z.object({
|
|
type: z.enum(["file"]),
|
|
mediaType: z.enum(["image/jpeg", "image/png", "image/webp"]),
|
|
name: z.string().min(1).max(100),
|
|
url: z.string().url(),
|
|
});
|
|
|
|
const partSchema = z.union([textPartSchema, filePartSchema]);
|
|
|
|
// 🆕 视频参数 schema
|
|
const videoParamsSchema = z.object({
|
|
mode: z.enum(["text-to-video", "first-frame", "first-last-frame", "reference-images"]),
|
|
resolution: z.enum(["480p", "720p", "1080p"]).optional(),
|
|
ratio: z.string().optional(),
|
|
duration: z.number().optional(),
|
|
watermark: z.boolean().optional(),
|
|
cameraFixed: z.boolean().optional(),
|
|
cameraMove: z.string().optional(),
|
|
fps: z.number().optional(),
|
|
seed: z.number().optional(),
|
|
returnLastFrame: z.boolean().optional(),
|
|
}).optional();
|
|
|
|
export const postRequestBodySchema = z.object({
|
|
id: z.string().uuid(),
|
|
message: z.object({
|
|
id: z.string().uuid(),
|
|
role: z.enum(["user"]),
|
|
parts: z.array(partSchema),
|
|
}),
|
|
// 支持预定义模型名称或数据库中的模型 UUID
|
|
selectedChatModel: z.string().min(1).max(128),
|
|
selectedVisibilityType: z.enum(["public", "private"]),
|
|
videoParams: videoParamsSchema, // 🆕 视频参数
|
|
});
|
|
|
|
export type PostRequestBody = z.infer<typeof postRequestBodySchema>;
|