koishi-plugin-aka-ai-generator 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +13 -34
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -984,41 +984,18 @@ var YunwuVideoProvider = class {
|
|
|
984
984
|
async queryTaskStatus(taskId) {
|
|
985
985
|
const { logger, ctx } = this.config;
|
|
986
986
|
try {
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
`${this.config.apiBase}${endpoint}`,
|
|
998
|
-
{
|
|
999
|
-
headers: {
|
|
1000
|
-
"Authorization": `Bearer ${this.config.apiKey}`,
|
|
1001
|
-
"Accept": "application/json"
|
|
1002
|
-
},
|
|
1003
|
-
timeout: this.config.apiTimeout * 1e3
|
|
1004
|
-
}
|
|
1005
|
-
);
|
|
1006
|
-
if (response && !response.error) {
|
|
1007
|
-
logger?.debug("查询任务状态成功", { taskId, endpoint });
|
|
1008
|
-
break;
|
|
1009
|
-
}
|
|
1010
|
-
} catch (err) {
|
|
1011
|
-
lastError = err;
|
|
1012
|
-
if (err.response?.status === 404 && possibleEndpoints.indexOf(endpoint) < possibleEndpoints.length - 1) {
|
|
1013
|
-
logger?.debug("尝试下一个查询端点", { taskId, endpoint, nextEndpoint: possibleEndpoints[possibleEndpoints.indexOf(endpoint) + 1] });
|
|
1014
|
-
continue;
|
|
1015
|
-
}
|
|
1016
|
-
throw err;
|
|
987
|
+
const endpoint = `/v1/video/${taskId}`;
|
|
988
|
+
logger?.debug("查询任务状态", { taskId, endpoint });
|
|
989
|
+
const response = await ctx.http.get(
|
|
990
|
+
`${this.config.apiBase}${endpoint}`,
|
|
991
|
+
{
|
|
992
|
+
headers: {
|
|
993
|
+
"Authorization": `Bearer ${this.config.apiKey}`,
|
|
994
|
+
"Accept": "application/json"
|
|
995
|
+
},
|
|
996
|
+
timeout: this.config.apiTimeout * 1e3
|
|
1017
997
|
}
|
|
1018
|
-
|
|
1019
|
-
if (!response) {
|
|
1020
|
-
throw lastError || new Error("所有查询端点都失败");
|
|
1021
|
-
}
|
|
998
|
+
);
|
|
1022
999
|
const status = response.status || response.data?.status || "pending";
|
|
1023
1000
|
const videoUrl = response.video_url || response.url || response.data?.video_url || response.data?.url;
|
|
1024
1001
|
return {
|
|
@@ -1073,6 +1050,8 @@ var YunwuVideoProvider = class {
|
|
|
1073
1050
|
try {
|
|
1074
1051
|
logger?.info("开始生成视频", { prompt, imageUrl, options });
|
|
1075
1052
|
const taskId = await this.createVideoTask(prompt, imageUrl, options);
|
|
1053
|
+
logger?.debug("任务已创建,等待 3 秒后开始查询", { taskId });
|
|
1054
|
+
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
1076
1055
|
const videoUrl = await this.pollTaskCompletion(taskId, maxWaitTime);
|
|
1077
1056
|
logger?.info("视频生成完成", { taskId, videoUrl });
|
|
1078
1057
|
return videoUrl;
|