@fastgpt-plugin/sdk-client 0.1.0-alpha.5 → 1.2.0-alpha.1
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/LICENSE +35 -0
- package/README.en.md +40 -10
- package/README.md +41 -11
- package/dist/index.d.ts +175 -85
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# FastGPT Open Source License
|
|
2
|
+
|
|
3
|
+
The FastGPT is licensed under the Apache License 2.0, with the following additional conditions:
|
|
4
|
+
|
|
5
|
+
1. FastGPT is permitted to be used for commercialization. You can use FastGPT as a "backend-as-a-service" for your other applications, or delivering it to enterprises as an application development platform. However, when the following conditions are met, you must contact the producer to obtain a commercial license:
|
|
6
|
+
|
|
7
|
+
a. Multi-tenant SaaS service: Unless explicitly authorized by FastGPT in writing, you may not use the FastGPT.AI source code to operate a multi-tenant SaaS service that is similar to the FastGPT.
|
|
8
|
+
b. LOGO and copyright information: In the process of using FastGPT, you may not remove or modify the LOGO or copyright information in the FastGPT console.
|
|
9
|
+
|
|
10
|
+
Please contact dennis@sealos.io by email to inquire about licensing matters.
|
|
11
|
+
|
|
12
|
+
2. As a contributor, you should agree that your contributed code:
|
|
13
|
+
|
|
14
|
+
a. The producer can adjust the open-source agreement to be more strict or relaxed.
|
|
15
|
+
b. Can be used for commercial purposes, such as FastGPT's cloud business.
|
|
16
|
+
|
|
17
|
+
Apart from this, all other rights and restrictions follow the Apache License 2.0. If you need more detailed information, you can refer to the full version of Apache License 2.0.
|
|
18
|
+
|
|
19
|
+
The interactive design of this product is protected by appearance patent.
|
|
20
|
+
|
|
21
|
+
© 2023 Sealos.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
you may not use this file except in compliance with the License.
|
|
27
|
+
You may obtain a copy of the License at
|
|
28
|
+
|
|
29
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
|
|
31
|
+
Unless required by applicable law or agreed to in writing, software
|
|
32
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
+
See the License for the specific language governing permissions and
|
|
35
|
+
limitations under the License.
|
package/README.en.md
CHANGED
|
@@ -2,22 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
Language: [简体中文](./README.md) | [English](./README.en.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The TypeScript client wraps the FastGPT Plugin service API. `FastGPTPluginClient` passes through service responses; it does not select display languages for callers.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```ts
|
|
8
|
+
import { FastGPTPluginClient } from '@fastgpt-plugin/sdk-client';
|
|
9
|
+
|
|
10
|
+
const client = new FastGPTPluginClient({
|
|
11
|
+
baseUrl: 'https://plugin.example.com',
|
|
12
|
+
token: process.env.FASTGPT_PLUGIN_TOKEN
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Workflow Templates
|
|
17
|
+
|
|
18
|
+
`listWorkflows()` takes no locale parameter and does not translate templates; fields such as `name` and `intro` pass through as strings. Workflow node configuration remains open-ended.
|
|
8
19
|
|
|
9
20
|
```ts
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
limit: number;
|
|
14
|
-
total: number;
|
|
15
|
-
};
|
|
21
|
+
const templates = await client.listWorkflows();
|
|
22
|
+
const templateName = templates[0]?.name;
|
|
23
|
+
const firstInputLabel = templates[0]?.workflow.nodes[0]?.inputs?.[0]?.label;
|
|
16
24
|
```
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
## Localized Plugin README URLs
|
|
27
|
+
|
|
28
|
+
Plugin data preserves both the compatibility field `readmeUrl` and a `readmeUrls` map for README variants that actually exist. A UI should first select the current locale, then fall back to Simplified Chinese and English. If no mapped URL is available, use the legacy `readmeUrl` as a final fallback. The SDK does not parse README content or choose a locale.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
type Locale = 'en' | 'zh-CN' | 'zh-Hant';
|
|
32
|
+
|
|
33
|
+
const plugins = await client.listPlugins();
|
|
34
|
+
const plugin = plugins[0];
|
|
35
|
+
const locale: Locale = 'zh-Hant';
|
|
36
|
+
const readmeUrl = plugin
|
|
37
|
+
? plugin.readmeUrls?.[locale] ??
|
|
38
|
+
plugin.readmeUrls?.['zh-CN'] ??
|
|
39
|
+
plugin.readmeUrls?.en ??
|
|
40
|
+
plugin.readmeUrl
|
|
41
|
+
: undefined;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`readmeUrls` contains only the locales supplied in the package. If a root `README.md` exists, the server points `readmeUrl` to it; otherwise it selects the first available variant in `zh-CN`, `en`, then `zh-Hant` order. The locale-selection example above is for the display client; older clients can continue reading only `readmeUrl`.
|
|
45
|
+
|
|
46
|
+
`PluginListType` is an array of plugin list items. `PluginListItemType` and `PluginSourceType` are also exported for handling the plugin `source` field.
|
|
47
|
+
|
|
48
|
+
## Plugin Service Features
|
|
19
49
|
|
|
20
|
-
`getPluginServiceFeatures()` returns the enabled Plugin service
|
|
50
|
+
`getPluginServiceFeatures()` returns the capabilities enabled on the current Plugin service:
|
|
21
51
|
|
|
22
52
|
```ts
|
|
23
53
|
const features = await client.getPluginServiceFeatures();
|
package/README.md
CHANGED
|
@@ -1,23 +1,53 @@
|
|
|
1
|
-
# FastGPT-plugin SDK
|
|
1
|
+
# FastGPT-plugin SDK Client
|
|
2
2
|
|
|
3
3
|
语言:[简体中文](./README.md) | [English](./README.en.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
TypeScript 客户端封装 FastGPT Plugin 服务 API。`FastGPTPluginClient` 的方法会透传服务端响应;SDK 不替调用方选择展示语言。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```ts
|
|
8
|
+
import { FastGPTPluginClient } from '@fastgpt-plugin/sdk-client';
|
|
9
|
+
|
|
10
|
+
const client = new FastGPTPluginClient({
|
|
11
|
+
baseUrl: 'https://plugin.example.com',
|
|
12
|
+
token: process.env.FASTGPT_PLUGIN_TOKEN
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 工作流模板
|
|
17
|
+
|
|
18
|
+
`listWorkflows()` 不接收 locale 参数,也不会对工作流模板进行翻译;模板 `name`、`intro` 等字段按原字符串透传。工作流节点配置保持开放结构。
|
|
8
19
|
|
|
9
20
|
```ts
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
limit: number;
|
|
14
|
-
total: number;
|
|
15
|
-
};
|
|
21
|
+
const templates = await client.listWorkflows();
|
|
22
|
+
const templateName = templates[0]?.name;
|
|
23
|
+
const firstInputLabel = templates[0]?.workflow.nodes[0]?.inputs?.[0]?.label;
|
|
16
24
|
```
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
## 多语言插件 README URL
|
|
27
|
+
|
|
28
|
+
插件信息会同时保留兼容字段 `readmeUrl` 和实际存在的 README 语言映射 `readmeUrls`。UI 应先按当前语言查映射,然后回退到简体中文、英文;若新映射没有可用地址,最后可使用旧 `readmeUrl`。SDK 不解析 README 内容或做语言选择。
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
type Locale = 'en' | 'zh-CN' | 'zh-Hant';
|
|
32
|
+
|
|
33
|
+
const plugins = await client.listPlugins();
|
|
34
|
+
const plugin = plugins[0];
|
|
35
|
+
const locale: Locale = 'zh-Hant';
|
|
36
|
+
const readmeUrl = plugin
|
|
37
|
+
? plugin.readmeUrls?.[locale] ??
|
|
38
|
+
plugin.readmeUrls?.['zh-CN'] ??
|
|
39
|
+
plugin.readmeUrls?.en ??
|
|
40
|
+
plugin.readmeUrl
|
|
41
|
+
: undefined;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`readmeUrls` 只包含包内实际提供的语言版本。服务端在根目录存在 `README.md` 时让 `readmeUrl` 指向它;否则按 `zh-CN`、`en`、`zh-Hant` 顺序选择可用变体。上述 UI 回退逻辑适用于展示端的语言选择;旧客户端仍可只读取 `readmeUrl`。
|
|
45
|
+
|
|
46
|
+
`PluginListType` 是插件列表项数组;`PluginListItemType` 和 `PluginSourceType` 也从客户端 SDK 导出,供调用方处理插件来源字段。
|
|
47
|
+
|
|
48
|
+
## Plugin 服务能力
|
|
19
49
|
|
|
20
|
-
`getPluginServiceFeatures()`
|
|
50
|
+
`getPluginServiceFeatures()` 返回当前 Plugin 服务已启用的能力:
|
|
21
51
|
|
|
22
52
|
```ts
|
|
23
53
|
const features = await client.getPluginServiceFeatures();
|