dsh-llm-ustc 0.2.0 → 0.2.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/README.md +9 -6
- package/lib/adapter.js +23 -16
- package/lib/adapter.js.map +1 -1
- package/lib/client.js +107 -120
- package/lib/config.js +6 -4
- package/lib/config.js.map +1 -1
- package/lib/constants.js +2 -2
- package/lib/constants.js.map +1 -1
- package/lib/index.js +9 -14
- package/lib/index.js.map +1 -1
- package/lib/state.js +3 -7
- package/lib/state.js.map +1 -1
- package/lib/types/adapter.d.ts +1 -0
- package/lib/types/adapter.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +2 -5
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/config.d.ts +13 -3
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/constants.d.ts +2 -2
- package/lib/types/constants.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/state.d.ts +0 -1
- package/lib/types/state.d.ts.map +1 -1
- package/lib/types/web.d.ts +4 -1
- package/lib/types/web.d.ts.map +1 -1
- package/lib/web.js +45 -50
- package/lib/web.js.map +1 -1
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +63 -43
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ DeepSeek Harness `ustc` LLM Provider,访问中国科学技术大学
|
|
|
6
6
|
|
|
7
7
|
## 要求
|
|
8
8
|
|
|
9
|
-
- DeepSeek Harness `0.
|
|
9
|
+
- DeepSeek Harness `0.2.0-rc.2`
|
|
10
10
|
- Node.js 24(也支持 Node.js `^22.19.0`)
|
|
11
11
|
- Windows、macOS 或 Linux,x64/ARM64
|
|
12
12
|
- 科大 LLM API Key
|
|
@@ -23,20 +23,20 @@ dsh plugin --profile web add dsh-llm-ustc@latest
|
|
|
23
23
|
如需固定版本,可以将 `latest` 换成具体版本号:
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
dsh plugin --profile web add dsh-llm-ustc@0.2.
|
|
26
|
+
dsh plugin --profile web add dsh-llm-ustc@0.2.1
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
安装时 npm 会通过六个 `optionalDependencies` 之一自动选择当前操作系统和架构的
|
|
30
30
|
原生 helper;不支持的平台或缺失的原生包会返回明确错误。安装完成后重启正在运行的
|
|
31
31
|
DSH Web 进程。
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
在 DSH Web 主页左上角打开“插件”,从“已安装”进入“科大大模型”的详情页:
|
|
34
34
|
|
|
35
|
-
1. 保存 API Key(凭据引用固定为 `USTC_LLM_API_KEY
|
|
35
|
+
1. 保存 API Key(凭据引用固定为 `USTC_LLM_API_KEY`),并同步模型目录。模型页也会使用同一凭据引用。
|
|
36
36
|
2. 公网使用时启动 USTC 登录,在浏览器完成认证后粘贴完整回调 URL,再显式选择一条线路。
|
|
37
37
|
|
|
38
38
|
模型 ID 直接来自 `/v1/models`。首次离线时仅显示
|
|
39
|
-
`deepseek-
|
|
39
|
+
`deepseek-flash` 引导项;同步成功后会缓存最近可用目录。
|
|
40
40
|
|
|
41
41
|
## 网络边界
|
|
42
42
|
|
|
@@ -59,7 +59,10 @@ DSH Web 进程。
|
|
|
59
59
|
|
|
60
60
|
- `USTC_LLM_API_KEY`:科大 LLM API Key。
|
|
61
61
|
- `USTC_LLM_IWAN_CONFIG`:插件私有 iWAN 凭据,不写入 Provider 配置。
|
|
62
|
-
- `$DSH_HOME/
|
|
62
|
+
- `$DSH_HOME/profiles/web/cordis.patch.yml`:所选 iWAN 线路和直连恢复间隔,归属 `llm-ustc` 插件配置行;其他 profile 使用自己的同名文件。
|
|
63
|
+
- `$DSH_HOME/cache/dsh-llm-ustc/models.json`:可重新同步的模型目录缓存。升级后旧缓存不会迁移,可在插件详情页手动同步。
|
|
64
|
+
|
|
65
|
+
升级到 DSH 0.2 后,DSH 会在首次启动时把旧 `$DSH_HOME/settings.yaml` 中的插件设置导入当前 profile,并将旧文件改名为 `settings.yaml.imported`。请确保导入时已启用本插件。
|
|
63
66
|
|
|
64
67
|
## 验证
|
|
65
68
|
|
package/lib/adapter.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { credentialRef } from '@deepseek-ai/dsh-credentials';
|
|
2
2
|
import { assertUsableApiKey, LlmAdapter, LlmError, ReasoningEffortId, resolveRetryPolicy, } from '@deepseek-ai/dsh-llm';
|
|
3
3
|
import { PiAiAdapter } from '@deepseek-ai/dsh-llm-pi-ai';
|
|
4
|
-
import { createProvider } from '@earendil-works/pi-ai';
|
|
4
|
+
import { createProvider, defaultProviderAuthContext, InMemoryCredentialStore } from '@earendil-works/pi-ai';
|
|
5
5
|
import { openAICompletionsApi } from '@earendil-works/pi-ai/api/openai-completions.lazy';
|
|
6
6
|
import { API_KEY_REF, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_TOKENS, PROVIDER, PROVIDER_NAME, } from "./constants.js";
|
|
7
7
|
const RETRY_POLICY = resolveRetryPolicy(undefined, 'llm-ustc.retryPolicy');
|
|
8
8
|
const USTC_REASONING_EFFORTS = [
|
|
9
9
|
{ id: ReasoningEffortId('off'), name: 'Off' },
|
|
10
|
+
{ id: ReasoningEffortId('low'), name: 'Low' },
|
|
10
11
|
{ id: ReasoningEffortId('high'), name: 'High' },
|
|
11
12
|
{ id: ReasoningEffortId('max'), name: 'Max' },
|
|
12
13
|
];
|
|
13
14
|
const LONG_CONTEXT_WINDOW = 1_000_000;
|
|
14
|
-
const K3_CONTEXT_WINDOW = 600_000;
|
|
15
15
|
export class UstcAdapter extends LlmAdapter {
|
|
16
16
|
ctx;
|
|
17
17
|
helper;
|
|
18
18
|
catalog;
|
|
19
19
|
delegate;
|
|
20
|
+
auth = { credentials: new InMemoryCredentialStore(), authContext: defaultProviderAuthContext() };
|
|
20
21
|
constructor(ctx, helper, catalog) {
|
|
21
22
|
super();
|
|
22
23
|
this.ctx = ctx;
|
|
@@ -33,12 +34,15 @@ export class UstcAdapter extends LlmAdapter {
|
|
|
33
34
|
}
|
|
34
35
|
async listModels(provider) {
|
|
35
36
|
this.assertProvider(provider);
|
|
36
|
-
return this.catalog.models().map(model =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
return this.catalog.models().map(model => {
|
|
38
|
+
const capabilities = modelCapabilities(model.id);
|
|
39
|
+
return {
|
|
40
|
+
provider: PROVIDER,
|
|
41
|
+
id: model.id,
|
|
42
|
+
name: model.name,
|
|
43
|
+
inputModalities: capabilities.input,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
42
46
|
}
|
|
43
47
|
async resolveModel(provider, model) {
|
|
44
48
|
this.assertProvider(provider);
|
|
@@ -48,7 +52,7 @@ export class UstcAdapter extends LlmAdapter {
|
|
|
48
52
|
provider: PROVIDER,
|
|
49
53
|
id: model,
|
|
50
54
|
name: match?.name ?? model,
|
|
51
|
-
inputModalities:
|
|
55
|
+
inputModalities: capabilities.input,
|
|
52
56
|
context: { contextWindow: capabilities.contextWindow },
|
|
53
57
|
defaultMaxTokens: DEFAULT_MAX_TOKENS,
|
|
54
58
|
...(capabilities.reasoning ? { reasoning: { efforts: USTC_REASONING_EFFORTS } } : {}),
|
|
@@ -79,6 +83,7 @@ export class UstcAdapter extends LlmAdapter {
|
|
|
79
83
|
const profiles = new Map([[PROVIDER, profile]]);
|
|
80
84
|
const adapter = new PiAiAdapter({
|
|
81
85
|
profiles: () => profiles,
|
|
86
|
+
auth: this.auth,
|
|
82
87
|
resolveApiKey: async () => {
|
|
83
88
|
const hit = await this.ctx.credentials.resolve(credentialRef(API_KEY_REF));
|
|
84
89
|
if (hit === undefined)
|
|
@@ -139,14 +144,14 @@ function makeProfile(baseURL, cached, headers) {
|
|
|
139
144
|
...(capabilities.reasoning ? {
|
|
140
145
|
thinkingLevelMap: {
|
|
141
146
|
minimal: null,
|
|
142
|
-
low:
|
|
147
|
+
low: 'low',
|
|
143
148
|
medium: null,
|
|
144
149
|
high: 'high',
|
|
145
150
|
xhigh: null,
|
|
146
151
|
max: 'max',
|
|
147
152
|
},
|
|
148
153
|
} : {}),
|
|
149
|
-
input:
|
|
154
|
+
input: capabilities.input,
|
|
150
155
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
151
156
|
contextWindow: capabilities.contextWindow,
|
|
152
157
|
maxTokens: DEFAULT_MAX_TOKENS,
|
|
@@ -190,18 +195,20 @@ function makeProfile(baseURL, cached, headers) {
|
|
|
190
195
|
defaultMaxTokens: DEFAULT_MAX_TOKENS,
|
|
191
196
|
defaultInput: ['text'],
|
|
192
197
|
streamIdleTimeoutMs: 300_000,
|
|
198
|
+
maxRequestImageBytes: 20 * 1024 * 1024,
|
|
199
|
+
requestImagePixelBudget: 4_194_304,
|
|
200
|
+
requestImageMaxBytes: 1_048_576,
|
|
193
201
|
retryPolicy: RETRY_POLICY,
|
|
194
202
|
piProvider: provider,
|
|
203
|
+
modelErrors: new Map(),
|
|
195
204
|
configuredMaxTokens: new Map(models.map(model => [model.id, DEFAULT_MAX_TOKENS])),
|
|
196
205
|
};
|
|
197
206
|
}
|
|
198
207
|
function modelCapabilities(model) {
|
|
199
208
|
const id = model.toLowerCase();
|
|
200
|
-
if (id.startsWith('deepseek
|
|
201
|
-
return { contextWindow: LONG_CONTEXT_WINDOW, reasoning: true };
|
|
209
|
+
if (id.startsWith('deepseek') || id.startsWith('glm-5')) {
|
|
210
|
+
return { contextWindow: LONG_CONTEXT_WINDOW, input: ['text', 'image'], reasoning: true };
|
|
202
211
|
}
|
|
203
|
-
|
|
204
|
-
return { contextWindow: K3_CONTEXT_WINDOW, reasoning: true };
|
|
205
|
-
return { contextWindow: DEFAULT_CONTEXT_WINDOW, reasoning: false };
|
|
212
|
+
return { contextWindow: DEFAULT_CONTEXT_WINDOW, input: ['text'], reasoning: false };
|
|
206
213
|
}
|
|
207
214
|
//# sourceMappingURL=adapter.js.map
|
package/lib/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,GAMnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAoC,MAAM,4BAA4B,CAAA;AAC1F,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,GAMnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAoC,MAAM,4BAA4B,CAAA;AAC1F,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,uBAAuB,EAAwB,MAAM,uBAAuB,CAAA;AACjI,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAA;AACxF,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,QAAQ,EACR,aAAa,GACd,MAAM,gBAAgB,CAAA;AAIvB,MAAM,YAAY,GAAG,kBAAkB,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAA;AAE1E,MAAM,sBAAsB,GAAG;IAC7B,EAAE,EAAE,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7C,EAAE,EAAE,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7C,EAAE,EAAE,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IAC/C,EAAE,EAAE,EAAE,iBAAiB,CAAC,K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,EAAE,SAAS;QAClC,oBAAoB,EAAE,SAAS;QAC/B,WAAW,EAAE,YAAY;QACzB,UAAU,EAAE,QAAQ;QACpB,WAAW,EAAE,IAAI,GAAG,EAAE;QACtB,mBAAmB,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC;KAClF,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACtC,MAAM,EAAE,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;IAC9B,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;IAC1F,CAAC;IACD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AACrF,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -9,12 +9,8 @@ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-
|
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
//#region src/client/index.tsx
|
|
11
11
|
const LOCALE_NS = "llm-ustc";
|
|
12
|
-
const SETTINGS_ROUTE = "/
|
|
12
|
+
const SETTINGS_ROUTE = "/api/llm-ustc/settings";
|
|
13
13
|
const en = {
|
|
14
|
-
title: "USTC LLM",
|
|
15
|
-
intro: "Manage the USTC API credential, model catalog, and iWAN access.",
|
|
16
|
-
expand: "Show settings",
|
|
17
|
-
collapse: "Hide settings",
|
|
18
14
|
apiKeyLabel: "USTC API Key",
|
|
19
15
|
apiKeyPlaceholder: "Enter a new key",
|
|
20
16
|
configured: "Configured",
|
|
@@ -49,10 +45,6 @@ const en = {
|
|
|
49
45
|
retry: "Retry"
|
|
50
46
|
};
|
|
51
47
|
const zh = {
|
|
52
|
-
title: "科大大模型",
|
|
53
|
-
intro: "管理科大 API 凭据、模型目录和 iWAN 访问。",
|
|
54
|
-
expand: "展开设置",
|
|
55
|
-
collapse: "收起设置",
|
|
56
48
|
apiKeyLabel: "科大 API Key",
|
|
57
49
|
apiKeyPlaceholder: "输入新的 Key",
|
|
58
50
|
configured: "已配置",
|
|
@@ -118,7 +110,8 @@ var UstcSettingsController = class {
|
|
|
118
110
|
...this.current,
|
|
119
111
|
status: "loading",
|
|
120
112
|
action: "load",
|
|
121
|
-
error: void 0
|
|
113
|
+
error: void 0,
|
|
114
|
+
errorAction: void 0
|
|
122
115
|
});
|
|
123
116
|
try {
|
|
124
117
|
const snapshot = await apiRequest();
|
|
@@ -134,7 +127,8 @@ var UstcSettingsController = class {
|
|
|
134
127
|
...this.current,
|
|
135
128
|
status: "error",
|
|
136
129
|
action: void 0,
|
|
137
|
-
error: messageOf(error)
|
|
130
|
+
error: messageOf(error),
|
|
131
|
+
errorAction: "load"
|
|
138
132
|
});
|
|
139
133
|
}
|
|
140
134
|
}
|
|
@@ -145,7 +139,8 @@ var UstcSettingsController = class {
|
|
|
145
139
|
this.set({
|
|
146
140
|
...this.current,
|
|
147
141
|
action,
|
|
148
|
-
error: void 0
|
|
142
|
+
error: void 0,
|
|
143
|
+
errorAction: void 0
|
|
149
144
|
});
|
|
150
145
|
try {
|
|
151
146
|
const value = await apiRequest({
|
|
@@ -157,7 +152,8 @@ var UstcSettingsController = class {
|
|
|
157
152
|
this.set({
|
|
158
153
|
...this.current,
|
|
159
154
|
action: void 0,
|
|
160
|
-
error: messageOf(error)
|
|
155
|
+
error: messageOf(error),
|
|
156
|
+
errorAction: action
|
|
161
157
|
});
|
|
162
158
|
}
|
|
163
159
|
}
|
|
@@ -185,55 +181,15 @@ var UstcSettingsController = class {
|
|
|
185
181
|
function messageOf(error) {
|
|
186
182
|
return error instanceof Error ? error.message : String(error);
|
|
187
183
|
}
|
|
188
|
-
function
|
|
189
|
-
if (controller === void 0 || t === void 0) return null;
|
|
190
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UstcCard, {
|
|
191
|
-
controller,
|
|
192
|
-
t
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function UstcCard({ controller, t }) {
|
|
184
|
+
function UstcBundleConfig({ controller, t }) {
|
|
196
185
|
const state = (0, react.useSyncExternalStore)(controller.subscribe, controller.snapshot, controller.snapshot);
|
|
197
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
198
|
-
(0, react.useEffect)(() => {
|
|
199
|
-
if (state.status === "idle") controller.load();
|
|
200
|
-
}, [controller, state.status]);
|
|
201
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
202
|
-
className: "ulu-card",
|
|
203
|
-
"data-open": open || void 0,
|
|
204
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
205
|
-
type: "button",
|
|
206
|
-
className: "ulu-card-header",
|
|
207
|
-
"aria-expanded": open,
|
|
208
|
-
"aria-label": `${t(open ? "collapse" : "expand")}: ${t("title")}`,
|
|
209
|
-
onClick: () => {
|
|
210
|
-
setOpen((value) => !value);
|
|
211
|
-
},
|
|
212
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
213
|
-
className: "ulu-card-head-text",
|
|
214
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
215
|
-
className: "ulu-card-name",
|
|
216
|
-
children: t("title")
|
|
217
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
218
|
-
className: "ulu-card-description",
|
|
219
|
-
children: t("intro")
|
|
220
|
-
})]
|
|
221
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { className: "ulu-card-chevron" })]
|
|
222
|
-
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
223
|
-
className: "ulu-card-body",
|
|
224
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LoadedSettings, {
|
|
225
|
-
controller,
|
|
226
|
-
t,
|
|
227
|
-
state
|
|
228
|
-
})
|
|
229
|
-
}) : null]
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
function LoadedSettings({ controller, t, state }) {
|
|
233
186
|
const snapshot = state.snapshot;
|
|
234
187
|
const [apiKey, setApiKey] = (0, react.useState)("");
|
|
235
188
|
const [callbackUrl, setCallbackUrl] = (0, react.useState)("");
|
|
236
189
|
const [selectedServerId, setSelectedServerId] = (0, react.useState)("");
|
|
190
|
+
(0, react.useEffect)(() => {
|
|
191
|
+
controller.load();
|
|
192
|
+
}, [controller]);
|
|
237
193
|
(0, react.useEffect)(() => {
|
|
238
194
|
setSelectedServerId(snapshot?.selectedServerId ?? "");
|
|
239
195
|
}, [snapshot?.selectedServerId]);
|
|
@@ -260,30 +216,6 @@ function LoadedSettings({ controller, t, state }) {
|
|
|
260
216
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
261
217
|
className: "ulu-settings",
|
|
262
218
|
children: [
|
|
263
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
264
|
-
className: "ulu-status-row",
|
|
265
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("route") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
266
|
-
className: "ulu-route-value",
|
|
267
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: snapshot.usingIwan ? t("iwanRoute") : t("directRoute") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
268
|
-
label: t("refreshRoute"),
|
|
269
|
-
side: "top",
|
|
270
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
271
|
-
className: "ulu-route-refresh",
|
|
272
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
273
|
-
type: "button",
|
|
274
|
-
variant: "toolbar",
|
|
275
|
-
size: "sm",
|
|
276
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutline14, { className: state.action === "refreshRoute" ? "ulu-spin" : void 0 }),
|
|
277
|
-
"aria-label": t("refreshRoute"),
|
|
278
|
-
disabled: busy,
|
|
279
|
-
onClick: () => {
|
|
280
|
-
controller.mutateSnapshot("refreshRoute");
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
})
|
|
284
|
-
})]
|
|
285
|
-
})]
|
|
286
|
-
}),
|
|
287
219
|
!snapshot.writable || !snapshot.apiKey.writable || !snapshot.iwan.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
288
220
|
className: "ulu-alert warning",
|
|
289
221
|
children: t("readOnly")
|
|
@@ -295,9 +227,10 @@ function LoadedSettings({ controller, t, state }) {
|
|
|
295
227
|
className: "ulu-section-title",
|
|
296
228
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("apiKeyLabel") })
|
|
297
229
|
}),
|
|
298
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
230
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
231
|
+
className: "ulu-input",
|
|
299
232
|
type: "password",
|
|
300
|
-
autoComplete: "
|
|
233
|
+
autoComplete: "new-password",
|
|
301
234
|
"aria-label": t("apiKeyLabel"),
|
|
302
235
|
placeholder: snapshot.apiKey.configured ? t("configured") : t("apiKeyPlaceholder"),
|
|
303
236
|
value: apiKey,
|
|
@@ -326,9 +259,37 @@ function LoadedSettings({ controller, t, state }) {
|
|
|
326
259
|
},
|
|
327
260
|
children: t("remove")
|
|
328
261
|
})]
|
|
329
|
-
})
|
|
262
|
+
}),
|
|
263
|
+
state.errorAction === "saveApiKey" || state.errorAction === "unsetApiKey" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
264
|
+
className: "ulu-alert error",
|
|
265
|
+
children: state.error
|
|
266
|
+
}) : null
|
|
330
267
|
]
|
|
331
268
|
}),
|
|
269
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
270
|
+
className: "ulu-status-row",
|
|
271
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("route") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
272
|
+
className: "ulu-route-value",
|
|
273
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: snapshot.usingIwan ? t("iwanRoute") : t("directRoute") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
274
|
+
label: t("refreshRoute"),
|
|
275
|
+
side: "top",
|
|
276
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
277
|
+
className: "ulu-route-refresh",
|
|
278
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
279
|
+
type: "button",
|
|
280
|
+
variant: "ghost",
|
|
281
|
+
size: "sm",
|
|
282
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineMedium, { className: state.action === "refreshRoute" ? "ulu-spin" : void 0 }),
|
|
283
|
+
"aria-label": t("refreshRoute"),
|
|
284
|
+
disabled: busy,
|
|
285
|
+
onClick: () => {
|
|
286
|
+
controller.mutateSnapshot("refreshRoute");
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
})
|
|
290
|
+
})]
|
|
291
|
+
})]
|
|
292
|
+
}),
|
|
332
293
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
333
294
|
className: "ulu-section",
|
|
334
295
|
children: [
|
|
@@ -368,7 +329,8 @@ function LoadedSettings({ controller, t, state }) {
|
|
|
368
329
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
369
330
|
htmlFor: "ulu-callback-url",
|
|
370
331
|
children: t("callbackLabel")
|
|
371
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
332
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
333
|
+
className: "ulu-input",
|
|
372
334
|
id: "ulu-callback-url",
|
|
373
335
|
value: callbackUrl,
|
|
374
336
|
placeholder: t("callbackPlaceholder"),
|
|
@@ -417,46 +379,71 @@ function LoadedSettings({ controller, t, state }) {
|
|
|
417
379
|
},
|
|
418
380
|
children: state.action === "selectServer" ? t("applyingLine") : t("selectLine")
|
|
419
381
|
})]
|
|
382
|
+
}) : null,
|
|
383
|
+
state.errorAction === "beginOidc" || state.errorAction === "completeOidc" || state.errorAction === "logoutIwan" || state.errorAction === "selectServer" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
384
|
+
className: "ulu-alert error",
|
|
385
|
+
children: state.error
|
|
420
386
|
}) : null
|
|
421
387
|
]
|
|
422
388
|
}),
|
|
423
389
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
424
390
|
className: "ulu-section",
|
|
425
|
-
children: [
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
t("
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
className: "ulu-model-
|
|
444
|
-
children:
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
391
|
+
children: [
|
|
392
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
393
|
+
className: "ulu-section-title",
|
|
394
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("models") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { children: [
|
|
395
|
+
t("refreshedAt"),
|
|
396
|
+
": ",
|
|
397
|
+
snapshot.modelsUpdatedAt === void 0 ? t("never") : new Date(snapshot.modelsUpdatedAt).toLocaleString()
|
|
398
|
+
] })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
399
|
+
size: "sm",
|
|
400
|
+
variant: "outline",
|
|
401
|
+
disabled: busy || !snapshot.apiKey.configured,
|
|
402
|
+
onClick: () => {
|
|
403
|
+
controller.mutateSnapshot("syncModels");
|
|
404
|
+
},
|
|
405
|
+
children: state.action === "syncModels" ? t("syncingModels") : t("syncModels")
|
|
406
|
+
})]
|
|
407
|
+
}),
|
|
408
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
409
|
+
className: "ulu-model-list",
|
|
410
|
+
children: snapshot.models.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
411
|
+
className: "ulu-model-entry",
|
|
412
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: model.id }), model.name === model.id ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: model.name })]
|
|
413
|
+
}, model.id))
|
|
414
|
+
}),
|
|
415
|
+
state.errorAction === "syncModels" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
416
|
+
className: "ulu-alert error",
|
|
417
|
+
children: state.error
|
|
418
|
+
}) : null
|
|
419
|
+
]
|
|
420
|
+
}),
|
|
421
|
+
state.errorAction === "refreshRoute" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
422
|
+
className: "ulu-alert error",
|
|
423
|
+
children: state.error
|
|
424
|
+
}) : null
|
|
448
425
|
]
|
|
449
426
|
});
|
|
450
427
|
}
|
|
451
428
|
const CSS = `
|
|
452
|
-
.ulu-
|
|
453
|
-
.ulu-
|
|
454
|
-
.ulu-
|
|
455
|
-
.ulu-section{display:grid;min-width:0;gap:6px;padding:12px 0;border-top:
|
|
456
|
-
.ulu-
|
|
457
|
-
.ulu-
|
|
458
|
-
.ulu-
|
|
459
|
-
.ulu-
|
|
429
|
+
.ulu-settings{display:flex;min-width:0;flex-direction:column;color:var(--dsw-alias-label-primary)}
|
|
430
|
+
.ulu-status-row{display:flex;min-height:34px;align-items:center;justify-content:space-between;gap:16px;padding:12px 0;border-top:0.5px solid var(--dsw-alias-border-l2);font-size:13px;line-height:1.5}
|
|
431
|
+
.ulu-status-row strong{font-weight:500}.ulu-route-value{display:flex;align-items:center;gap:5px}.ulu-route-refresh{display:inline-flex}.ulu-route-refresh>button,.ulu-route-refresh>button:hover:not(:disabled),.ulu-route-refresh>button:active:not(:disabled){width:28px;padding:0;background:transparent}
|
|
432
|
+
.ulu-section{display:grid;min-width:0;gap:6px;padding:12px 0;border-top:0.5px solid var(--dsw-alias-border-l2)}.ulu-section>*{min-width:0}
|
|
433
|
+
.ulu-section-title{display:flex;min-width:0;align-items:center;justify-content:space-between;gap:8px}.ulu-section-title>div{min-width:0}
|
|
434
|
+
.ulu-section-title h3,.ulu-field>label{margin:0;color:var(--dsw-alias-label-primary);font-size:13px;font-weight:500;line-height:1.5}
|
|
435
|
+
.ulu-section-title p{margin:3px 0 0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5;overflow-wrap:anywhere}
|
|
436
|
+
.ulu-input,.ulu-line-select{box-sizing:border-box;width:100%;height:34px;padding:0 12px;border:0.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.5}
|
|
437
|
+
.ulu-input::placeholder{color:var(--dsw-alias-label-dimmed)}.ulu-input:focus-visible,.ulu-line-select:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
438
|
+
.ulu-row{display:grid;min-width:0;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px}.ulu-field{display:grid;min-width:0;gap:6px}.ulu-field>*{min-width:0}
|
|
439
|
+
.ulu-actions,.ulu-login-row{display:flex;min-width:0;align-items:center;gap:8px}.ulu-actions{padding-top:16px}.ulu-actions button:first-child,.ulu-login-row button,.ulu-row>button{min-height:31px;padding:5px 14px;border-radius:var(--dsw-radius-md);font-size:13px;line-height:1.5}
|
|
440
|
+
.ulu-link{display:inline-flex;min-height:31px;align-items:center;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:1.5;text-decoration:none}.ulu-link:hover{color:var(--dsw-alias-label-primary);text-decoration:underline}
|
|
441
|
+
.ulu-spin{animation:ulu-spin .7s linear infinite}@keyframes ulu-spin{to{transform:rotate(360deg)}}
|
|
442
|
+
.ulu-alert{margin:0;padding:10px 0;border-top:0.5px solid var(--dsw-alias-border-l2);font-size:12px;line-height:1.5}.ulu-alert.warning{color:var(--dsw-alias-label-tertiary)}.ulu-alert.error{color:var(--dsw-alias-label-error)}
|
|
443
|
+
.ulu-loading{padding:12px 0;color:var(--dsw-alias-label-tertiary);font-size:12px}.ulu-load-error{display:flex;align-items:center;justify-content:space-between;gap:12px}.ulu-load-error .ulu-alert{flex:1;border-top:0}
|
|
444
|
+
.ulu-model-list{display:flex;max-height:300px;min-width:0;flex-direction:column;overflow:auto;border-top:0.5px solid var(--dsw-alias-border-l2)}
|
|
445
|
+
.ulu-model-entry{display:grid;min-width:0;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:8px;padding:9px 2px;border-bottom:0.5px solid var(--dsw-alias-border-l2);font-size:12px;line-height:18px}
|
|
446
|
+
.ulu-model-entry code,.ulu-model-entry span{min-width:0;overflow-wrap:anywhere}.ulu-model-entry span{color:var(--dsw-alias-label-tertiary)}
|
|
460
447
|
`;
|
|
461
448
|
function installStyles() {
|
|
462
449
|
const id = "dsh-llm-ustc/client";
|
|
@@ -486,14 +473,14 @@ function apply(ctx) {
|
|
|
486
473
|
dispose();
|
|
487
474
|
};
|
|
488
475
|
}, "dsh-llm-ustc: settings invalidations");
|
|
489
|
-
ctx.slots.inject("
|
|
490
|
-
name: "
|
|
491
|
-
key:
|
|
476
|
+
ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
|
|
477
|
+
name: "plugins.bundle.config",
|
|
478
|
+
key: "dsh-llm-ustc",
|
|
492
479
|
inject: () => ({
|
|
493
480
|
controller,
|
|
494
481
|
t
|
|
495
482
|
})
|
|
496
|
-
},
|
|
483
|
+
}, UstcBundleConfig));
|
|
497
484
|
}
|
|
498
485
|
//#endregion
|
|
499
486
|
exports.UstcSettingsController = UstcSettingsController;
|
package/lib/config.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
import { API_KEY_REF } from "./constants.js";
|
|
2
3
|
export const Config = z.object({
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
apiKeyEnv: z.union([API_KEY_REF]).role('credential-ref').default(API_KEY_REF).volatile(),
|
|
5
|
+
selectedServerId: z.string().volatile(),
|
|
6
|
+
directRecoverySeconds: z.number().step(1).min(30).max(86_400).default(300).volatile(),
|
|
5
7
|
});
|
|
6
8
|
export function resolveConfig(config) {
|
|
7
|
-
const directRecoverySeconds = config.directRecoverySeconds
|
|
9
|
+
const directRecoverySeconds = config.directRecoverySeconds.get();
|
|
8
10
|
if (!Number.isSafeInteger(directRecoverySeconds) || directRecoverySeconds < 30 || directRecoverySeconds > 86_400) {
|
|
9
11
|
throw new TypeError('llm-ustc.directRecoverySeconds must be an integer from 30 to 86400');
|
|
10
12
|
}
|
|
11
|
-
const selected = config.selectedServerId?.trim();
|
|
13
|
+
const selected = config.selectedServerId.get()?.trim();
|
|
12
14
|
return {
|
|
13
15
|
...(selected === undefined || selected.length === 0 ? {} : { selectedServerId: selected }),
|
|
14
16
|
directRecoverySeconds,
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAQ5C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;IACxF,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACvC,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CACtF,CAAC,CAAA;AAOF,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,MAAM,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAAA;IAChE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,qBAAqB,CAAC,IAAI,qBAAqB,GAAG,EAAE,IAAI,qBAAqB,GAAG,MAAM,EAAE,CAAC;QACjH,MAAM,IAAI,SAAS,CAAC,oEAAoE,CAAC,CAAA;IAC3F,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAA;IACtD,OAAO;QACL,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC;QAC1F,qBAAqB;KACtB,CAAA;AACH,CAAC"}
|
package/lib/constants.js
CHANGED
|
@@ -3,9 +3,9 @@ export const PROVIDER_NAME = 'USTC LLM';
|
|
|
3
3
|
export const SETTINGS_NS = 'llm-ustc';
|
|
4
4
|
export const API_KEY_REF = 'USTC_LLM_API_KEY';
|
|
5
5
|
export const IWAN_CONFIG_REF = 'USTC_LLM_IWAN_CONFIG';
|
|
6
|
-
export const DEFAULT_MODEL = 'deepseek-
|
|
6
|
+
export const DEFAULT_MODEL = 'deepseek-flash';
|
|
7
7
|
export const DEFAULT_CONTEXT_WINDOW = 262_144;
|
|
8
8
|
export const DEFAULT_MAX_TOKENS = 32_768;
|
|
9
9
|
export const HELPER_PROTOCOL = 'v2';
|
|
10
|
-
export const SETTINGS_ROUTE = '/
|
|
10
|
+
export const SETTINGS_ROUTE = '/api/llm-ustc/settings';
|
|
11
11
|
//# sourceMappingURL=constants.js.map
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAA;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAA;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAA;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAA;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAA;AACrD,MAAM,CAAC,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAA;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAA;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAA;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAA;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAA;AACrD,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAA;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAA;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAA;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
2
1
|
import { UstcAdapter } from "./adapter.js";
|
|
3
2
|
import { Config, resolveConfig } from "./config.js";
|
|
4
3
|
import { PROVIDER, PROVIDER_NAME, SETTINGS_NS } from "./constants.js";
|
|
@@ -9,32 +8,28 @@ import { installWeb, UstcWebBackend } from "./web.js";
|
|
|
9
8
|
export const name = 'dsh-llm-ustc';
|
|
10
9
|
export const inject = ['llm', 'credentials', 'settings'];
|
|
11
10
|
export { Config };
|
|
12
|
-
export async function apply(ctx, config
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
applies: 'live',
|
|
16
|
-
validate: resolveConfig,
|
|
17
|
-
});
|
|
11
|
+
export async function apply(ctx, config) {
|
|
12
|
+
ctx.inject(['settings'], child => { child.effect(() => child.settings.configure({ auto: false }, ctx.fiber)); });
|
|
13
|
+
const settingsId = ctx.fiber.entry?.options.id ?? SETTINGS_NS;
|
|
18
14
|
const store = new StateStore();
|
|
19
15
|
await store.load();
|
|
20
|
-
const helper = new HelperManager(ctx, resolveConfig(
|
|
16
|
+
const helper = new HelperManager(ctx, resolveConfig(config));
|
|
21
17
|
const catalog = new ModelCatalog(ctx, helper, store);
|
|
22
18
|
const adapter = new UstcAdapter(ctx, helper, catalog);
|
|
23
19
|
const registration = ctx.llm.registerAdapter([PROVIDER], adapter);
|
|
24
20
|
const directory = ctx.llm.registerConfigurableProviders([{
|
|
25
21
|
provider: PROVIDER,
|
|
26
22
|
displayName: PROVIDER_NAME,
|
|
27
|
-
settingsNs:
|
|
23
|
+
settingsNs: settingsId,
|
|
28
24
|
settingsPath: [],
|
|
29
25
|
declared: false,
|
|
30
26
|
}]);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
ctx.on('settings/document-updated', ns => {
|
|
28
|
+
if (ns === settingsId)
|
|
29
|
+
helper.reconfigure(resolveConfig(config));
|
|
34
30
|
});
|
|
35
|
-
installWeb(ctx, new UstcWebBackend(ctx, helper, catalog, store));
|
|
31
|
+
installWeb(ctx, new UstcWebBackend(ctx, helper, catalog, store, undefined, settingsId, config));
|
|
36
32
|
return async () => {
|
|
37
|
-
watch();
|
|
38
33
|
directory();
|
|
39
34
|
registration();
|
|
40
35
|
await helper.dispose();
|