ai-world-sdk 1.3.2 → 1.3.5

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/dist/config.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
11
11
  */
12
- export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.3.2";
12
+ export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.3.5";
13
13
  /**
14
14
  * 版本兼容性错误
15
15
  */
@@ -34,8 +34,8 @@ declare class SDKConfig {
34
34
  private _authenticated;
35
35
  private _authCheckPromise;
36
36
  private _currentUser;
37
- readonly sdkSignature = "AI_WORLD_SDK_V:1.3.2";
38
- readonly sdkVersion = "1.3.2";
37
+ readonly sdkSignature = "AI_WORLD_SDK_V:1.3.5";
38
+ readonly sdkVersion = "1.3.5";
39
39
  constructor();
40
40
  /**
41
41
  * Set global base URL
package/dist/config.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.sdkConfig = exports.VersionCompatibilityError = exports.SDK_SIGNATURE = void 0;
8
8
  // SDK 版本号(构建时自动从 package.json 更新)
9
9
  // 此版本号会在运行 npm run build 时自动从 package.json 读取并更新
10
- const SDK_VERSION = "1.3.2";
10
+ const SDK_VERSION = "1.3.5";
11
11
  /**
12
12
  * SDK 特征码 - 用于在构建后的 JS 文件中识别 SDK 版本
13
13
  * 格式: AI_WORLD_SDK_V:版本号
@@ -15,7 +15,7 @@ const SDK_VERSION = "1.3.2";
15
15
  *
16
16
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
17
17
  */
18
- exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.3.2";
18
+ exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.3.5";
19
19
  /**
20
20
  * 版本兼容性错误
21
21
  */
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  import { BaseChatModel, BaseChatModelParams } from "./base";
8
8
  import { DoubaoImageGenerationClient, DoubaoImageSize, type DoubaoImageGenerationConfig, type DoubaoImageGenerationRequest, type DoubaoImageGenerationResponse } from "./doubao-image-generation";
9
9
  import { GeminiImageGenerationClient, type GeminiImageGenerationConfig, type GeminiImageGenerationRequest, type GeminiImageGenerationResponse } from "./gemini-image-generation";
10
- import { VideoGenerationClient, type VideoGenerationConfig, type VideoGenerationRequest, type ContentGenerationTaskID, type ContentGenerationTask } from "./video_generation";
10
+ import { VideoGenerationClient, type VideoGenerationConfig, type VideoGenerationRequest, type ContentGenerationTaskID, type ContentGenerationTask, VideoUnderstandingClient, type VideoUnderstandingConfig, type VideoUnderstandingRequest, type VideoUnderstandingResponse, type VideoUnderstandingStreamChunk, type VideoUnderstandingMessage, type VideoUnderstandingContent } from "./video_generation";
11
11
  import { OpenAIVideoGenerationClient, type OpenAIVideoGenerationConfig, type OpenAIVideoGenerationRequest, type OpenAIVideoTaskResponse } from "./openai_video_generation";
12
12
  import { DownloadClient, type DownloadConfig, type DownloadOptions, type StreamDownloadOptions } from "./download";
13
13
  import { AuthClient, getCurrentUserInfo, type AuthConfig, type UserInfo } from "./auth";
@@ -25,11 +25,12 @@ export interface LangchainClientConfig {
25
25
  export { DoubaoImageGenerationClient, type DoubaoImageGenerationConfig, type DoubaoImageGenerationRequest, type DoubaoImageGenerationResponse, type DoubaoImageSize, };
26
26
  export { GeminiImageGenerationClient, type GeminiImageGenerationConfig, type GeminiImageGenerationRequest, type GeminiImageGenerationResponse, };
27
27
  export { VideoGenerationClient, type VideoGenerationConfig, type VideoGenerationRequest, type ContentGenerationTaskID, type ContentGenerationTask, };
28
+ export { VideoUnderstandingClient, type VideoUnderstandingConfig, type VideoUnderstandingRequest, type VideoUnderstandingResponse, type VideoUnderstandingStreamChunk, type VideoUnderstandingMessage, type VideoUnderstandingContent, };
28
29
  export { OpenAIVideoGenerationClient, type OpenAIVideoGenerationConfig, type OpenAIVideoGenerationRequest, type OpenAIVideoTaskResponse, };
29
30
  export { DownloadClient, type DownloadConfig, type DownloadOptions, type StreamDownloadOptions, };
30
31
  export { MinioStorageClient, type MinioStorageConfig, type UploadResponse, type ObjectInfo, type PresignedUrlResponse, type UploadOptions, type ListOptions, } from "./minio";
31
32
  export { ResourceClient, type ResourceClientConfig, type ResourceInfo, type AccessLevel, type UploadResourceOptions, type ListResourceOptions, } from "./resource";
32
- export { DatabaseRequestClient, type DatabaseRequestClientConfig, type DatabaseRequestInfo, type RequestType, type RequestStatus, type ColumnDefinition, type IndexDefinition, type ForeignKeyDefinition, type SchemaDefinition, type SubmitCreateRequestOptions, type SubmitMigrateRequestOptions, type ListRequestsOptions, } from "./database-requests";
33
+ export { VersionedResourceClient, type VersionedResourceClientConfig, type VersionedResourceInfo, type VersionedResourceSummary, type VersionedResourceListResponse, type ListVersionedResourceOptions, } from "./versioned-resource";
33
34
  export { AgentSkillClient, type AgentSkillClientConfig, type AgentSkillInfo, type AgentSkillListResponse, type ListSkillsOptions, } from "./agent-skills";
34
35
  export { AuthClient, getCurrentUserInfo, type AuthConfig, type UserInfo, };
35
36
  export { sdkConfig, VersionCompatibilityError, SDK_SIGNATURE, type AuthenticatedUser } from "./config";
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.SDK_SIGNATURE = exports.VersionCompatibilityError = exports.sdkConfig = exports.getCurrentUserInfo = exports.AuthClient = exports.AgentSkillClient = exports.DatabaseRequestClient = exports.ResourceClient = exports.MinioStorageClient = exports.DownloadClient = exports.OpenAIVideoGenerationClient = exports.VideoGenerationClient = exports.GeminiImageGenerationClient = exports.DoubaoImageGenerationClient = exports.ChatAnthropic = exports.ChatGoogleGenerativeAI = exports.ChatOpenAI = exports.BaseChatModel = exports.AIMessageChunk = exports.SystemMessage = exports.AIMessage = exports.HumanMessage = void 0;
23
+ exports.SDK_SIGNATURE = exports.VersionCompatibilityError = exports.sdkConfig = exports.getCurrentUserInfo = exports.AuthClient = exports.AgentSkillClient = exports.VersionedResourceClient = exports.ResourceClient = exports.MinioStorageClient = exports.DownloadClient = exports.OpenAIVideoGenerationClient = exports.VideoUnderstandingClient = exports.VideoGenerationClient = exports.GeminiImageGenerationClient = exports.DoubaoImageGenerationClient = exports.ChatAnthropic = exports.ChatGoogleGenerativeAI = exports.ChatOpenAI = exports.BaseChatModel = exports.AIMessageChunk = exports.SystemMessage = exports.AIMessage = exports.HumanMessage = void 0;
24
24
  exports.createChatModel = createChatModel;
25
25
  const openai_1 = require("./chat_models/openai");
26
26
  const google_1 = require("./chat_models/google");
@@ -30,6 +30,7 @@ const gemini_image_generation_1 = require("./gemini-image-generation");
30
30
  Object.defineProperty(exports, "GeminiImageGenerationClient", { enumerable: true, get: function () { return gemini_image_generation_1.GeminiImageGenerationClient; } });
31
31
  const video_generation_1 = require("./video_generation");
32
32
  Object.defineProperty(exports, "VideoGenerationClient", { enumerable: true, get: function () { return video_generation_1.VideoGenerationClient; } });
33
+ Object.defineProperty(exports, "VideoUnderstandingClient", { enumerable: true, get: function () { return video_generation_1.VideoUnderstandingClient; } });
33
34
  const openai_video_generation_1 = require("./openai_video_generation");
34
35
  Object.defineProperty(exports, "OpenAIVideoGenerationClient", { enumerable: true, get: function () { return openai_video_generation_1.OpenAIVideoGenerationClient; } });
35
36
  const download_1 = require("./download");
@@ -59,9 +60,9 @@ Object.defineProperty(exports, "MinioStorageClient", { enumerable: true, get: fu
59
60
  // Export resource management client
60
61
  var resource_1 = require("./resource");
61
62
  Object.defineProperty(exports, "ResourceClient", { enumerable: true, get: function () { return resource_1.ResourceClient; } });
62
- // Export database request client
63
- var database_requests_1 = require("./database-requests");
64
- Object.defineProperty(exports, "DatabaseRequestClient", { enumerable: true, get: function () { return database_requests_1.DatabaseRequestClient; } });
63
+ // Export versioned resource client
64
+ var versioned_resource_1 = require("./versioned-resource");
65
+ Object.defineProperty(exports, "VersionedResourceClient", { enumerable: true, get: function () { return versioned_resource_1.VersionedResourceClient; } });
65
66
  // Export agent skill client
66
67
  var agent_skills_1 = require("./agent-skills");
67
68
  Object.defineProperty(exports, "AgentSkillClient", { enumerable: true, get: function () { return agent_skills_1.AgentSkillClient; } });
package/dist/llm.js CHANGED
@@ -32,6 +32,10 @@ function createProvider(provider, endpointType, pluginId) {
32
32
  settings.baseURL = `${serverUrl}/api/llm/openrouter`;
33
33
  return (0, ai_sdk_provider_1.createOpenRouter)(settings);
34
34
  }
35
+ else if (provider === "kunpo") {
36
+ settings.baseURL = `${serverUrl}/api/llm/kunpo`;
37
+ return (0, ai_sdk_provider_1.createOpenRouter)(settings);
38
+ }
35
39
  switch (endpointType) {
36
40
  case "openai":
37
41
  return (0, openai_1.createOpenAI)(settings);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 模型提供商
3
3
  */
4
- export type AIModelProvider = "api2img" | "aihubmix" | "doubao" | "gemini" | "shubiaobiao" | "anthropic" | "aiping" | "openrouter";
4
+ export type AIModelProvider = "api2img" | "aihubmix" | "doubao" | "gemini" | "shubiaobiao" | "anthropic" | "aiping" | "openrouter" | "kunpo";
5
5
  /**
6
6
  * 模型端点类型
7
7
  * - openai: OpenAI 兼容 API(/v1/chat/completions 等)
@@ -11,6 +11,7 @@ exports.PROVIDER_CONFIGS = {
11
11
  gemini: { provider: "gemini", modelType: "gemini" },
12
12
  anthropic: { provider: "anthropic", modelType: "anthropic" },
13
13
  openrouter: { provider: "openrouter", modelType: "openai" },
14
+ kunpo: { provider: "kunpo", modelType: "openai" },
14
15
  };
15
16
  function getProviderConfig(provider) {
16
17
  return exports.PROVIDER_CONFIGS[provider];
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Versioned Resource Client
3
+ * 版本化资源管理客户端
4
+ * 通过后端 /api/versioned-resources 操作版本化资源系统
5
+ * 资源名称为全局唯一标识,支持语义化版本号管理
6
+ */
7
+ export interface VersionedResourceClientConfig {
8
+ baseUrl?: string;
9
+ token?: string;
10
+ headers?: Record<string, string>;
11
+ }
12
+ export interface VersionedResourceInfo {
13
+ id: number;
14
+ name: string;
15
+ version: string;
16
+ description?: string;
17
+ filename: string;
18
+ size: number;
19
+ content_type: string;
20
+ uploader_id: number;
21
+ uploader_name?: string;
22
+ created_at: string;
23
+ }
24
+ export interface VersionedResourceSummary {
25
+ name: string;
26
+ latest_version: string;
27
+ description?: string;
28
+ filename: string;
29
+ size: number;
30
+ content_type: string;
31
+ version_count: number;
32
+ latest_uploader_name?: string;
33
+ created_at: string;
34
+ }
35
+ export interface VersionedResourceListResponse {
36
+ items: VersionedResourceSummary[];
37
+ total: number;
38
+ page: number;
39
+ page_size: number;
40
+ }
41
+ export interface ListVersionedResourceOptions {
42
+ page?: number;
43
+ pageSize?: number;
44
+ search?: string;
45
+ }
46
+ /**
47
+ * Versioned Resource Client
48
+ * 版本化资源管理客户端类
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * import { VersionedResourceClient } from 'ai-world-sdk';
53
+ *
54
+ * const vr = new VersionedResourceClient();
55
+ *
56
+ * // 上传新版本
57
+ * const file = new File(['content'], 'config.json', { type: 'application/json' });
58
+ * const res = await vr.upload('my-config', '1.0.0', file, '初始版本');
59
+ *
60
+ * // 获取最新版本
61
+ * const latest = await vr.getLatest('my-config');
62
+ *
63
+ * // 列出所有版本
64
+ * const versions = await vr.listVersions('my-config');
65
+ *
66
+ * // 下载指定版本
67
+ * const blob = await vr.download('my-config', '1.0.0');
68
+ *
69
+ * // 下载最新版本
70
+ * const latestBlob = await vr.download('my-config', 'latest');
71
+ * ```
72
+ */
73
+ export declare class VersionedResourceClient {
74
+ private baseUrl;
75
+ private headers;
76
+ constructor(config?: VersionedResourceClientConfig);
77
+ private handleErrorResponse;
78
+ /**
79
+ * 上传新版本
80
+ * @param name 资源名称(全局唯一标识)
81
+ * @param version 语义化版本号(必须高于当前最新版本)
82
+ * @param file 文件
83
+ * @param description 可选的版本描述
84
+ */
85
+ upload(name: string, version: string, file: File | Blob, description?: string): Promise<VersionedResourceInfo>;
86
+ /**
87
+ * 分页列出所有版本化资源(聚合最新版本信息)
88
+ */
89
+ list(options?: ListVersionedResourceOptions): Promise<VersionedResourceListResponse>;
90
+ /**
91
+ * 列出指定资源的所有版本(按版本号降序)
92
+ */
93
+ listVersions(name: string): Promise<VersionedResourceInfo[]>;
94
+ /**
95
+ * 获取指定资源的最新版本信息
96
+ */
97
+ getLatest(name: string): Promise<VersionedResourceInfo>;
98
+ /**
99
+ * 获取指定版本信息
100
+ */
101
+ getVersion(name: string, version: string): Promise<VersionedResourceInfo>;
102
+ /**
103
+ * 下载指定版本文件(version 可传 "latest" 下载最新版本)
104
+ */
105
+ download(name: string, version: string): Promise<Blob>;
106
+ /**
107
+ * 删除指定版本
108
+ */
109
+ deleteVersion(name: string, version: string): Promise<{
110
+ name: string;
111
+ version: string;
112
+ deleted: boolean;
113
+ }>;
114
+ }
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /**
3
+ * Versioned Resource Client
4
+ * 版本化资源管理客户端
5
+ * 通过后端 /api/versioned-resources 操作版本化资源系统
6
+ * 资源名称为全局唯一标识,支持语义化版本号管理
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.VersionedResourceClient = void 0;
10
+ const config_1 = require("./config");
11
+ const log_1 = require("./log");
12
+ // ==================== VersionedResourceClient ====================
13
+ /**
14
+ * Versioned Resource Client
15
+ * 版本化资源管理客户端类
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { VersionedResourceClient } from 'ai-world-sdk';
20
+ *
21
+ * const vr = new VersionedResourceClient();
22
+ *
23
+ * // 上传新版本
24
+ * const file = new File(['content'], 'config.json', { type: 'application/json' });
25
+ * const res = await vr.upload('my-config', '1.0.0', file, '初始版本');
26
+ *
27
+ * // 获取最新版本
28
+ * const latest = await vr.getLatest('my-config');
29
+ *
30
+ * // 列出所有版本
31
+ * const versions = await vr.listVersions('my-config');
32
+ *
33
+ * // 下载指定版本
34
+ * const blob = await vr.download('my-config', '1.0.0');
35
+ *
36
+ * // 下载最新版本
37
+ * const latestBlob = await vr.download('my-config', 'latest');
38
+ * ```
39
+ */
40
+ class VersionedResourceClient {
41
+ constructor(config = {}) {
42
+ this.baseUrl =
43
+ config.baseUrl ||
44
+ config_1.sdkConfig.getServerUrl() ||
45
+ (typeof window !== "undefined" ? window.location.origin : "");
46
+ const globalHeaders = config_1.sdkConfig.getHeaders();
47
+ const globalToken = config.token || config_1.sdkConfig.getToken();
48
+ this.headers = {
49
+ ...globalHeaders,
50
+ ...config.headers,
51
+ };
52
+ if (globalToken) {
53
+ this.headers["Authorization"] = `Bearer ${globalToken}`;
54
+ }
55
+ }
56
+ async handleErrorResponse(response) {
57
+ let errorMessage = `Request failed: ${response.status} ${response.statusText}`;
58
+ try {
59
+ const errorText = await response.text();
60
+ const errorJson = JSON.parse(errorText);
61
+ errorMessage = errorJson.detail || errorMessage;
62
+ }
63
+ catch {
64
+ // ignore parse error
65
+ }
66
+ throw new Error(errorMessage);
67
+ }
68
+ /**
69
+ * 上传新版本
70
+ * @param name 资源名称(全局唯一标识)
71
+ * @param version 语义化版本号(必须高于当前最新版本)
72
+ * @param file 文件
73
+ * @param description 可选的版本描述
74
+ */
75
+ async upload(name, version, file, description) {
76
+ const params = new URLSearchParams();
77
+ params.append("name", name);
78
+ params.append("version", version);
79
+ if (description)
80
+ params.append("description", description);
81
+ const url = `${this.baseUrl}/api/versioned-resources/upload?${params.toString()}`;
82
+ const formData = new FormData();
83
+ formData.append("file", file);
84
+ (0, log_1.debugLog)("VersionedResource", `Uploading ${name}@${version}`);
85
+ (0, log_1.logRequest)("POST", url);
86
+ const response = await fetch(url, {
87
+ method: "POST",
88
+ headers: {
89
+ ...this.headers,
90
+ },
91
+ body: formData,
92
+ });
93
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, response.body);
94
+ if (!response.ok) {
95
+ return this.handleErrorResponse(response);
96
+ }
97
+ return response.json();
98
+ }
99
+ /**
100
+ * 分页列出所有版本化资源(聚合最新版本信息)
101
+ */
102
+ async list(options = {}) {
103
+ const params = new URLSearchParams();
104
+ if (options.page)
105
+ params.append("page", options.page.toString());
106
+ if (options.pageSize)
107
+ params.append("page_size", options.pageSize.toString());
108
+ if (options.search)
109
+ params.append("search", options.search);
110
+ const url = `${this.baseUrl}/api/versioned-resources/?${params.toString()}`;
111
+ (0, log_1.debugLog)("VersionedResource", `Listing resources`);
112
+ (0, log_1.logRequest)("GET", url);
113
+ const response = await fetch(url, {
114
+ method: "GET",
115
+ headers: this.headers,
116
+ });
117
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, response.body);
118
+ if (!response.ok) {
119
+ return this.handleErrorResponse(response);
120
+ }
121
+ return response.json();
122
+ }
123
+ /**
124
+ * 列出指定资源的所有版本(按版本号降序)
125
+ */
126
+ async listVersions(name) {
127
+ const url = `${this.baseUrl}/api/versioned-resources/${encodeURIComponent(name)}/versions`;
128
+ (0, log_1.debugLog)("VersionedResource", `Listing versions of ${name}`);
129
+ (0, log_1.logRequest)("GET", url);
130
+ const response = await fetch(url, {
131
+ method: "GET",
132
+ headers: this.headers,
133
+ });
134
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, response.body);
135
+ if (!response.ok) {
136
+ return this.handleErrorResponse(response);
137
+ }
138
+ return response.json();
139
+ }
140
+ /**
141
+ * 获取指定资源的最新版本信息
142
+ */
143
+ async getLatest(name) {
144
+ const url = `${this.baseUrl}/api/versioned-resources/${encodeURIComponent(name)}/latest`;
145
+ (0, log_1.debugLog)("VersionedResource", `Getting latest version of ${name}`);
146
+ (0, log_1.logRequest)("GET", url);
147
+ const response = await fetch(url, {
148
+ method: "GET",
149
+ headers: this.headers,
150
+ });
151
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, response.body);
152
+ if (!response.ok) {
153
+ return this.handleErrorResponse(response);
154
+ }
155
+ return response.json();
156
+ }
157
+ /**
158
+ * 获取指定版本信息
159
+ */
160
+ async getVersion(name, version) {
161
+ const url = `${this.baseUrl}/api/versioned-resources/${encodeURIComponent(name)}/${encodeURIComponent(version)}`;
162
+ (0, log_1.debugLog)("VersionedResource", `Getting ${name}@${version}`);
163
+ (0, log_1.logRequest)("GET", url);
164
+ const response = await fetch(url, {
165
+ method: "GET",
166
+ headers: this.headers,
167
+ });
168
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, response.body);
169
+ if (!response.ok) {
170
+ return this.handleErrorResponse(response);
171
+ }
172
+ return response.json();
173
+ }
174
+ /**
175
+ * 下载指定版本文件(version 可传 "latest" 下载最新版本)
176
+ */
177
+ async download(name, version) {
178
+ const url = `${this.baseUrl}/api/versioned-resources/${encodeURIComponent(name)}/${encodeURIComponent(version)}/download`;
179
+ (0, log_1.debugLog)("VersionedResource", `Downloading ${name}@${version}`);
180
+ (0, log_1.logRequest)("GET", url);
181
+ const response = await fetch(url, {
182
+ method: "GET",
183
+ headers: this.headers,
184
+ });
185
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, response.body);
186
+ if (!response.ok) {
187
+ return this.handleErrorResponse(response);
188
+ }
189
+ return response.blob();
190
+ }
191
+ /**
192
+ * 删除指定版本
193
+ */
194
+ async deleteVersion(name, version) {
195
+ const url = `${this.baseUrl}/api/versioned-resources/${encodeURIComponent(name)}/${encodeURIComponent(version)}`;
196
+ (0, log_1.debugLog)("VersionedResource", `Deleting ${name}@${version}`);
197
+ (0, log_1.logRequest)("DELETE", url);
198
+ const response = await fetch(url, {
199
+ method: "DELETE",
200
+ headers: this.headers,
201
+ });
202
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, response.body);
203
+ if (!response.ok) {
204
+ return this.handleErrorResponse(response);
205
+ }
206
+ return response.json();
207
+ }
208
+ }
209
+ exports.VersionedResourceClient = VersionedResourceClient;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Video Generation Client
3
- * 视频生成客户端
2
+ * Video Generation & Understanding Client
3
+ * 视频生成 & 视频理解客户端
4
4
  */
