seacloud-sdk 0.10.2 → 0.11.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/dist/cli.js +339 -30
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +996 -5
- package/dist/index.js +672 -31
- package/dist/index.js.map +1 -1
- package/package.json +19 -4
- package/README.md +0 -168
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seacloud-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "SeaCloud SDK for JavaScript/TypeScript",
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "SeaCloud SDK for JavaScript/TypeScript - AI models, LLM, content safety scanning",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
20
22
|
],
|
|
21
23
|
"scripts": {
|
|
22
24
|
"build": "tsup",
|
|
@@ -31,10 +33,23 @@
|
|
|
31
33
|
"ai",
|
|
32
34
|
"image-generation",
|
|
33
35
|
"video-generation",
|
|
34
|
-
"llm"
|
|
36
|
+
"llm",
|
|
37
|
+
"content-safety",
|
|
38
|
+
"nsfw-detection",
|
|
39
|
+
"video-scan",
|
|
40
|
+
"image-scan",
|
|
41
|
+
"risk-detection"
|
|
35
42
|
],
|
|
36
43
|
"author": "SeaVerse AI",
|
|
37
44
|
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/SeaVerseAI/seacloud-sdk"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/SeaVerseAI/seacloud-sdk#readme",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/SeaVerseAI/seacloud-sdk/issues"
|
|
52
|
+
},
|
|
38
53
|
"devDependencies": {
|
|
39
54
|
"@types/node": "^20.10.0",
|
|
40
55
|
"tsup": "^8.0.1",
|
package/README.md
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# SeaCloud SDK
|
|
2
|
-
|
|
3
|
-
SeaCloud SDK for JavaScript/TypeScript - 用于调用 SeaCloud AI 服务的官方 SDK。
|
|
4
|
-
|
|
5
|
-
## 功能特性
|
|
6
|
-
|
|
7
|
-
- 🤖 **Agent Chat API** - 多轮对话、工具调用、流式输出
|
|
8
|
-
- 🎨 **图像生成** - 支持多种 AI 图像生成模型
|
|
9
|
-
- 🎬 **视频生成** - Text-to-Video、Image-to-Video
|
|
10
|
-
- 🎵 **音乐生成** - 歌曲、歌词生成
|
|
11
|
-
- 🔄 **流式响应** - 实时获取 AI 响应
|
|
12
|
-
- 📦 **TypeScript 支持** - 完整的类型定义
|
|
13
|
-
|
|
14
|
-
## 安装
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pnpm install seacloud-sdk
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 快速开始
|
|
21
|
-
|
|
22
|
-
### 初始化 SDK
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { initSeacloud, agentChatCompletions, createTextMessage } from 'seacloud-sdk';
|
|
26
|
-
|
|
27
|
-
// 初始化 SDK
|
|
28
|
-
initSeacloud({
|
|
29
|
-
apiKey: 'your-api-key',
|
|
30
|
-
baseUrl: 'https://proxy-rs.seaverse.ai',
|
|
31
|
-
xProject: 'SeaArt', // 可选,默认为 'SeaVerse'
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 简单对话
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
const response = await agentChatCompletions({
|
|
39
|
-
agent_id: 'seagen_agent',
|
|
40
|
-
messages: [
|
|
41
|
-
createTextMessage('user', 'Hello! How are you?')
|
|
42
|
-
],
|
|
43
|
-
model: 'gpt-4o',
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
console.log(response.choices[0].message.content);
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### 流式对话
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
const stream = await agentChatCompletions({
|
|
53
|
-
agent_id: 'seagen_agent',
|
|
54
|
-
messages: [
|
|
55
|
-
createTextMessage('user', 'Tell me a story')
|
|
56
|
-
],
|
|
57
|
-
model: 'gpt-4o',
|
|
58
|
-
stream: true,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
for await (const chunk of stream) {
|
|
62
|
-
const content = chunk.choices[0]?.delta?.content;
|
|
63
|
-
if (content) {
|
|
64
|
-
process.stdout.write(content);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## 配置选项
|
|
70
|
-
|
|
71
|
-
### initSeacloud(options)
|
|
72
|
-
|
|
73
|
-
| 参数 | 类型 | 默认值 | 描述 |
|
|
74
|
-
|------|------|--------|------|
|
|
75
|
-
| `apiKey` | `string` | - | API 密钥,也可通过环境变量 `API_SERVICE_TOKEN` 设置 |
|
|
76
|
-
| `baseUrl` | `string` | `https://proxy-rs.seaverse.ai` | API 服务器地址 |
|
|
77
|
-
| `timeout` | `number` | `30000` | 请求超时时间(毫秒) |
|
|
78
|
-
| `intervalMs` | `number` | `3000` | 轮询间隔(毫秒) |
|
|
79
|
-
| `maxAttempts` | `number` | `100` | 最大轮询次数 |
|
|
80
|
-
| `xProject` | `string` | `'SeaVerse'` | X-Project header 值,用于项目标识 |
|
|
81
|
-
|
|
82
|
-
### xProject 参数说明
|
|
83
|
-
|
|
84
|
-
`xProject` 参数用于设置请求头 `X-Project`,标识请求来源的项目。不同项目可能有不同的配额和权限:
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
// SeaArt 项目
|
|
88
|
-
initSeacloud({
|
|
89
|
-
apiKey: 'your-api-key',
|
|
90
|
-
xProject: 'SeaArt',
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// KIIRA 项目
|
|
94
|
-
initSeacloud({
|
|
95
|
-
apiKey: 'your-api-key',
|
|
96
|
-
xProject: 'KIIRA',
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// 默认使用 SeaVerse
|
|
100
|
-
initSeacloud({
|
|
101
|
-
apiKey: 'your-api-key',
|
|
102
|
-
// xProject 默认为 'SeaVerse'
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Token 获取优先级
|
|
107
|
-
|
|
108
|
-
SDK 会按以下优先级获取 API Token:
|
|
109
|
-
|
|
110
|
-
1. `initSeacloud({ apiKey: '...' })` 传入的 apiKey
|
|
111
|
-
2. 浏览器环境:`localStorage.getItem('auth_token')`
|
|
112
|
-
3. Node.js 环境:`process.env.API_SERVICE_TOKEN`
|
|
113
|
-
|
|
114
|
-
## 环境变量
|
|
115
|
-
|
|
116
|
-
| 变量名 | 描述 |
|
|
117
|
-
|--------|------|
|
|
118
|
-
| `API_SERVICE_TOKEN` | API 密钥 |
|
|
119
|
-
| `SEACLOUD_BASE_URL` | API 服务器地址 |
|
|
120
|
-
|
|
121
|
-
## API 参考
|
|
122
|
-
|
|
123
|
-
### Agent Chat API
|
|
124
|
-
|
|
125
|
-
```typescript
|
|
126
|
-
import { agentChatCompletions, createTextMessage, createImageMessage, createTool } from 'seacloud-sdk';
|
|
127
|
-
|
|
128
|
-
// 文本消息
|
|
129
|
-
const textMessage = createTextMessage('user', 'Hello!');
|
|
130
|
-
|
|
131
|
-
// 图片消息
|
|
132
|
-
const imageMessage = createImageMessage('user', 'What is this?', 'https://example.com/image.jpg');
|
|
133
|
-
|
|
134
|
-
// 创建工具
|
|
135
|
-
const tool = createTool('seagen_text2image_flux1d_artifact_tool');
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### 可用工具列表
|
|
139
|
-
|
|
140
|
-
**图像生成:**
|
|
141
|
-
- `seagen_text2image_flux1d_artifact_tool`
|
|
142
|
-
- `seagen_text2image_seedream40_artifact_tool`
|
|
143
|
-
- `seagen_text2image_google_gemini3_pro_image_artifact_tool`
|
|
144
|
-
- `seagen_blackforestlabs_flux_2_pro_tool`
|
|
145
|
-
- `mm_volces_seedream_4_5_gateway_tool`
|
|
146
|
-
|
|
147
|
-
**图像编辑:**
|
|
148
|
-
- `seagen_edit_image_google_artifact_tool`
|
|
149
|
-
- `seagen_blackforestlabs_flux_2_pro_edit_tool`
|
|
150
|
-
|
|
151
|
-
**视频生成:**
|
|
152
|
-
- `seagen_image2video_wanx26_artifact_tool`
|
|
153
|
-
- `seagen_text2video_wanx26_artifact_tool`
|
|
154
|
-
- `seagen_image2video_seedance_pro_fast_artifact_tool`
|
|
155
|
-
- `mm_text2video_kling_v2_6_gateway_tool`
|
|
156
|
-
- `mm_image2video_kling_v2_6_i2v_gateway_tool`
|
|
157
|
-
|
|
158
|
-
**音乐生成:**
|
|
159
|
-
- `seagen_text2song_mureka_artifact_tool`
|
|
160
|
-
- `seagen_text2lyrics_mureka_artifact_tool`
|
|
161
|
-
|
|
162
|
-
## 示例
|
|
163
|
-
|
|
164
|
-
更多示例请查看 [examples_agent.ts](./examples_agent.ts)
|
|
165
|
-
|
|
166
|
-
## License
|
|
167
|
-
|
|
168
|
-
MIT
|