@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
- ## [新增] Sora 视频生成
205
+ ## [新增] 视频生成(Seedance 2.0)
206
206
 
207
- 通过 AppsClient 调用 Sora 视频生成服务。计费将自动关联到应用所属的组织。
207
+ 通过 AppsClient 调用统一视频任务接口。当前云模式默认视频模型为 `agent:tacore-3.3`,后端会映射到火山引擎 `doubao-seedance-2-0-260128`。计费将自动关联到应用所属的组织。
208
208
 
209
209
  ### 定价
210
- - **sora-2**: 300 积分/次
211
- - **sora-2-pro**: 1500 积分/次
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
- - `model` (string, 必填): 模型名称, 'sora-2' 或 'sora-2-pro'。
219
- - `size` (string, 可选): 视频尺寸, 默认为 '1920x1080'
220
- - `seconds` (number, 可选): 视频时长, 默认为 6。
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` (string, 必填): 用于修改视频的提示词。
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
- prompt: 'A stylish woman walks down a Tokyo street filled with warm glowing neon and animated city signage.',
254
- model: 'sora-2'
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
- // ==================== 新增:Sora 视频生成 ====================
49
+ // ==================== 新增:视频生成 ====================
50
50
 
51
51
  /**
52
- * 创建一个 Sora 视频生成任务
53
- * @param {object} options - { prompt, model, size, seconds }
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
- if (!options.prompt || !options.model) {
58
- throw new Error("prompt and model are required for video generation.");
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
- // The middleware uses appId from the body to find the organization
61
- return this._post("/apps/sora/videos", {
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 - { prompt }
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
- if (!options.prompt) {
78
- throw new Error("A new prompt is required for remixing.");
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
- return this._post(`/apps/sora/videos/${jobId}/remix`, {
85
+
86
+ return this._post(`/apps/videos/tasks/${jobId}/remix`, {
81
87
  appId: this.appId,
82
- prompt: options.prompt,
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/sora/videos/${jobId}`, { appId: this.appId });
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/sora/videos", { appId: this.appId, ...options });
110
+ return this._get("/apps/videos/tasks", { appId: this.appId, ...options });
105
111
  },
106
112
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tacoreai/web-sdk",
3
3
  "description": "This file is for app server package, not the real npm package",
4
- "version": "1.21.0",
4
+ "version": "1.22.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public",