5
5
  export interface VideoGenerationConfig {
6
6
  baseUrl?: string;
@@ -88,3 +88,150 @@ export declare class VideoGenerationClient {
88
88
  timeout?: number;
89
89
  }): Promise<ContentGenerationTask>;
90
90
  }
91
+ export interface VideoUnderstandingConfig {
92
+ baseUrl?: string;
93
+ token?: string;
94
+ headers?: Record<string, string>;
95
+ }
96
+ export interface VideoUnderstandingVideoURL {
97
+ url: string;
98
+ fps?: number;
99
+ }
100
+ export interface VideoUnderstandingContentText {
101
+ type: "text";
102
+ text: string;
103
+ }
104
+ export interface VideoUnderstandingContentVideo {
105
+ type: "video_url";
106
+ video_url: VideoUnderstandingVideoURL;
107
+ }
108
+ export interface VideoUnderstandingContentImage {
109
+ type: "image_url";
110
+ image_url: {
111
+ url: string;
112
+ };
113
+ }
114
+ export type VideoUnderstandingContent = VideoUnderstandingContentText | VideoUnderstandingContentVideo | VideoUnderstandingContentImage;
115
+ export interface VideoUnderstandingMessage {
116
+ role: "system" | "user" | "assistant";
117
+ content: string | VideoUnderstandingContent[];
118
+ }
119
+ export interface VideoUnderstandingRequest {
120
+ model?: string;
121
+ /** 视频 URL(简化参数,与 messages 二选一) */
122
+ video_url?: string;
123
+ /** 文本提示词(配合 video_url 使用) */
124
+ prompt?: string;
125
+ /** 视频采样帧率 */
126
+ fps?: number;
127
+ /** 完整消息列表(高级用法)。提供时忽略 video_url/prompt/fps */
128
+ messages?: VideoUnderstandingMessage[];
129
+ /** 是否流式输出 */
130
+ stream?: boolean;
131
+ /** 最大输出 token 数 */
132
+ max_tokens?: number;
133
+ /** 采样温度 */
134
+ temperature?: number;
135
+ /** 核采样参数 */
136
+ top_p?: number;
137
+ /** 用户标识 */
138
+ user?: string;
139
+ }
140
+ /** 视频理解使用情况 */
141
+ export interface VideoUnderstandingUsage {
142
+ /** 提示 token 数 */
143
+ prompt_tokens: number;
144
+ /** 完成 token 数 */
145
+ completion_tokens: number;
146
+ /** 总 token 数 */
147
+ total_tokens: number;
148
+ }
149
+ /** 视频理解选择 */
150
+ export interface VideoUnderstandingChoice {
151
+ /** 索引 */
152
+ index: number;
153
+ /** 消息 */
154
+ message: {
155
+ /** 角色 */
156
+ role: string;
157
+ /** 内容 */
158
+ content: string;
159
+ };
160
+ /** 完成原因 */
161
+ finish_reason: string | null;
162
+ }
163
+ export interface VideoUnderstandingResponse {
164
+ /** 任务 ID */
165
+ id: string;
166
+ /** 对象 */
167
+ object: string;
168
+ /** 模型 */
169
+ model: string;
170
+ /** 选择 */
171
+ choices: VideoUnderstandingChoice[];
172
+ /** 使用情况 */
173
+ usage?: VideoUnderstandingUsage;
174
+ }
175
+ export interface VideoUnderstandingStreamDelta {
176
+ /** 角色 */
177
+ role?: string;
178
+ /** 内容 */
179
+ content?: string;
180
+ }
181
+ export interface VideoUnderstandingStreamChoice {
182
+ /** 索引 */
183
+ index: number;
184
+ /** 增量 */
185
+ delta: VideoUnderstandingStreamDelta;
186
+ /** 完成原因 */
187
+ finish_reason: string | null;
188
+ }
189
+ export interface VideoUnderstandingStreamChunk {
190
+ /** 任务 ID */
191
+ id: string;
192
+ /** 对象 */
193
+ object: string;
194
+ /** 模型 */
195
+ model: string;
196
+ /** 选择 */
197
+ choices: VideoUnderstandingStreamChoice[];
198
+ }
199
+ export declare class VideoUnderstandingClient {
200
+ private headers;
201
+ constructor(config?: VideoUnderstandingConfig);
202
+ /**
203
+ * Analyze a video (non-streaming)
204
+ * 视频理解(非流式)
205
+ */
206
+ understand(request: VideoUnderstandingRequest): Promise<VideoUnderstandingResponse>;
207
+ /**
208
+ * Analyze a video with streaming response
209
+ * 视频理解(流式)
210
+ *
211
+ * @returns AsyncGenerator yielding content chunks
212
+ */
213
+ understandStream(request: VideoUnderstandingRequest): AsyncGenerator<VideoUnderstandingStreamChunk, void, unknown>;
214
+ /**
215
+ * Convenience: analyze video and return full text content
216
+ * 便捷方法:分析视频并返回完整文本
217
+ */
218
+ analyzeVideo(videoUrl: string, options?: {
219
+ prompt?: string;
220
+ fps?: number;
221
+ model?: string;
222
+ max_tokens?: number;
223
+ }): Promise<string>;
224
+ /**
225
+ * Convenience: analyze video with streaming, collecting full text
226
+ * 便捷方法:流式分析视频,收集完整文本
227
+ *
228
+ * @param onChunk optional callback for each text chunk
229
+ */
230
+ analyzeVideoStream(videoUrl: string, options?: {
231
+ prompt?: string;
232
+ fps?: number;
233
+ model?: string;
234
+ max_tokens?: number;
235
+ onChunk?: (text: string) => void;
236
+ }): Promise<string>;
237
+ }