@nocobase/plugin-ai 2.1.0-beta.37 → 2.1.0-beta.40
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/ai/docs/nocobase/api/cli/app/index.md +4 -4
- package/dist/ai/docs/nocobase/api/cli/app/restart.md +4 -2
- package/dist/ai/docs/nocobase/api/cli/app/start.md +6 -2
- package/dist/ai/docs/nocobase/api/cli/app/stop.md +2 -2
- package/dist/ai/docs/nocobase/api/cli/app/upgrade.md +27 -6
- package/dist/ai/docs/nocobase/api/cli/license/plugins/sync.md +4 -0
- package/dist/ai/docs/nocobase/file-manager/file-preview/index.md +17 -0
- package/dist/ai/docs/nocobase/get-started/installation/env.md +6 -2
- package/dist/ai/docs/nocobase/plugin-development/build.md +5 -0
- package/dist/ai/docs/nocobase/plugin-development/write-your-first-plugin.md +28 -0
- package/dist/client/559.a0f2f1cc2be3c039.js +10 -0
- package/dist/client/index.js +4 -4
- package/dist/externalVersion.js +20 -20
- package/dist/node_modules/@langchain/xai/dist/index.cjs +16 -2
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.d.ts +2 -1
- package/dist/server/ai-employees/ai-employee.js +3 -1
- package/dist/server/llm-providers/provider.js +6 -2
- package/dist/server/utils.d.ts +1 -1
- package/dist/server/workflow/nodes/employee/constants.d.ts +23 -0
- package/dist/server/workflow/nodes/employee/constants.js +50 -0
- package/dist/server/workflow/nodes/employee/handler.js +23 -2
- package/dist/server/workflow/nodes/employee/index.d.ts +1 -0
- package/dist/server/workflow/nodes/employee/index.js +83 -25
- package/dist/server/workflow/nodes/employee/tools.d.ts +2 -2
- package/dist/server/workflow/nodes/employee/tools.js +26 -5
- package/dist/server/workflow/nodes/employee/types.d.ts +2 -1
- package/dist/server/workflow/nodes/llm/index.js +31 -9
- package/package.json +7 -7
- package/dist/client/559.585f80c3bcea0bed.js +0 -10
|
@@ -6,7 +6,7 @@ keywords: "nb app,NocoBase CLI,app runtime,start,stop,logs,upgrade"
|
|
|
6
6
|
|
|
7
7
|
# nb app
|
|
8
8
|
|
|
9
|
-
Manage the runtime of a selected NocoBase env. npm/Git envs run local app commands; Docker envs manage saved
|
|
9
|
+
Manage the runtime of a selected NocoBase env. npm/Git envs run local app commands; Docker envs manage app containers from the saved env config.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -18,12 +18,12 @@ nb app <command>
|
|
|
18
18
|
|
|
19
19
|
| Command | Description |
|
|
20
20
|
| --- | --- |
|
|
21
|
-
| [`nb app start`](./start.md) | Start the app or Docker container |
|
|
22
|
-
| [`nb app stop`](./stop.md) | Stop the app or Docker container |
|
|
21
|
+
| [`nb app start`](./start.md) | Start the app or recreate the Docker container |
|
|
22
|
+
| [`nb app stop`](./stop.md) | Stop the app or remove the Docker container |
|
|
23
23
|
| [`nb app restart`](./restart.md) | Stop and then start the app |
|
|
24
24
|
| [`nb app logs`](./logs.md) | View app logs |
|
|
25
25
|
| [`nb app down`](./down.md) | Stop and clean up local runtime resources |
|
|
26
|
-
| [`nb app upgrade`](./upgrade.md) |
|
|
26
|
+
| [`nb app upgrade`](./upgrade.md) | Stop the app, replace the source or image, then start it again |
|
|
27
27
|
|
|
28
28
|
## Examples
|
|
29
29
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "nb app restart"
|
|
3
|
-
description: "nb app restart command reference: restart the NocoBase app
|
|
3
|
+
description: "nb app restart command reference: restart the NocoBase app for a selected env and recreate the Docker app container from saved env config when needed."
|
|
4
4
|
keywords: "nb app restart,NocoBase CLI,restart app,Docker"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# nb app restart
|
|
8
8
|
|
|
9
|
-
Stop and then start the NocoBase app for a selected env.
|
|
9
|
+
Stop and then start the NocoBase app for a selected env. Local envs reuse the `nb app stop` and `nb app start` flow; Docker envs remove the current container first, then recreate the app container from saved env config.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -43,6 +43,8 @@ nb app restart --env local-docker
|
|
|
43
43
|
|
|
44
44
|
If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
|
|
45
45
|
|
|
46
|
+
Whenever the CLI needs to wait for readiness, it checks `__health_check`: it prints one waiting line first, then one progress line every 10 seconds until the app becomes available or times out. If you pass `--no-daemon` for a local env, the app runs in the foreground, so the CLI does not keep waiting for the readiness check after startup.
|
|
47
|
+
|
|
46
48
|
## Related Commands
|
|
47
49
|
|
|
48
50
|
- [`nb app start`](./start.md)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "nb app start"
|
|
3
|
-
description: "nb app start command reference: start the NocoBase app
|
|
3
|
+
description: "nb app start command reference: start the NocoBase app for a selected env and recreate the Docker app container from saved env config when needed."
|
|
4
4
|
keywords: "nb app start,NocoBase CLI,start app,Docker,pm2"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# nb app start
|
|
8
8
|
|
|
9
|
-
Start the NocoBase app for a selected env. npm/Git installations run local app commands; Docker installations
|
|
9
|
+
Start the NocoBase app for a selected env. npm/Git installations run local app commands; Docker installations recreate the saved app container from the saved env config.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -44,6 +44,10 @@ nb app start --env local-docker
|
|
|
44
44
|
|
|
45
45
|
If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
|
|
46
46
|
|
|
47
|
+
By default, local envs start in daemon mode and Docker envs recreate the app container from saved env config. Whenever the CLI needs to wait for readiness, it checks `__health_check`: it prints one waiting line first, then one progress line every 10 seconds until the app becomes available or times out.
|
|
48
|
+
|
|
49
|
+
If you pass `--no-daemon` for a local env, the app runs in the foreground. In that case, the CLI does not keep waiting for the readiness check after startup.
|
|
50
|
+
|
|
47
51
|
## Related Commands
|
|
48
52
|
|
|
49
53
|
- [`nb app stop`](./stop.md)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "nb app stop"
|
|
3
|
-
description: "nb app stop command reference: stop the NocoBase app
|
|
3
|
+
description: "nb app stop command reference: stop the NocoBase app and remove the Docker app container for a selected env."
|
|
4
4
|
keywords: "nb app stop,NocoBase CLI,stop app,Docker"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# nb app stop
|
|
8
8
|
|
|
9
|
-
Stop the NocoBase app for a selected env. npm/Git installations stop local app processes; Docker installations
|
|
9
|
+
Stop the NocoBase app for a selected env. npm/Git installations stop local app processes; Docker installations remove the saved app container.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "nb app upgrade"
|
|
3
|
-
description: "nb app upgrade command reference:
|
|
3
|
+
description: "nb app upgrade command reference: stop the app, replace the saved source or image, then start the selected NocoBase app again."
|
|
4
4
|
keywords: "nb app upgrade,NocoBase CLI,upgrade,update,Docker image"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# nb app upgrade
|
|
8
8
|
|
|
9
|
-
Upgrade a selected NocoBase app.
|
|
9
|
+
Upgrade a selected NocoBase app. The CLI stops the current app, replaces the saved source or image by default, synchronizes commercial plugins, quickstarts the app again, and refreshes the env runtime at the end. Docker envs recreate the app container from the saved env config during startup.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -20,23 +20,44 @@ nb app upgrade [flags]
|
|
|
20
20
|
| --- | --- | --- |
|
|
21
21
|
| `--env`, `-e` | string | CLI env name to upgrade; uses the current env if omitted |
|
|
22
22
|
| `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
|
|
23
|
-
| `--
|
|
24
|
-
| `--
|
|
23
|
+
| `--force`, `-f` | boolean | Skip the upgrade confirmation prompt. Required in non-interactive terminals and AI agent sessions |
|
|
24
|
+
| `--skip-download`, `-s` | boolean | Restart from the currently saved local source or Docker image without downloading updates first; also skips `nb license plugins sync` |
|
|
25
|
+
| `--version` | string | Override the target version for this upgrade; when the upgrade succeeds, the new version is written back to `downloadVersion` in the env config |
|
|
25
26
|
| `--verbose` | boolean | Show underlying update and restart command output |
|
|
26
27
|
|
|
27
28
|
## Examples
|
|
28
29
|
|
|
29
30
|
```bash
|
|
30
31
|
nb app upgrade
|
|
32
|
+
nb app upgrade --force
|
|
31
33
|
nb app upgrade --env local
|
|
32
|
-
nb app upgrade --env local
|
|
34
|
+
nb app upgrade --env local --force
|
|
35
|
+
nb app upgrade --env local --skip-download
|
|
36
|
+
nb app upgrade --env local --skip-download --version beta
|
|
33
37
|
nb app upgrade --env local --version beta
|
|
34
38
|
nb app upgrade --env local --verbose
|
|
35
|
-
nb app upgrade --env local-docker -
|
|
39
|
+
nb app upgrade --env local-docker --skip-download
|
|
36
40
|
```
|
|
37
41
|
|
|
38
42
|
If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
|
|
39
43
|
|
|
44
|
+
Before the upgrade starts, interactive terminals also ask for upgrade confirmation unless you pass `--force`. In non-interactive terminals and AI agent sessions, `nb app upgrade` refuses to proceed without `--force` and prints a copyable re-run command. If the command is also cross-env, you need both `--yes` and `--force`.
|
|
45
|
+
|
|
46
|
+
By default, `nb app upgrade` runs these steps:
|
|
47
|
+
|
|
48
|
+
1. `nb app stop`
|
|
49
|
+
2. `nb source download --replace`
|
|
50
|
+
3. `nb license plugins sync --skip-if-no-license`
|
|
51
|
+
4. `nb app start --quickstart`
|
|
52
|
+
5. Save the new `downloadVersion` when needed
|
|
53
|
+
6. `nb env update`
|
|
54
|
+
|
|
55
|
+
When `--skip-download` is passed, the CLI skips steps 2 and 3 and restarts the currently saved source or image directly. If `--version` is also passed, the CLI does not download that version during this run; instead it only saves it as the new `downloadVersion` after a successful restart so later upgrades can use it.
|
|
56
|
+
|
|
57
|
+
Step 4 waits for the app to pass `__health_check`. During this wait, the CLI prints one waiting line first, then one progress line every 10 seconds until the app is ready or the health check times out.
|
|
58
|
+
|
|
59
|
+
If the final `nb env update` step fails, the upgrade still counts as successful. The CLI prints a warning and tells you to run `nb env update <envName>` manually afterward.
|
|
60
|
+
|
|
40
61
|
## Related Commands
|
|
41
62
|
|
|
42
63
|
- [`nb source download`](../source/download.md)
|
|
@@ -22,6 +22,7 @@ nb license plugins sync [flags]
|
|
|
22
22
|
| `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
|
|
23
23
|
| `--dry-run` | boolean | Preview changes without installing, upgrading, or removing plugins |
|
|
24
24
|
| `--version` | string | Registry version or dist-tag to synchronize; defaults to the current workspace version |
|
|
25
|
+
| `--skip-if-no-license` | boolean | Skip without error when the current env does not have a saved license key |
|
|
25
26
|
| `--verbose` | boolean | Show detailed per-plugin sync logs |
|
|
26
27
|
| `--json` | boolean | Output JSON |
|
|
27
28
|
|
|
@@ -32,6 +33,7 @@ nb license plugins sync
|
|
|
32
33
|
nb license plugins sync --env app1
|
|
33
34
|
nb license plugins sync --env app1 --yes
|
|
34
35
|
nb license plugins sync --env app1 --dry-run
|
|
36
|
+
nb license plugins sync --env app1 --skip-if-no-license
|
|
35
37
|
nb license plugins sync --env app1 --json
|
|
36
38
|
```
|
|
37
39
|
|
|
@@ -39,6 +41,8 @@ nb license plugins sync --env app1 --json
|
|
|
39
41
|
|
|
40
42
|
When `--version` is omitted, the CLI detects the current app version automatically and uses that to decide which registry version of commercial plugins should be downloaded.
|
|
41
43
|
|
|
44
|
+
`--skip-if-no-license` only ignores one case: the current env does not have a saved license key yet. Other errors, such as missing registry credentials in the key, registry login failures, or plugin download failures, still surface normally.
|
|
45
|
+
|
|
42
46
|
If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
|
|
43
47
|
|
|
44
48
|
## Related Commands
|
|
@@ -9,3 +9,20 @@ For file types that do not support native preview, you can enable preview functi
|
|
|
9
9
|
Currently, NocoBase provides the following file preview plugins:
|
|
10
10
|
|
|
11
11
|
* [Office File Preview Plugin](../file-preview/ms-office.md)
|
|
12
|
+
|
|
13
|
+
## PDF preview with external storage
|
|
14
|
+
|
|
15
|
+
PDF preview uses PDF.js to render files in the browser. The browser must first read the PDF file content and then pass it to PDF.js for rendering. Therefore, when files are stored in external storage such as OSS, S3, COS, or a CDN, and the file access domain is different from the NocoBase site domain, the external storage must allow the NocoBase site to read files across origins.
|
|
16
|
+
|
|
17
|
+
If CORS is not configured, PDF downloads can still work normally, but preview may fail with a file loading error.
|
|
18
|
+
|
|
19
|
+
The CORS configuration for external storage or CDN should include:
|
|
20
|
+
|
|
21
|
+
```http
|
|
22
|
+
Access-Control-Allow-Origin: https://your-nocobase-domain
|
|
23
|
+
Access-Control-Allow-Methods: GET, HEAD
|
|
24
|
+
Access-Control-Allow-Headers: *
|
|
25
|
+
Access-Control-Expose-Headers: Content-Length, Content-Range, Accept-Ranges, Content-Disposition, Content-Type
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`Access-Control-Allow-Origin` should be set to the actual domain used to access NocoBase. Avoid using `*` for non-public files over the long term, because it expands the range of sites that can read the files.
|
|
@@ -294,7 +294,7 @@ Log print format. Default is `console` in development and `json` in production.
|
|
|
294
294
|
LOGGER_FORMAT=json
|
|
295
295
|
```
|
|
296
296
|
|
|
297
|
-
Reference: [Log Format](/log-and-monitor/logger/index.md#log-
|
|
297
|
+
Reference: [Log Format](/log-and-monitor/logger/index.md#log-formats)
|
|
298
298
|
|
|
299
299
|
### CACHE_DEFAULT_STORE
|
|
300
300
|
|
|
@@ -375,8 +375,10 @@ Supported formats:
|
|
|
375
375
|
Used to append preset local plugins. The value is the package name (the `name` parameter in `package.json`), with multiple plugins separated by commas.
|
|
376
376
|
|
|
377
377
|
:::info
|
|
378
|
+
|
|
378
379
|
1. Ensure the plugin is downloaded locally and can be found in the `node_modules` directory. For more details, see [Plugin Organization](/plugin-development/project-structure).
|
|
379
380
|
2. After adding the environment variable, the plugin will appear on the plugin manager page only after an initial installation (`nocobase install`) or upgrade (`nocobase upgrade`).
|
|
381
|
+
|
|
380
382
|
:::
|
|
381
383
|
|
|
382
384
|
```bash
|
|
@@ -388,8 +390,10 @@ APPEND_PRESET_LOCAL_PLUGINS=@my-project/plugin-foo,@my-project/plugin-bar
|
|
|
388
390
|
Used to append built-in plugins that are installed by default. The value is the package name (the `name` parameter in `package.json`), with multiple plugins separated by commas.
|
|
389
391
|
|
|
390
392
|
:::info
|
|
393
|
+
|
|
391
394
|
1. Ensure the plugin is downloaded locally and can be found in the `node_modules` directory. For more details, see [Plugin Organization](/plugin-development/project-structure).
|
|
392
395
|
2. After adding the environment variable, the plugin will be automatically installed or upgraded during the initial installation (`nocobase install`) or upgrade (`nocobase upgrade`).
|
|
396
|
+
|
|
393
397
|
:::
|
|
394
398
|
|
|
395
399
|
```bash
|
|
@@ -472,7 +476,7 @@ yarn cross-env \
|
|
|
472
476
|
|
|
473
477
|
### WORKFLOW_SCRIPT_MODULES
|
|
474
478
|
|
|
475
|
-
Workflow JavaScript node available modules list. For details, see "[JavaScript Node: Using External Modules](/workflow/nodes/javascript#
|
|
479
|
+
Workflow JavaScript node available modules list. For details, see "[JavaScript Node: Using External Modules](/workflow/nodes/javascript#unsafe-mode-module-support)".
|
|
476
480
|
|
|
477
481
|
### WORKFLOW_LOOP_LIMIT
|
|
478
482
|
|
|
@@ -44,6 +44,10 @@ yarn build @my-project/plugin-hello --tar
|
|
|
44
44
|
|
|
45
45
|
Upload and extract the `.tar.gz` file to the target application's `./storage/plugins` directory. For detailed steps, see [Install and Upgrade Plugins](../get-started/install-upgrade-plugins.mdx).
|
|
46
46
|
|
|
47
|
+
### Enable a Plugin by Default
|
|
48
|
+
|
|
49
|
+
After uploading, the plugin is not activated automatically — it appears in the Plugin Manager and must be enabled manually. If you are maintaining your own NocoBase application and want the plugin to be enabled by default along with the application, you can use the `APPEND_PRESET_BUILT_IN_PLUGINS` (append built-in plugins) environment variable. See [Make a Plugin Preset or Built-in by Default](./write-your-first-plugin.md#make-a-plugin-preset-or-built-in-by-default-optional) for usage.
|
|
50
|
+
|
|
47
51
|
## Custom Build Configuration
|
|
48
52
|
|
|
49
53
|
In most cases, the default build configuration is sufficient. If you need to customize it — such as modifying the bundle entry, adding aliases, adjusting compression options, etc. — you can create a `build.config.ts` file in the plugin root directory:
|
|
@@ -84,3 +88,4 @@ Key points:
|
|
|
84
88
|
- [Dependency Management](./dependency-management.md) — Plugin dependency declarations and global dependencies
|
|
85
89
|
- [Plugin Development Overview](./index.md) — Overall introduction to plugin development
|
|
86
90
|
- [Install and Upgrade Plugins](../get-started/install-upgrade-plugins.mdx) — Upload packaged files to target environments
|
|
91
|
+
- [Environment Variables](../get-started/installation/env.md) — Environment variable configuration for preset and built-in plugins
|
|
@@ -118,6 +118,33 @@ After activation, create a new "Modern page (v2)" page. When adding blocks, you'
|
|
|
118
118
|
|
|
119
119
|

|
|
120
120
|
|
|
121
|
+
### Make a Plugin Preset or Built-in by Default (Optional)
|
|
122
|
+
|
|
123
|
+
The steps above describe manually enabling a single plugin. If you are maintaining your own NocoBase application and want certain plugins to be automatically ready after running `nocobase install` (first-time installation) or `nocobase upgrade` (upgrade), you can use two environment variables to control a plugin's default state:
|
|
124
|
+
|
|
125
|
+
- **`APPEND_PRESET_LOCAL_PLUGINS` (append preset local plugins)** — Adds the plugin to the preset local plugin list. After installation it appears in the Plugin Manager but is not activated by default; you need to enable it manually.
|
|
126
|
+
- **`APPEND_PRESET_BUILT_IN_PLUGINS` (append built-in plugins)** — Adds the plugin to the built-in plugin list. It is automatically activated on installation and, as a built-in plugin, **cannot be disabled or deleted from the Plugin Manager**.
|
|
127
|
+
|
|
128
|
+
The value for both variables is the plugin package name (the `name` field in `package.json`); separate multiple plugins with commas. Configure them in `.env` like this:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Preset: appears in the Plugin Manager list but is not activated automatically
|
|
132
|
+
APPEND_PRESET_LOCAL_PLUGINS=@my-project/plugin-hello,@my-project/plugin-hello-world
|
|
133
|
+
|
|
134
|
+
# Built-in: automatically installed and activated, and cannot be disabled from the UI
|
|
135
|
+
APPEND_PRESET_BUILT_IN_PLUGINS=@my-project/plugin-hello,@my-project/plugin-hello-world
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
For day-to-day local development and debugging, `yarn pm enable` (described above) is usually sufficient. These two variables are better suited for "out-of-the-box" distribution scenarios — for example, when you are shipping a NocoBase application bundled with a fixed set of plugins and want those plugins to be ready immediately after initialization.
|
|
139
|
+
|
|
140
|
+
:::tip Note
|
|
141
|
+
|
|
142
|
+
- The plugin must already be downloaded locally and resolvable in `node_modules`. See [Project Structure](./project-structure.md) for details.
|
|
143
|
+
- After configuring, you need to re-run `nocobase install` or `nocobase upgrade` for the changes to take effect.
|
|
144
|
+
- For the full list of environment variable options, see [Environment Variables](../get-started/installation/env.md#append_preset_local_plugins).
|
|
145
|
+
|
|
146
|
+
:::
|
|
147
|
+
|
|
121
148
|
## Step 4: Build and Package
|
|
122
149
|
|
|
123
150
|
When you're ready to distribute the plugin to other environments, you need to build and package it first:
|
|
@@ -158,4 +185,5 @@ Upload and extract the package file to the target application's `./storage/plugi
|
|
|
158
185
|
- [Install using create-nocobase-app](../get-started/installation/create-nocobase-app) — One of the NocoBase installation methods
|
|
159
186
|
- [Install from Git source](../get-started/installation/git) — Install NocoBase from source code
|
|
160
187
|
- [Install and Upgrade Plugins](../get-started/install-upgrade-plugins.mdx) — Upload packaged plugins to other environments
|
|
188
|
+
- [Environment Variables](../get-started/installation/env.md) — Environment variable configuration for preset and built-in plugins
|
|
161
189
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["559"],{6482:function(e,t,n){n.r(t),n.d(t,{Settings:function(){return _},useProviderSettingsForm:function(){return U},LLMServices:function(){return z},ProviderSelect:function(){return q}});var r=n(3342),o=n(9155),i=n.n(o),l=n(4442),a=n(3079),c=n(2059),s=n(7375),u={name:"llmServices",fields:[{name:"name",type:"uid",primaryKey:!0},{name:"title",type:"string",interface:"input",uiSchema:{title:'{{t("Title")}}',"x-component":"Input"}},{name:"provider",type:"string",interface:"select",uiSchema:{title:'{{t("Provider")}}',"x-component":"Select"}},{name:"options",type:"jsonb"},{name:"enabledModels",type:"json",defaultValue:{mode:"recommended",models:[]}},{name:"enabled",type:"boolean",defaultValue:!0},{name:"modelOptions",type:"jsonb",defaultValue:{temperature:1,topP:1,frequencyPenalty:0,presencePenalty:0}}]},p={type:"void",properties:{drawer:{type:"void",title:'{{ t("Add new") }}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:{provider:{type:"string","x-decorator":"FormItem",title:'{{ t("Provider") }}',"x-component":"ProviderSelect",required:!0},title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input","x-reactions":{dependencies:["provider"],when:"{{!$self.modified}}",fulfill:{state:{value:"{{$getProviderLabel($deps[0])}}"},schema:{"x-visible":"{{!!$deps[0]}}"}}}},options:{type:"object","x-component":"Settings","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},"options.baseURL":{type:"string","x-decorator":"FormItem",title:'{{ t("Base URL") }}',"x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:'{{ t("Base URL is optional, leave blank to use default (recommended)") }}'},"x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},enabledModels:{type:"object","x-decorator":"FormItem",title:'{{ t("Enabled Models") }}',"x-component":"EnabledModelsSelect","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{testFlight:{type:"void","x-component":"LLMTestFlight","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}}}},d={type:"void",name:"llm-services",properties:{card:{type:"void","x-component":"CardItem","x-component-props":{heightMode:"fullHeight"},"x-decorator":"TableBlockProvider","x-decorator-props":{collection:"llmServices",action:"list",rowKey:"name",dragSort:!0,dragSortBy:"sort"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:20}},properties:{refresh:{title:"{{t('Refresh')}}","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},bulkDelete:{title:"{{t('Delete')}}","x-action":"destroy","x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},add:{type:"void","x-component":"AddNew",title:"{{t('Add new')}}","x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void",title:'{{ t("UID") }}',"x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"Input","x-read-pretty":!0}}},column2:{type:"void",title:'{{ t("Title") }}',"x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"Input","x-read-pretty":!0}}},column3:{type:"void",title:'{{ t("Provider") }}',"x-component":"TableV2.Column",properties:{provider:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ providers }}"}}},column4:{type:"void",title:'{{ t("Enabled") }}',"x-component":"TableV2.Column",properties:{enabled:{type:"boolean","x-component":"EnabledSwitch"}}},column5:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:{provider:{type:"string","x-decorator":"FormItem",title:'{{ t("Provider") }}',"x-component":"ProviderDisplay"},title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input"},options:{type:"object","x-component":"Settings"},"options.baseURL":{type:"string","x-decorator":"FormItem",title:'{{ t("Base URL") }}',"x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:'{{ t("Base URL is optional, leave blank to use default (recommended)") }}'}},enabledModels:{type:"object","x-decorator":"FormItem",title:'{{ t("Enabled Models") }}',"x-component":"EnabledModelsSelect"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{testFlight:{type:"void","x-component":"LLMTestFlight"},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useEditActionProps"}}}}}}},destroy:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}}}},m=n(284),f=n(5230),y=n(9452),v=n(166),b=n(6759),x=n(5555),h={type:"object",properties:{temperature:{type:"number",title:'{{t("Temperature")}}',description:'{{t("Temperature description")}}',"x-decorator":"FormItem","x-component":"Slider","x-component-props":{min:0,max:2,step:.1},default:1},maxTokens:{type:"number",title:'{{t("Max tokens")}}',description:'{{t("Max completion tokens description")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:128e3,placeholder:'{{t("Leave empty for no limit")}}'}},topP:{type:"number",title:'{{t("Top P")}}',description:'{{t("Top P description")}}',"x-decorator":"FormItem","x-component":"Slider","x-component-props":{min:0,max:1,step:.1},default:1},frequencyPenalty:{type:"number",title:'{{t("Frequency penalty")}}',description:'{{t("Frequency penalty description")}}',"x-decorator":"FormItem","x-component":"Slider","x-component-props":{min:-2,max:2,step:.1},default:0},presencePenalty:{type:"number",title:'{{t("Presence penalty")}}',description:'{{t("Presence penalty description")}}',"x-decorator":"FormItem","x-component":"Slider","x-component-props":{min:-2,max:2,step:.1},default:0}}},g=function(){var e=(0,a.kj)();return i().createElement(c.Collapse,{bordered:!1,size:"small",style:{marginTop:16},items:[{key:"modelOptions",label:e("Model options"),forceRender:!0,children:i().createElement(r.SchemaComponent,{schema:h,scope:{t:e}})}]})},P=n(7330);function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function A(e,t,n,r,o,i,l){try{var a=e[i](l),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){A(i,r,o,l,a,"next",e)}function a(e){A(i,r,o,l,a,"throw",e)}l(void 0)})}}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function C(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(a)throw r}}return i}}(e,t)||O(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(e,t)}}function M(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:c(0)}),a(l,"throw",{value:c(1)}),a(l,"return",{value:c(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function c(a){return function(c){var s=[a,c];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var L=(0,o.createContext)({autoOpen:!1,setAutoOpen:function(){}}),I=function(){return{form:(0,o.useMemo)(function(){return(0,y.createForm)({initialValues:{name:"v_".concat((0,v.uid)())}})},[])}},F=function(){var e=(0,r.useCollectionRecordData)();return{form:(0,o.useMemo)(function(){return(0,y.createForm)({initialValues:e})},[e])}},T=function(){var e=(0,r.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},j=function(){var e=(0,r.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,f.useForm)(),o=(0,r.useDataBlockResource)(),i=(0,r.useDataBlockRequest)().refresh,l=(0,a.kj)(),s=(0,P.M)();return{type:"primary",onClick:function(){return w(function(){var r;return M(this,function(a){switch(a.label){case 0:return[4,n.submit()];case 1:return a.sent(),r=n.values,[4,o.create({values:r})];case 2:return a.sent(),i(),s.refreshLLMServices(),t.success(l("Saved successfully")),e(!1),[2]}})})()}}},D=function(){var e=(0,r.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,f.useForm)(),o=(0,r.useDataBlockResource)(),i=(0,r.useDataBlockRequest)().refresh,l=(0,r.useCollection)().getFilterTargetKey(),s=(0,a.kj)(),u=(0,P.M)();return{type:"primary",onClick:function(){return w(function(){var r;return M(this,function(a){switch(a.label){case 0:return[4,n.submit()];case 1:return a.sent(),r=n.values,[4,o.update({values:r,filterByTk:r[l]})];case 2:return a.sent(),i(),u.refreshLLMServices(),t.success(s("Saved successfully")),e(!1),n.reset(),[2]}})})()}}},B={"google-genai":"Gemini",openai:"GPT","openai-completions":"Recommended for third-party OpenAI-compatible APIs (OpenRouter, Groq, Together AI, etc.)",anthropic:"Claude",deepseek:"DeepSeek",dashscope:"Qwen (Tongyi)",kimi:"Kimi",xai:"Grok models by xAI",ollama:"Local models",mimo:"Xiaomi MIMO"},R=["google-genai","openai","anthropic","deepseek","dashscope","kimi","openai-completions","ollama"],V=function(){var e=(0,f.useField)(),t=(0,m.Pq)().find(function(t){return t.value===e.value});return i().createElement("span",null,(null==t?void 0:t.label)||e.value)},q=function(){var e=c.theme.useToken().token,t=(0,f.useField)(),n=(0,m.Pq)(),r=(0,a.kj)(),o=((function(e){if(Array.isArray(e))return S(e)})(n)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||O(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).sort(function(e,t){var n=R.indexOf(e.value),r=R.indexOf(t.value);return(n<0?1/0:n)-(r<0?1/0:r)}).map(function(t){var n=B[t.value],o=n?r(n):"",l=t.supportedModel||[],a=[l.includes("LLM")?"LLM":null,l.includes("EMBEDDING")?"EMBEDDING":null].filter(Boolean);return{value:t.value,label:i().createElement("div",null,i().createElement("div",{style:{fontWeight:500}},t.label),i().createElement("div",{style:{fontSize:e.fontSizeSM,color:e.colorTextTertiary,lineHeight:1.4,display:"flex",alignItems:"center",justifyContent:"space-between",gap:e.marginXS}},i().createElement("span",null,o),i().createElement("span",{style:{display:"inline-flex",alignItems:"center",gap:e.marginXXS,flexWrap:"wrap"}},a.map(function(e){return i().createElement(c.Tag,{key:e,bordered:!1,color:"default",style:{marginInlineEnd:0,paddingInline:6,lineHeight:"18px",height:18,fontSize:11}},e)})))),selectedLabel:t.label}});return i().createElement(c.Select,{value:t.value,onChange:function(e){return t.value=e},options:o,optionLabelProp:"selectedLabel",style:{width:"100%"},listHeight:400})},N=(0,f.observer)(function(){var e=(0,f.useField)(),t=(0,r.useCollectionRecordData)(),n=(0,r.useDataBlockResource)(),o=(0,r.useDataBlockRequest)().refresh,l=(0,r.useCollection)().getFilterTargetKey(),a=!1!==e.value,s=(0,P.M)();return i().createElement(c.Switch,{size:"small",checked:a,onChange:function(r){return w(function(){return M(this,function(i){switch(i.label){case 0:return e.value=r,[4,n.update({values:{enabled:r},filterByTk:t[l]})];case 1:return i.sent(),o(),s.refreshLLMServices(),[2]}})})()}})},{displayName:"EnabledSwitch"}),$=function(){var e=(0,r.useDestroyActionProps)(),t=(0,P.M)();return C(k({},e),{onClick:function(n,r){return w(function(){return M(this,function(o){switch(o.label){case 0:return[4,e.onClick(n,r)];case 1:return o.sent(),t.refreshLLMServices(),[2]}})})()}})},G=function(){var e=(0,r.useBulkDestroyActionProps)(),t=(0,P.M)();return C(k({},e),{onClick:function(n,r){return w(function(){return M(this,function(o){switch(o.label){case 0:return[4,e.onClick(n,r)];case 1:return o.sent(),t.refreshLLMServices(),[2]}})})()}})},K=function(){var e=(0,a.kj)(),t=E((0,o.useState)(!1),2),n=t[0],l=t[1],u=E((0,o.useState)(0),2),d=u[0],f=u[1],y=(0,m.Pq)(),v=(0,o.useContext)(L),h=v.autoOpen,P=v.setAutoOpen;return(0,o.useEffect)(function(){h&&(f(function(e){return e+1}),l(!0),P(!1),window.history.replaceState({},document.title))},[h,P]),i().createElement(r.ActionContextProvider,{value:{visible:n,setVisible:l}},i().createElement(c.Button,{icon:i().createElement(s.PlusOutlined,null),type:"primary",onClick:function(){f(function(e){return e+1}),l(!0)}},e("Add new")),i().createElement(r.SchemaComponent,{key:d,components:{LLMTestFlight:b.e,EnabledModelsSelect:x.uQ,ProviderSelect:q,ModelOptionsSettings:g},scope:{useCreateFormProps:I,providers:y,$getProviderLabel:function(e){var t=y.find(function(t){return t.value===e});return(null==t?void 0:t.label)||e}},schema:p}))},U=function(e){var t,n=(0,r.usePlugin)("ai").aiManager.llmProviders.get(e);return null==n||null==(t=n.components)?void 0:t.ProviderSettingsForm},_=(0,f.observer)(function(){var e=(0,f.useForm)(),t=(0,r.useCollectionRecordData)(),n=U(e.values.provider||t.provider);return n?i().createElement(n,null):null},{displayName:"LLMProviderSettings"}),z=function(){var e=(0,a.kj)(),t=E((0,o.useState)([]),2),n=t[0],c=t[1],s=(0,r.useAPIClient)(),p=(0,l.useLocation)(),y=E((0,o.useState)(!1),2),v=y[0],h=y[1];return(0,o.useEffect)(function(){var e=p.state;(null==e?void 0:e.autoOpenAddNew)&&h(!0)},[p.state]),(0,r.useRequest)(function(){return s.resource("ai").listLLMProviders().then(function(t){var n;return((null==t||null==(n=t.data)?void 0:n.data)||[]).map(function(t){return{key:t.name,label:f.Schema.compile(t.title||t.name,{t:e}),value:t.name,supportedModel:t.supportedModel}})})},{onSuccess:function(e){c(e)}}),i().createElement(L.Provider,{value:{autoOpen:v,setAutoOpen:h}},i().createElement(m.PL.Provider,{value:{providers:n}},i().createElement(r.ExtendCollectionsProvider,{collections:[u]},i().createElement(r.SchemaComponent,{schema:d,components:{AddNew:K,Settings:_,LLMTestFlight:b.e,EnabledModelsSelect:x.uQ,ProviderDisplay:V,ModelOptionsSettings:g,EnabledSwitch:N},scope:{t:e,providers:n,useEditFormProps:F,useCancelActionProps:T,useCreateActionProps:j,useEditActionProps:D,useDestroyActionProps:$,useBulkDestroyActionProps:G}}))))}},6759:function(e,t,n){n.d(t,{e:function(){return f}});var r=n(5230),o=n(3342),i=n(9155),l=n.n(i),a=n(2059),c=n(7375),s=n(1931),u=n(5555),p=n(3079);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,o,i,l){try{var a=e[i](l),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}var f=(0,r.observer)(function(){var e,t=(0,p.kj)(),n=(0,r.useForm)(),f=(0,o.useAPIClient)(),y=a.App.useApp().message,v=function(e){if(Array.isArray(e))return e}(e=(0,i.useState)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),b=v[0],x=v[1];return l().createElement(a.Tooltip,{title:t("Test connection with the configured API Key")},l().createElement(a.Button,{icon:l().createElement(c.RocketOutlined,null),loading:b,onClick:function(){var e;return(e=function(){var e,r,o,i,l,a,c,p,d;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:c(0)}),a(l,"throw",{value:c(1)}),a(l,"return",{value:c(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function c(a){return function(c){var s=[a,c];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(m){switch(m.label){case 0:if(r=(e=n.values).provider,o=e.options,i=e.enabledModels,"ollama"!==r&&!(null==o?void 0:o.apiKey))return y.warning(t("Please fill in the API Key first")),[2];if("recommended"===(l=(0,u.lf)(i)).mode){if(0===(c=(0,s.sN)(r)).length)return y.warning(t("Please configure enabled models first")),[2];a=c[0].value}else{if(0===l.models.length)return y.warning(t("Please configure enabled models first")),[2];a=l.models[0].value}x(!0),m.label=1;case 1:return m.trys.push([1,3,4,5]),[4,f.resource("ai").testFlight({values:{provider:r,options:o,model:a}})];case 2:return 0!==(p=m.sent()).data.data.code?y.error(p.data.data.message||t("Failure")):y.success(t("Successful")),[3,5];case 3:return d=m.sent(),y.error(d.message||t("Failure")),[3,5];case 4:return x(!1),[7];case 5:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){m(i,r,o,l,a,"next",e)}function a(e){m(i,r,o,l,a,"throw",e)}l(void 0)})})()}},t("Test flight")))})},284:function(e,t,n){n.d(t,{PL:function(){return o},Pq:function(){return i}});var r=n(9155);(0,r.createContext)({provider:""}).displayName="LLMProvidersContext";var o=(0,r.createContext)({providers:[]});o.displayName="LLMProviderssContext";var i=function(){return(0,r.useContext)(o).providers}}}]);
|