bjchy-udg-sdk 1.8.12 → 1.8.14
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 +2 -2
- package/package.json +2 -3
- package/src/ai.js +3 -3
- package/src/request.js +1 -1
package/README.md
CHANGED
|
@@ -594,7 +594,7 @@ curl -X POST https://udg.vule.cn/api/execute -H 'X-Admin-Key: <ADMIN_KEY>' -H 'C
|
|
|
594
594
|
|
|
595
595
|
## AI 模型选择
|
|
596
596
|
|
|
597
|
-
所有有效租户均可使用网关提供的 AI 服务及所有已注册用途,租户调用无日 token 配额。登录后调用 `client.ai.listModels()`,获取 `{ defaultModel, models }`。`models`
|
|
597
|
+
所有有效租户均可使用网关提供的 AI 服务及所有已注册用途,租户调用无日 token 配额。登录后调用 `client.ai.listModels()`,获取 `{ defaultModel, documentDefaultModel, models }`。`models` 是网关开放的通用模型清单,包含 `defaultModel`。文档解析可选择 `models` 中的值或 `documentDefaultModel`。
|
|
598
598
|
|
|
599
599
|
```js
|
|
600
600
|
const { defaultModel, models } = await client.ai.listModels()
|
|
@@ -607,7 +607,7 @@ const { text, model } = await client.ai.complete({
|
|
|
607
607
|
})
|
|
608
608
|
```
|
|
609
609
|
|
|
610
|
-
`complete`、`analyzeDocument`、`nlQuery` 及 `ask(question, options)` 的选项均支持 `model
|
|
610
|
+
`complete`、`analyzeDocument`、`nlQuery` 及 `ask(question, options)` 的选项均支持 `model`。省略时,Word 和 Excel 的 `analyzeDocument` 使用 `openai`,由 AIGATE 选择 OpenAI 提供商的默认模型。`complete`、`nlQuery` 和 `ask` 默认使用 DeepSeek V4 Flash(`deepseek/deepseek-v4-flash`)。这两种默认值可由网关配置调整。已知当前接口接受的模型 ID 或别名时,可直接填写 `model`,无需先调用 `listModels()`。传入未开放的值会收到 `INVALID_PARAM`。`complete`、`analyzeDocument` 和 `nlQuery` 返回实际的 `model`。问数的计划、重试和解读会使用同一个模型选项,响应中的 `model` 为生成最终计划的模型。`ask` 按 `format` 返回数字、行数组或摘要字符串。
|
|
611
611
|
|
|
612
612
|
HTTP 使用租户访问令牌或绑定租户的服务令牌,以 Bearer 方式向 `POST /api/ai/models` 发送 POST 请求即可,租户取自令牌。现有客户端仍可发送相同的 `appid`。`POST /api/ai/complete` 和 `/api/ai/nl-query` 的 JSON 请求及 `POST /api/ai/document` 的 multipart 表单均可传 `model`。
|
|
613
613
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bjchy-udg-sdk",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.14",
|
|
4
4
|
"description": "Universal Data Gateway SDK - 跨端统一数据访问(微信小程序 / Web / Node.js),API 兼容微信云开发",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -23,6 +23,5 @@
|
|
|
23
23
|
"type": "git",
|
|
24
24
|
"url": "https://git.weixin.qq.com/wangzhongsheng/UDGV1.git",
|
|
25
25
|
"directory": "sdk"
|
|
26
|
-
}
|
|
27
|
-
"dependencies": {}
|
|
26
|
+
}
|
|
28
27
|
}
|
package/src/ai.js
CHANGED
|
@@ -9,7 +9,7 @@ class AiNamespace {
|
|
|
9
9
|
this._ctx = ctx
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
/** @returns {Promise<{defaultModel: string, models: string[]}>}
|
|
12
|
+
/** @returns {Promise<{defaultModel: string, documentDefaultModel?: string, models: string[]}>} 通用模型清单以及通用和文档的默认模型。 */
|
|
13
13
|
listModels() {
|
|
14
14
|
return post(this._ctx, '/api/ai/models')
|
|
15
15
|
}
|
|
@@ -30,9 +30,9 @@ class AiNamespace {
|
|
|
30
30
|
})
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/** 上传并解析 DOCX/XLSX
|
|
33
|
+
/** 上传并解析 DOCX/XLSX。省略 model 时选择网关的文档默认模型。 */
|
|
34
34
|
async analyzeDocument(options) {
|
|
35
|
-
const model = options
|
|
35
|
+
const model = options === undefined || options === null ? undefined : options.model
|
|
36
36
|
if (model !== undefined && (typeof model !== 'string' || !model.trim())) {
|
|
37
37
|
throw new UdgRequestError({ errorCode: 'INVALID_PARAM', errorMessage: 'model 必须是非空的模型 ID 或别名' })
|
|
38
38
|
}
|
package/src/request.js
CHANGED
|
@@ -237,7 +237,7 @@ function uploadViaWx(url, filePath, fields, headers, timeout) {
|
|
|
237
237
|
success(res) {
|
|
238
238
|
let json = res.data
|
|
239
239
|
if (typeof json === 'string') {
|
|
240
|
-
try { json = JSON.parse(json) } catch { json = null }
|
|
240
|
+
try { json = JSON.parse(json) } catch (e) { json = null }
|
|
241
241
|
}
|
|
242
242
|
resolve({ status: res.statusCode, json })
|
|
243
243
|
},
|