@tacoreai/web-sdk 1.21.0 → 1.22.0
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/README.md
CHANGED
|
@@ -202,30 +202,46 @@ const base64 = result.data.uri || result.data.images?.[0]?.uri;
|
|
|
202
202
|
|
|
203
203
|
---
|
|
204
204
|
|
|
205
|
-
## [新增]
|
|
205
|
+
## [新增] 视频生成(Seedance 2.0)
|
|
206
206
|
|
|
207
|
-
通过 AppsClient
|
|
207
|
+
通过 AppsClient 调用统一视频任务接口。当前云模式默认视频模型为 `agent:tacore-3.3`,后端会映射到火山引擎 `doubao-seedance-2-0-260128`。计费将自动关联到应用所属的组织。
|
|
208
208
|
|
|
209
209
|
### 定价
|
|
210
|
-
-
|
|
211
|
-
-
|
|
210
|
+
- `agent:tacore-3.3`
|
|
211
|
+
- 输入价格:4
|
|
212
|
+
- 输出价格:10
|
|
212
213
|
|
|
213
214
|
### `createVideoJob(options)`
|
|
214
215
|
- **功能**: 创建一个异步的视频生成任务。
|
|
215
216
|
- **参数**:
|
|
216
217
|
- `options` (object):
|
|
217
|
-
- `prompt` (string,
|
|
218
|
-
- `
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
- `prompt` (string, 推荐): 视频描述提示词。
|
|
219
|
+
- `content` (array, 推荐): 多模态输入数组,支持:
|
|
220
|
+
- `{ type: 'text', text: '...' }`
|
|
221
|
+
- `{ type: 'image_url', image_url: { url: 'https://...' }, role: 'reference_image' }`
|
|
222
|
+
- `{ type: 'video_url', video_url: { url: 'https://...' }, role: 'reference_video' }`
|
|
223
|
+
- `{ type: 'audio_url', audio_url: { url: 'https://...' }, role: 'reference_audio' }`
|
|
224
|
+
- `model` (string, 可选): 默认 `agent:tacore-3.3`。
|
|
225
|
+
- `generate_audio` (boolean, 可选): 是否生成音频。
|
|
226
|
+
- `ratio` (string, 可选): 画幅比例,例如 `16:9`。
|
|
227
|
+
- `duration` (number, 可选): 视频时长(秒)。
|
|
228
|
+
- `watermark` (boolean, 可选): 是否保留 provider 水印。
|
|
229
|
+
- `resolution` (string, 可选): 分辨率。
|
|
230
|
+
- `seed` (number, 可选): 随机种子。
|
|
231
|
+
- `return_last_frame` (boolean, 可选): 是否返回尾帧。
|
|
232
|
+
- `providerOptions` (object, 可选): 透传给 provider 的扩展字段。
|
|
221
233
|
- **返回值**: `Promise<object>` - 包含任务初始状态的文档。
|
|
222
234
|
|
|
235
|
+
### 参考素材上传
|
|
236
|
+
- 图片、视频、音频参考素材必须先调用 `uploadToR2`,然后把返回的公网 `url` 填到 `content` 中。
|
|
237
|
+
- 不要直接把本地 `File`/`Blob`/base64 传给 `createVideoJob`。
|
|
238
|
+
|
|
223
239
|
### `remixVideoJob(jobId, options)`
|
|
224
|
-
- **功能**: 基于一个已完成的视频,创建一个新的 Remix
|
|
240
|
+
- **功能**: 基于一个已完成的视频,创建一个新的 Remix 任务。后端会自动把原视频作为 `reference_video` 注入。
|
|
225
241
|
- **参数**:
|
|
226
242
|
- `jobId` (string, 必填): 原始视频任务的 `wyID`。
|
|
227
243
|
- `options` (object):
|
|
228
|
-
- `prompt`
|
|
244
|
+
- 兼容 `createVideoJob(options)` 的全部字段,至少需要 `prompt` 或 `content`。
|
|
229
245
|
- **返回值**: `Promise<object>` - 包含新的 Remix 任务初始状态的文档。
|
|
230
246
|
|
|
231
247
|
### `getVideoJob(jobId)`
|
|
@@ -248,10 +264,29 @@ const client = new AppsClient('YOUR_APP_ID');
|
|
|
248
264
|
|
|
249
265
|
async function generateAndPollVideo() {
|
|
250
266
|
try {
|
|
267
|
+
const image = await client.uploadToR2(fileInput.files[0]);
|
|
268
|
+
const audio = await client.uploadToR2(audioInput.files[0]);
|
|
269
|
+
|
|
251
270
|
// 1. 提交任务
|
|
252
271
|
const jobResult = await client.createVideoJob({
|
|
253
|
-
|
|
254
|
-
|
|
272
|
+
model: 'agent:tacore-3.3',
|
|
273
|
+
content: [
|
|
274
|
+
{ type: 'text', text: '第一视角果茶广告短片' },
|
|
275
|
+
{
|
|
276
|
+
type: 'image_url',
|
|
277
|
+
image_url: { url: image.url },
|
|
278
|
+
role: 'reference_image',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
type: 'audio_url',
|
|
282
|
+
audio_url: { url: audio.url },
|
|
283
|
+
role: 'reference_audio',
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
generate_audio: true,
|
|
287
|
+
ratio: '16:9',
|
|
288
|
+
duration: 11,
|
|
289
|
+
watermark: false,
|
|
255
290
|
});
|
|
256
291
|
const jobId = jobResult.data.wyID;
|
|
257
292
|
console.log('视频任务已创建, ID:', jobId);
|
|
@@ -401,4 +436,4 @@ Body:
|
|
|
401
436
|
• 图像编辑:editImage({ messages }) 或 editImage({ prompt, inputs, ... })
|
|
402
437
|
• 单个爬虫:scrapeUrl({ url, projectId? })
|
|
403
438
|
• 批量爬虫:scrapeMultipleUrls({ urls, projectId?, maxConcurrent? })
|
|
404
|
-
- 错误处理:注意处理 401 未登录、402 余额不足、404 组织不存在、500/503 外部服务异常等。
|
|
439
|
+
- 错误处理:注意处理 401 未登录、402 余额不足、404 组织不存在、500/503 外部服务异常等。
|
|
@@ -33,4 +33,23 @@ export const appsClientToolsMethods = {
|
|
|
33
33
|
const result = await this._post("/apps/sensitive/detect", { content });
|
|
34
34
|
return result.data;
|
|
35
35
|
},
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
// ==================== 外部工具 ====================
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 执行 Google 搜索
|
|
41
|
+
* @param {object} options
|
|
42
|
+
* @param {string} options.query - 搜索关键词
|
|
43
|
+
* @param {number} [options.num=10] - 返回结果数量 (1-10)
|
|
44
|
+
* @returns {Promise<{success: boolean, data: Array<{title: string, link: string, snippet: string}>}>}
|
|
45
|
+
*/
|
|
46
|
+
async googleSearch(options = {}) {
|
|
47
|
+
if (!options.query) {
|
|
48
|
+
throw new Error("query is required for googleSearch.");
|
|
49
|
+
}
|
|
50
|
+
return this._post("/apps/tools/google-search", {
|
|
51
|
+
appId: this.appId,
|
|
52
|
+
...options,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -46,19 +46,21 @@ export const appsClientVoiceVideoMethods = {
|
|
|
46
46
|
return response; // 直接返回 Response 对象
|
|
47
47
|
},
|
|
48
48
|
|
|
49
|
-
// ====================
|
|
49
|
+
// ==================== 新增:视频生成 ====================
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param {object} options - { prompt
|
|
52
|
+
* 创建一个视频生成任务(默认走豆包 Seedance 2.0)
|
|
53
|
+
* @param {object} options - { prompt?, content?, model?, generate_audio?, ratio?, duration?, watermark?, resolution?, seed?, return_last_frame?, providerOptions? }
|
|
54
54
|
* @returns {Promise<object>} 视频任务文档
|
|
55
55
|
*/
|
|
56
56
|
async createVideoJob(options = {}) {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const hasPrompt = typeof options.prompt === "string" && options.prompt.trim();
|
|
58
|
+
const hasContent = Array.isArray(options.content) && options.content.length > 0;
|
|
59
|
+
if (!hasPrompt && !hasContent) {
|
|
60
|
+
throw new Error("prompt or content is required for video generation.");
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
return this._post("/apps/
|
|
62
|
+
|
|
63
|
+
return this._post("/apps/videos/tasks", {
|
|
62
64
|
appId: this.appId,
|
|
63
65
|
...options,
|
|
64
66
|
});
|
|
@@ -67,19 +69,23 @@ export const appsClientVoiceVideoMethods = {
|
|
|
67
69
|
/**
|
|
68
70
|
* 基于现有视频创建一个 Remix 任务
|
|
69
71
|
* @param {string} jobId - 原始视频任务的 wyID
|
|
70
|
-
* @param {object} options -
|
|
72
|
+
* @param {object} options - 兼容 createVideoJob 的请求体,后端会自动注入 reference_video
|
|
71
73
|
* @returns {Promise<object>} 新的 Remix 任务初始状态的文档
|
|
72
74
|
*/
|
|
73
75
|
async remixVideoJob(jobId, options = {}) {
|
|
74
76
|
if (!jobId) {
|
|
75
77
|
throw new Error("jobId of the original video is required for remixing.");
|
|
76
78
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
|
|
80
|
+
const hasPrompt = typeof options.prompt === "string" && options.prompt.trim();
|
|
81
|
+
const hasContent = Array.isArray(options.content) && options.content.length > 0;
|
|
82
|
+
if (!hasPrompt && !hasContent) {
|
|
83
|
+
throw new Error("prompt or content is required for remixing.");
|
|
79
84
|
}
|
|
80
|
-
|
|
85
|
+
|
|
86
|
+
return this._post(`/apps/videos/tasks/${jobId}/remix`, {
|
|
81
87
|
appId: this.appId,
|
|
82
|
-
|
|
88
|
+
...options,
|
|
83
89
|
});
|
|
84
90
|
},
|
|
85
91
|
|
|
@@ -92,7 +98,7 @@ export const appsClientVoiceVideoMethods = {
|
|
|
92
98
|
if (!jobId) {
|
|
93
99
|
throw new Error("jobId is required.");
|
|
94
100
|
}
|
|
95
|
-
return this._get(`/apps/
|
|
101
|
+
return this._get(`/apps/videos/tasks/${jobId}`, { appId: this.appId });
|
|
96
102
|
},
|
|
97
103
|
|
|
98
104
|
/**
|
|
@@ -101,6 +107,6 @@ export const appsClientVoiceVideoMethods = {
|
|
|
101
107
|
* @returns {Promise<object>} 任务列表和分页信息
|
|
102
108
|
*/
|
|
103
109
|
async listVideoJobs(options = {}) {
|
|
104
|
-
return this._get("/apps/
|
|
110
|
+
return this._get("/apps/videos/tasks", { appId: this.appId, ...options });
|
|
105
111
|
},
|
|
106
112
|
};
|