fix: address project review bugs
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import { aiGenerationClient } from "../../api/aiGenerationClient";
|
||||
import { serverRequest } from "../../api/serverConnection";
|
||||
import { waitForTask } from "../../api/taskSubscription";
|
||||
import { ENTERPRISE_DEFAULT_VIDEO_MODEL } from "../../utils/enterpriseVideoPolicy";
|
||||
import { resolveVideoRequestModel } from "../../utils/resolveVideoModel";
|
||||
import { ecommerceOssScopes } from "./ecommerceGenerationPersistence";
|
||||
import { normalizeEcommerceImageMime } from "./ecommerceImageValidation";
|
||||
@@ -130,6 +131,18 @@ export interface PlanCallbacks {
|
||||
|
||||
const LOCAL_PREVIEW_MISSING_FILE_MESSAGE = "Please re-upload the product image before generating the short video.";
|
||||
|
||||
export function buildComplianceFailureMessage(compliance: NonNullable<EcommerceVideoPlanProgress["compliance"]>): string {
|
||||
const issues = compliance.issues
|
||||
.slice(0, 3)
|
||||
.map((issue) => [issue.field, issue.problem, issue.suggestion].filter(Boolean).join(":"))
|
||||
.filter(Boolean)
|
||||
.join(";");
|
||||
|
||||
return issues
|
||||
? `合规检查未通过,已停止生成。${issues}`
|
||||
: "合规检查未通过,已停止生成。请修改商品说明或广告文案后重试。";
|
||||
}
|
||||
|
||||
function readBlobAsDataUrl(blob: Blob): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
@@ -271,6 +284,10 @@ export async function runVideoPlan(
|
||||
emit();
|
||||
}
|
||||
|
||||
if (progress.compliance.allow_video_generation === false) {
|
||||
throw new Error(buildComplianceFailureMessage(progress.compliance));
|
||||
}
|
||||
|
||||
return {
|
||||
imageUrls: progress.imageUrls!,
|
||||
imageDescription: progress.imageDescription,
|
||||
@@ -303,7 +320,6 @@ export async function renderSceneImage(
|
||||
abortRef: { current: boolean },
|
||||
): Promise<void> {
|
||||
const { taskId } = await aiGenerationClient.createImageTask({
|
||||
model: "gpt-image-2",
|
||||
prompt: input.prompt,
|
||||
ratio: input.aspectRatio,
|
||||
quality: "2K",
|
||||
@@ -315,7 +331,6 @@ export async function renderSceneImage(
|
||||
const resultUrl = await waitForTask(taskId, {
|
||||
abortRef,
|
||||
kind: "image",
|
||||
model: "gpt-image-2",
|
||||
onProgress: (e) => callbacks.onSceneImageProgress(input.sceneId, e.progress),
|
||||
});
|
||||
|
||||
@@ -351,7 +366,7 @@ export async function renderScene(
|
||||
): Promise<void> {
|
||||
const allReferenceUrls = [...input.productImageUrls, input.imageUrl];
|
||||
const model = resolveVideoRequestModel({
|
||||
model: input.model || "happyhorse-1.0",
|
||||
model: input.model || ENTERPRISE_DEFAULT_VIDEO_MODEL,
|
||||
referenceUrls: allReferenceUrls,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user