MCPcopy Create free account
hub / github.com/Hello-Application-XH/HelloGML / handleVideoGenerations

Function handleVideoGenerations

src/index.ts:211–242  ·  view source on GitHub ↗
(request: Request, env: Env)

Source from the content-addressed store, hash-verified

209}
210
211async function handleVideoGenerations(request: Request, env: Env): Promise<Response> {
212 const refreshToken = await authenticate(request, env);
213 const body = (await request.json()) as any;
214
215 if (!isString(body.prompt)) throw new Error("prompt must be a string");
216 const {
217 model,
218 conversation_id: convId,
219 prompt,
220 image_url: imageUrl,
221 video_style: videoStyle = "",
222 emotional_atmosphere: emotionalAtmosphere = "",
223 mirror_mode: mirrorMode = "",
224 audio_id: audioId,
225 } = body;
226
227 const validStyles = ["卡通3D", "黑白老照片", "油画", "电影感"];
228 const validEmotions = ["温馨和谐", "生动活泼", "紧张刺激", "凄凉寂寞"];
229 const validMirrors = ["水平", "垂直", "推近", "拉远"];
230 if (videoStyle && !validStyles.includes(videoStyle)) throw new Error(`video_style must be one of ${validStyles.join("/")}`);
231 if (emotionalAtmosphere && !validEmotions.includes(emotionalAtmosphere)) throw new Error(`emotional_atmosphere must be one of ${validEmotions.join("/")}`);
232 if (mirrorMode && !validMirrors.includes(mirrorMode)) throw new Error(`mirror_mode must be one of ${validMirrors.join("/")}`);
233
234 const data = await generateVideos(model, prompt, refreshToken, {
235 imageUrl: imageUrl || "",
236 videoStyle,
237 emotionalAtmosphere,
238 mirrorMode,
239 audioId: audioId || "",
240 }, convId);
241 return jsonResponse({ created: unixTimestamp(), data });
242}
243
244async function handleModels(): Promise<Response> {
245 return jsonResponse({ data: SUPPORTED_MODELS });

Callers 1

fetchFunction · 0.85

Calls 5

isStringFunction · 0.90
generateVideosFunction · 0.90
unixTimestampFunction · 0.90
authenticateFunction · 0.85
jsonResponseFunction · 0.85

Tested by

no test coverage detected