Merge branch 'develop' of https://github.com/HBAI-Ltd/Toonflow-app into develop
This commit is contained in:
commit
9254a4e650
@ -1,6 +1,6 @@
|
||||
import "../type";
|
||||
import axios from "axios";
|
||||
import u from "@/utils";
|
||||
import { pollTask } from "@/utils/ai/utils";
|
||||
|
||||
interface DoubaoVideoConfig {
|
||||
prompt: string;
|
||||
@ -11,20 +11,6 @@ interface DoubaoVideoConfig {
|
||||
audio?: boolean;
|
||||
}
|
||||
|
||||
const pollTask = async (
|
||||
queryFn: () => Promise<{ completed: boolean; imageUrl?: string; error?: string }>,
|
||||
maxAttempts = 500,
|
||||
interval = 2000,
|
||||
): Promise<string> => {
|
||||
for (let i = 0; i < maxAttempts; i++) {
|
||||
await new Promise((resolve) => setTimeout(resolve, interval));
|
||||
const { completed, imageUrl, error } = await queryFn();
|
||||
if (error) throw new Error(error);
|
||||
if (completed && imageUrl) return imageUrl;
|
||||
}
|
||||
throw new Error(`任务轮询超时,已尝试 ${maxAttempts} 次`);
|
||||
};
|
||||
|
||||
export default async (input: ImageConfig, config: AIConfig) => {
|
||||
console.log("%c Line:5 🍓 input", "background:#7f2b82", input);
|
||||
console.log("%c Line:5 🍎 config", "background:#93c0a4", config);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user