@dsh-plus/llm-pi 0.1.2 → 0.1.4
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/lib/client.js +85 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -0
- package/package.json +9 -9
- package/src/client/api.ts +1 -0
- package/src/client/client.ts +74 -10
- package/src/client/draft.ts +4 -0
- package/src/client/i18n.ts +2 -0
- package/src/client/scope.ts +9 -5
- package/src/client/views/provider-fields.tsx +8 -0
- package/src/config.ts +7 -0
- package/src/profiles.ts +2 -0
package/lib/client.js
CHANGED
|
@@ -196,6 +196,7 @@ function providerDraftFromWire(provider) {
|
|
|
196
196
|
timeoutMs: numToText(provider.timeoutMs),
|
|
197
197
|
websocketConnectTimeoutMs: numToText(provider.websocketConnectTimeoutMs),
|
|
198
198
|
streamIdleTimeoutMs: numToText(provider.streamIdleTimeoutMs),
|
|
199
|
+
maxRequestImageBytes: numToText(provider.maxRequestImageBytes),
|
|
199
200
|
retryPolicy: provider.retryPolicy,
|
|
200
201
|
models: (provider.models ?? []).map(modelDraftFromWire)
|
|
201
202
|
};
|
|
@@ -219,6 +220,7 @@ function providerToWire(provider) {
|
|
|
219
220
|
timeoutMs: toNum(provider.timeoutMs),
|
|
220
221
|
websocketConnectTimeoutMs: toNum(provider.websocketConnectTimeoutMs),
|
|
221
222
|
streamIdleTimeoutMs: toNum(provider.streamIdleTimeoutMs),
|
|
223
|
+
maxRequestImageBytes: toNum(provider.maxRequestImageBytes),
|
|
222
224
|
retryPolicy: provider.retryPolicy,
|
|
223
225
|
models: provider.models.map(modelToWire)
|
|
224
226
|
});
|
|
@@ -250,6 +252,7 @@ function emptyProviderDraft() {
|
|
|
250
252
|
timeoutMs: "",
|
|
251
253
|
websocketConnectTimeoutMs: "",
|
|
252
254
|
streamIdleTimeoutMs: "",
|
|
255
|
+
maxRequestImageBytes: "",
|
|
253
256
|
retryPolicy: void 0,
|
|
254
257
|
models: []
|
|
255
258
|
};
|
|
@@ -1067,6 +1070,14 @@ function ProviderScalarFields(props) {
|
|
|
1067
1070
|
disabled: props.disabled === true,
|
|
1068
1071
|
onEdit: (value) => props.onPatch({ streamIdleTimeoutMs: value })
|
|
1069
1072
|
}),
|
|
1073
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
|
|
1074
|
+
id: `${props.id}-maxImageBytes`,
|
|
1075
|
+
label: t("maxRequestImageBytes"),
|
|
1076
|
+
numeric: true,
|
|
1077
|
+
value: draft.maxRequestImageBytes,
|
|
1078
|
+
disabled: props.disabled === true,
|
|
1079
|
+
onEdit: (value) => props.onPatch({ maxRequestImageBytes: value })
|
|
1080
|
+
}),
|
|
1070
1081
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1071
1082
|
className: "lpc-field",
|
|
1072
1083
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1656,6 +1667,7 @@ const zh = {
|
|
|
1656
1667
|
timeoutMs: "HTTP 超时(毫秒)",
|
|
1657
1668
|
websocketConnectTimeoutMs: "WebSocket 连接超时(毫秒)",
|
|
1658
1669
|
streamIdleTimeoutMs: "流空闲超时(毫秒)",
|
|
1670
|
+
maxRequestImageBytes: "单请求图片载荷上限(字节,缺省 20MiB)",
|
|
1659
1671
|
headers: "请求头",
|
|
1660
1672
|
headersHint: "键值对;键为空的整行会被忽略。",
|
|
1661
1673
|
key: "键",
|
|
@@ -1744,6 +1756,7 @@ const en = {
|
|
|
1744
1756
|
timeoutMs: "HTTP timeout (ms)",
|
|
1745
1757
|
websocketConnectTimeoutMs: "WebSocket connect timeout (ms)",
|
|
1746
1758
|
streamIdleTimeoutMs: "Stream idle timeout (ms)",
|
|
1759
|
+
maxRequestImageBytes: "Max image payload per request (bytes, default 20MiB)",
|
|
1747
1760
|
headers: "Request headers",
|
|
1748
1761
|
headersHint: "Key/value pairs; rows with an empty key are ignored.",
|
|
1749
1762
|
key: "Key",
|
|
@@ -1885,9 +1898,78 @@ const name = "dsh-plus-llm-pi";
|
|
|
1885
1898
|
const inject = [
|
|
1886
1899
|
"slots",
|
|
1887
1900
|
"locale",
|
|
1888
|
-
"
|
|
1889
|
-
"
|
|
1901
|
+
"connection",
|
|
1902
|
+
"remote"
|
|
1890
1903
|
];
|
|
1904
|
+
/**
|
|
1905
|
+
* api 直连实现的命名空间 scope(官方配置页 tab 同款模式)。
|
|
1906
|
+
* 读:describe 取命名空间视图(脱敏 value/revision + 顶层 writable);
|
|
1907
|
+
* 刷新:remote `settings/document-updated`(按命名空间过滤)与
|
|
1908
|
+
* `connection/reset`;generation 防旧读覆盖新发布。任何页面 origin
|
|
1909
|
+
* (loopback 或 tailnet 信任域名)下行为一致。
|
|
1910
|
+
*/
|
|
1911
|
+
function createApiScope(api, ns, c) {
|
|
1912
|
+
let state = {
|
|
1913
|
+
status: "loading",
|
|
1914
|
+
value: void 0,
|
|
1915
|
+
revision: void 0,
|
|
1916
|
+
writable: false
|
|
1917
|
+
};
|
|
1918
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1919
|
+
let generation = 0;
|
|
1920
|
+
const publish = (next) => {
|
|
1921
|
+
state = next;
|
|
1922
|
+
for (const listener of [...listeners]) listener();
|
|
1923
|
+
};
|
|
1924
|
+
const load = async () => {
|
|
1925
|
+
const gen = ++generation;
|
|
1926
|
+
let response;
|
|
1927
|
+
try {
|
|
1928
|
+
response = await api.describe({});
|
|
1929
|
+
} catch {
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
if (gen !== generation || !response.result.ok) return;
|
|
1933
|
+
const writable = response.result.value?.writable ?? false;
|
|
1934
|
+
const view = response.result.value?.namespaces.find((candidate) => candidate.ns === ns);
|
|
1935
|
+
if (view === void 0) {
|
|
1936
|
+
publish({
|
|
1937
|
+
status: "unavailable",
|
|
1938
|
+
value: void 0,
|
|
1939
|
+
revision: void 0,
|
|
1940
|
+
writable
|
|
1941
|
+
});
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
publish({
|
|
1945
|
+
status: "ready",
|
|
1946
|
+
value: view.value,
|
|
1947
|
+
revision: view.revision,
|
|
1948
|
+
writable
|
|
1949
|
+
});
|
|
1950
|
+
};
|
|
1951
|
+
const refresh = (namespace) => {
|
|
1952
|
+
if (namespace !== void 0 && namespace !== ns) return;
|
|
1953
|
+
load();
|
|
1954
|
+
};
|
|
1955
|
+
const disposers = [c.get("remote").$on("settings/document-updated", refresh), c.on("connection/reset", () => {
|
|
1956
|
+
load();
|
|
1957
|
+
})];
|
|
1958
|
+
c.effect(() => () => {
|
|
1959
|
+
for (const dispose of disposers) dispose();
|
|
1960
|
+
}, "llm-pi: settings scope");
|
|
1961
|
+
load();
|
|
1962
|
+
return {
|
|
1963
|
+
getSnapshot: () => state,
|
|
1964
|
+
subscribe: (listener) => {
|
|
1965
|
+
listeners.add(listener);
|
|
1966
|
+
return () => {
|
|
1967
|
+
listeners.delete(listener);
|
|
1968
|
+
};
|
|
1969
|
+
},
|
|
1970
|
+
load
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1891
1973
|
function apply(ctx) {
|
|
1892
1974
|
const c = ctx;
|
|
1893
1975
|
const tag = injectStyle();
|
|
@@ -1898,8 +1980,8 @@ function apply(ctx) {
|
|
|
1898
1980
|
zh,
|
|
1899
1981
|
en
|
|
1900
1982
|
}), "llm-pi: locale");
|
|
1901
|
-
const scope = c.settingsScope.bind({ namespace: SETTINGS_NS });
|
|
1902
1983
|
const api = c.get("connection").api.settings;
|
|
1984
|
+
const scope = createApiScope(api, SETTINGS_NS, c);
|
|
1903
1985
|
c.slots.inject("settings.plugin.item", () => c.slots.register({
|
|
1904
1986
|
name: "settings.plugin.item",
|
|
1905
1987
|
key: SETTINGS_NS,
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -52,6 +52,9 @@ const MODALITIES = ["text", "image"];
|
|
|
52
52
|
const DEFAULT_CONTEXT_WINDOW = 262144;
|
|
53
53
|
const DEFAULT_MAX_TOKENS = 32768;
|
|
54
54
|
const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 3e5;
|
|
55
|
+
/** 单请求 base64 图片载荷上限(rc8 起官方 ResolvedPiAiProviderProfile 必需字段;
|
|
56
|
+
* 缺省取官方默认 20MiB,旧配置无需改动即自动生效)。 */
|
|
57
|
+
const DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
55
58
|
/** dsh-timeout 的定时器上限(与官方 MAX_TIMER_DELAY_MS 对齐)。 */
|
|
56
59
|
const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
|
|
57
60
|
/** 键为可选档位,值为线协议拼写;仅 off 可留空(支持但不发送参数)。 */
|
|
@@ -105,6 +108,7 @@ const providerProfile = z.object({
|
|
|
105
108
|
timeoutMs: z.natural().description("HTTP/provider 超时毫秒"),
|
|
106
109
|
websocketConnectTimeoutMs: z.natural().description("WebSocket 连接超时毫秒"),
|
|
107
110
|
streamIdleTimeoutMs: z.number().min(Number.MIN_VALUE).max(MAX_TIMER_DELAY_MS).description("单支流式读取的最大空闲间隔毫秒"),
|
|
111
|
+
maxRequestImageBytes: z.natural().description("单请求 base64 图片载荷上限字节;缺省 20MiB(rc8 起生效,旧配置免改)"),
|
|
108
112
|
retryPolicy: z.any().description("provider 重试策略(dsh-llm RetryPolicy 形状,构建期校验)"),
|
|
109
113
|
models: z.array(modelEntry).description("本 route 的模型目录;缺省且 provider 有 extends 时继承该源全部模型")
|
|
110
114
|
});
|
|
@@ -846,6 +850,7 @@ function buildProfiles(providers, deps) {
|
|
|
846
850
|
displayName,
|
|
847
851
|
...profile.apiKeyEnv === void 0 ? {} : { apiKeyEnv: credentialRef(profile.apiKeyEnv) },
|
|
848
852
|
streamIdleTimeoutMs,
|
|
853
|
+
maxRequestImageBytes: profile.maxRequestImageBytes ?? DEFAULT_MAX_REQUEST_IMAGE_BYTES,
|
|
849
854
|
retryPolicy: deps.kit.resolveRetryPolicy(profile.retryPolicy, `llm-pi: provider "${route}" retryPolicy`),
|
|
850
855
|
...profile.headers === void 0 ? {} : { headers: { ...profile.headers } },
|
|
851
856
|
...profile.reasoning === void 0 ? {} : { reasoning: profile.reasoning },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/llm-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: 基于 PiAiAdapter 的自定义 LLM 路由(全量 compat、模型继承、models.dev 目录兜底)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@deepseek-ai/dsh-client-runtime",
|
|
27
27
|
"@deepseek-ai/dsh-client-locale",
|
|
28
28
|
"@deepseek-ai/dsh-client-connection",
|
|
29
|
-
"@deepseek-ai/dsh-
|
|
29
|
+
"@deepseek-ai/dsh-api-remotes"
|
|
30
30
|
],
|
|
31
31
|
"platform": "web"
|
|
32
32
|
}
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@deepseek-ai/cordis": "4.0.1",
|
|
36
36
|
"@deepseek-ai/schemastery": "3.18.1",
|
|
37
|
-
"@deepseek-ai/dsh-settings": "0.1.0-rc.
|
|
38
|
-
"@deepseek-ai/dsh-llm": "0.1.0-rc.
|
|
39
|
-
"@deepseek-ai/dsh-credentials": "0.1.0-rc.
|
|
40
|
-
"@deepseek-ai/dsh-home-paths": "0.1.0-rc.
|
|
41
|
-
"@deepseek-ai/dsh-launch-environment": "0.1.0-rc.
|
|
42
|
-
"@deepseek-ai/dsh-llm-pi-ai": "0.1.0-rc.
|
|
37
|
+
"@deepseek-ai/dsh-settings": "0.1.0-rc.8",
|
|
38
|
+
"@deepseek-ai/dsh-llm": "0.1.0-rc.8",
|
|
39
|
+
"@deepseek-ai/dsh-credentials": "0.1.0-rc.8",
|
|
40
|
+
"@deepseek-ai/dsh-home-paths": "0.1.0-rc.8",
|
|
41
|
+
"@deepseek-ai/dsh-launch-environment": "0.1.0-rc.8",
|
|
42
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.1.0-rc.8",
|
|
43
43
|
"@earendil-works/pi-ai": "0.82.1",
|
|
44
44
|
"https-proxy-agent": "^7.0.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@deepseek-ai/dsh-host-webserver": "0.1.0-rc.
|
|
47
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.0-rc.8",
|
|
48
48
|
"@types/react": "~18.3.1",
|
|
49
49
|
"react": "^18.2.0"
|
|
50
50
|
},
|
package/src/client/api.ts
CHANGED
package/src/client/client.ts
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
* 构建产物为 window.__ModuleLoader__.load({id, factory}) 形式的 CJS factory
|
|
4
4
|
* (包装见 tsdown.config.ts);样式沿用官方 data-plugin-css 约定,HMR 据此卸载。
|
|
5
5
|
*
|
|
6
|
-
* 类型说明:浏览器半只用到 slots/locale/
|
|
6
|
+
* 类型说明:浏览器半只用到 slots/locale/connection/remote 的很窄一面,
|
|
7
7
|
* 此处以最小本地接口声明(见 ./scope.ts),避免为构建期类型引入整条官方
|
|
8
8
|
* client 依赖树;运行时契约以官方 dsh-client-ui-settings-plugins 的
|
|
9
|
-
* settings.plugin.item 插槽与 dsh-client-
|
|
9
|
+
* settings.plugin.item 插槽与 dsh-client-connection 的 settings RPC 面为准。
|
|
10
10
|
* rc7 起该插槽为 keyed 槽位:key 必须是卡片编辑的 settings 命名空间
|
|
11
11
|
* (即服务端 settingsNamespace() 注册的同一字面量,见 ../ns.ts),
|
|
12
12
|
* 官方配置页按此 key 与 Host 已注册命名空间配对分发。
|
|
13
|
-
* 配置读写经官方
|
|
14
|
-
*
|
|
13
|
+
* 配置读写经官方 settings RPC 直连(rc7 起第三方命名空间全量开放;
|
|
14
|
+
* 不复用 settingsScope 服务——非 loopback 页面下它无数据,见 scope.ts);
|
|
15
|
+
* 自定义端点仅剩「模型目录」(api.ts,含 kitSource/models-dev
|
|
15
16
|
* 运行期诊断)。
|
|
16
17
|
* @module @dsh-plus/llm-pi/client
|
|
17
18
|
*/
|
|
@@ -26,7 +27,7 @@ import { injectStyle } from './styles.ts'
|
|
|
26
27
|
export const name = 'dsh-plus-llm-pi'
|
|
27
28
|
|
|
28
29
|
/** 浏览器半需要的 cordis 服务 key(loader 据此注入;package.json 的 dsh.client.inject 管包加载顺序)。 */
|
|
29
|
-
export const inject = ['slots', 'locale', '
|
|
30
|
+
export const inject = ['slots', 'locale', 'connection', 'remote'] as const
|
|
30
31
|
|
|
31
32
|
interface SlotsLike {
|
|
32
33
|
inject(key: string, callback: () => unknown): unknown
|
|
@@ -38,23 +39,86 @@ interface LocaleLike {
|
|
|
38
39
|
bind(ns: string): (key: string) => string
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
interface
|
|
42
|
-
|
|
42
|
+
interface RemoteLike {
|
|
43
|
+
$on(event: string, listener: (payload?: unknown) => void): () => void
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
interface ConnectionLike {
|
|
46
|
-
settings: SettingsApi
|
|
47
|
+
api: { settings: SettingsApi }
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
interface ClientContext {
|
|
50
51
|
slots: SlotsLike
|
|
51
52
|
locale: LocaleLike
|
|
52
|
-
settingsScope: SettingsScopeServiceLike
|
|
53
53
|
get(key: 'connection'): ConnectionLike
|
|
54
|
+
get(key: 'remote'): RemoteLike
|
|
55
|
+
on(event: string, listener: () => void): () => void
|
|
54
56
|
effect(execute: () => () => void, label?: string): unknown
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* api 直连实现的命名空间 scope(官方配置页 tab 同款模式)。
|
|
61
|
+
* 读:describe 取命名空间视图(脱敏 value/revision + 顶层 writable);
|
|
62
|
+
* 刷新:remote `settings/document-updated`(按命名空间过滤)与
|
|
63
|
+
* `connection/reset`;generation 防旧读覆盖新发布。任何页面 origin
|
|
64
|
+
* (loopback 或 tailnet 信任域名)下行为一致。
|
|
65
|
+
*/
|
|
66
|
+
function createApiScope(api: SettingsApi, ns: string, c: ClientContext): Scope {
|
|
67
|
+
let state: ScopeSnapshot = { status: 'loading', value: undefined, revision: undefined, writable: false }
|
|
68
|
+
const listeners = new Set<() => void>()
|
|
69
|
+
let generation = 0
|
|
70
|
+
const publish = (next: ScopeSnapshot): void => {
|
|
71
|
+
state = next
|
|
72
|
+
for (const listener of [...listeners]) listener()
|
|
73
|
+
}
|
|
74
|
+
const load = async (): Promise<void> => {
|
|
75
|
+
const gen = ++generation
|
|
76
|
+
let response
|
|
77
|
+
try {
|
|
78
|
+
response = await api.describe({})
|
|
79
|
+
} catch {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
if (gen !== generation || !response.result.ok) return
|
|
83
|
+
const writable = response.result.value?.writable ?? false
|
|
84
|
+
const view = response.result.value?.namespaces.find((candidate) => candidate.ns === ns)
|
|
85
|
+
if (view === undefined) {
|
|
86
|
+
publish({ status: 'unavailable', value: undefined, revision: undefined, writable })
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
publish({ status: 'ready', value: view.value, revision: view.revision, writable })
|
|
90
|
+
}
|
|
91
|
+
const refresh = (namespace?: unknown): void => {
|
|
92
|
+
if (namespace !== undefined && namespace !== ns) return
|
|
93
|
+
void load()
|
|
94
|
+
}
|
|
95
|
+
const disposers = [
|
|
96
|
+
c.get('remote').$on('settings/document-updated', refresh),
|
|
97
|
+
c.on('connection/reset', () => {
|
|
98
|
+
void load()
|
|
99
|
+
}),
|
|
100
|
+
]
|
|
101
|
+
c.effect(
|
|
102
|
+
() => () => {
|
|
103
|
+
for (const dispose of disposers) dispose()
|
|
104
|
+
},
|
|
105
|
+
'llm-pi: settings scope',
|
|
106
|
+
)
|
|
107
|
+
void load()
|
|
108
|
+
return {
|
|
109
|
+
getSnapshot: () => state,
|
|
110
|
+
subscribe: (listener: () => void) => {
|
|
111
|
+
listeners.add(listener)
|
|
112
|
+
return () => {
|
|
113
|
+
listeners.delete(listener)
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
load,
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
57
120
|
export function apply(ctx: Context): void {
|
|
121
|
+
|
|
58
122
|
const c = ctx as unknown as ClientContext
|
|
59
123
|
const tag = injectStyle()
|
|
60
124
|
c.effect(
|
|
@@ -67,8 +131,8 @@ export function apply(ctx: Context): void {
|
|
|
67
131
|
() => c.locale.register(NS, { zh, en }),
|
|
68
132
|
'llm-pi: locale',
|
|
69
133
|
)
|
|
70
|
-
const scope = c.settingsScope.bind({ namespace: SETTINGS_NS })
|
|
71
134
|
const api = c.get('connection').api.settings
|
|
135
|
+
const scope = createApiScope(api, SETTINGS_NS, c)
|
|
72
136
|
c.slots.inject('settings.plugin.item', () =>
|
|
73
137
|
c.slots.register(
|
|
74
138
|
{
|
package/src/client/draft.ts
CHANGED
|
@@ -58,6 +58,7 @@ export interface ProviderDraft {
|
|
|
58
58
|
timeoutMs: string
|
|
59
59
|
websocketConnectTimeoutMs: string
|
|
60
60
|
streamIdleTimeoutMs: string
|
|
61
|
+
maxRequestImageBytes: string
|
|
61
62
|
retryPolicy: unknown
|
|
62
63
|
models: ModelDraft[]
|
|
63
64
|
}
|
|
@@ -201,6 +202,7 @@ function providerDraftFromWire(provider: WireProvider): ProviderDraft {
|
|
|
201
202
|
timeoutMs: numToText(provider.timeoutMs),
|
|
202
203
|
websocketConnectTimeoutMs: numToText(provider.websocketConnectTimeoutMs),
|
|
203
204
|
streamIdleTimeoutMs: numToText(provider.streamIdleTimeoutMs),
|
|
205
|
+
maxRequestImageBytes: numToText(provider.maxRequestImageBytes),
|
|
204
206
|
retryPolicy: provider.retryPolicy,
|
|
205
207
|
models: (provider.models ?? []).map(modelDraftFromWire),
|
|
206
208
|
}
|
|
@@ -225,6 +227,7 @@ function providerToWire(provider: ProviderDraft): WireProvider {
|
|
|
225
227
|
timeoutMs: toNum(provider.timeoutMs),
|
|
226
228
|
websocketConnectTimeoutMs: toNum(provider.websocketConnectTimeoutMs),
|
|
227
229
|
streamIdleTimeoutMs: toNum(provider.streamIdleTimeoutMs),
|
|
230
|
+
maxRequestImageBytes: toNum(provider.maxRequestImageBytes),
|
|
228
231
|
retryPolicy: provider.retryPolicy,
|
|
229
232
|
models: provider.models.map(modelToWire),
|
|
230
233
|
}) as WireProvider
|
|
@@ -249,6 +252,7 @@ export function emptyProviderDraft(): ProviderDraft {
|
|
|
249
252
|
timeoutMs: '',
|
|
250
253
|
websocketConnectTimeoutMs: '',
|
|
251
254
|
streamIdleTimeoutMs: '',
|
|
255
|
+
maxRequestImageBytes: '',
|
|
252
256
|
retryPolicy: undefined,
|
|
253
257
|
models: [],
|
|
254
258
|
}
|
package/src/client/i18n.ts
CHANGED
|
@@ -50,6 +50,7 @@ export const zh: Record<string, string> = {
|
|
|
50
50
|
timeoutMs: 'HTTP 超时(毫秒)',
|
|
51
51
|
websocketConnectTimeoutMs: 'WebSocket 连接超时(毫秒)',
|
|
52
52
|
streamIdleTimeoutMs: '流空闲超时(毫秒)',
|
|
53
|
+
maxRequestImageBytes: '单请求图片载荷上限(字节,缺省 20MiB)',
|
|
53
54
|
headers: '请求头',
|
|
54
55
|
headersHint: '键值对;键为空的整行会被忽略。',
|
|
55
56
|
key: '键',
|
|
@@ -139,6 +140,7 @@ export const en: Record<string, string> = {
|
|
|
139
140
|
timeoutMs: 'HTTP timeout (ms)',
|
|
140
141
|
websocketConnectTimeoutMs: 'WebSocket connect timeout (ms)',
|
|
141
142
|
streamIdleTimeoutMs: 'Stream idle timeout (ms)',
|
|
143
|
+
maxRequestImageBytes: 'Max image payload per request (bytes, default 20MiB)',
|
|
142
144
|
headers: 'Request headers',
|
|
143
145
|
headersHint: 'Key/value pairs; rows with an empty key are ignored.',
|
|
144
146
|
key: 'Key',
|
package/src/client/scope.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 浏览器半 settingsScope/connection 的最小本地接口声明。
|
|
3
3
|
* 只声明本插件用到的窄面,避免为构建期类型引入整条官方 client 依赖树;
|
|
4
|
-
* 运行时契约以官方 dsh-client-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* 运行时契约以官方 dsh-client-connection 的 settings RPC 面为准
|
|
5
|
+
* (rc7:白名单已移除,任何已注册命名空间均可 describe/update/replace)。
|
|
6
|
+
*
|
|
7
|
+
* 实现说明:本插件不复用 settingsScope 服务的 bind()——它在非 loopback
|
|
8
|
+
* 页面(如经 tailnet 域名访问)下走 memory 模式、永远无数据;这里按官方
|
|
9
|
+
* 配置页 tab 的同款模式用 `api.settings` 直连实现 Scope(describe 读 +
|
|
10
|
+
* remote `settings/document-updated` / `connection/reset` 刷新,见 client.ts)。
|
|
11
|
+
* @module {pkg}/client/scope
|
|
8
12
|
*/
|
|
9
13
|
|
|
10
14
|
/** settings 命名空间 scope 的快照(官方 SettingsScopeSnapshot 的最小投影)。 */
|
|
@@ -27,7 +31,7 @@ export interface Scope {
|
|
|
27
31
|
|
|
28
32
|
/** connection api.settings 的 RPC 面(本插件用到的三个方法)。 */
|
|
29
33
|
export interface SettingsApi {
|
|
30
|
-
describe(): Promise<{ result: { ok: boolean; value?: { namespaces: Array<{ ns: string; secrets: Array<{ path: string[]; set: boolean }> }> }; error?: { message?: string } } }>
|
|
34
|
+
describe(payload?: Record<string, never>): Promise<{ result: { ok: boolean; value?: { namespaces: Array<{ ns: string; secrets: Array<{ path: string[]; set: boolean }> }> }; error?: { message?: string } } }>
|
|
31
35
|
update(request: { ns: string; patch: Record<string, unknown>; expectedRevision?: number }): Promise<{ result: { ok: boolean; error?: { message?: string } } }>
|
|
32
36
|
replace(request: { ns: string; section: Record<string, unknown>; expectedRevision?: number }): Promise<{ result: { ok: boolean; error?: { message?: string } } }>
|
|
33
37
|
}
|
|
@@ -96,6 +96,14 @@ export function ProviderScalarFields(props: ProviderScalarFieldsProps): ReactEle
|
|
|
96
96
|
disabled={props.disabled === true}
|
|
97
97
|
onEdit={(value) => props.onPatch({ streamIdleTimeoutMs: value })}
|
|
98
98
|
/>
|
|
99
|
+
<TextField
|
|
100
|
+
id={`${props.id}-maxImageBytes`}
|
|
101
|
+
label={t('maxRequestImageBytes')}
|
|
102
|
+
numeric
|
|
103
|
+
value={draft.maxRequestImageBytes}
|
|
104
|
+
disabled={props.disabled === true}
|
|
105
|
+
onEdit={(value) => props.onPatch({ maxRequestImageBytes: value })}
|
|
106
|
+
/>
|
|
99
107
|
<div className="lpc-field">
|
|
100
108
|
<span className="lpc-label">{t('defaultInput')}</span>
|
|
101
109
|
{MODALITIES.map((modality) => (
|
package/src/config.ts
CHANGED
|
@@ -28,6 +28,9 @@ export const MODALITIES = ['text', 'image'] as const
|
|
|
28
28
|
export const DEFAULT_CONTEXT_WINDOW = 262144
|
|
29
29
|
export const DEFAULT_MAX_TOKENS = 32768
|
|
30
30
|
export const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000
|
|
31
|
+
/** 单请求 base64 图片载荷上限(rc8 起官方 ResolvedPiAiProviderProfile 必需字段;
|
|
32
|
+
* 缺省取官方默认 20MiB,旧配置无需改动即自动生效)。 */
|
|
33
|
+
export const DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024
|
|
31
34
|
/** dsh-timeout 的定时器上限(与官方 MAX_TIMER_DELAY_MS 对齐)。 */
|
|
32
35
|
export const MAX_TIMER_DELAY_MS = 2 ** 31 - 1
|
|
33
36
|
|
|
@@ -69,6 +72,7 @@ export interface ProviderProfileConfig {
|
|
|
69
72
|
timeoutMs?: number
|
|
70
73
|
websocketConnectTimeoutMs?: number
|
|
71
74
|
streamIdleTimeoutMs?: number
|
|
75
|
+
maxRequestImageBytes?: number
|
|
72
76
|
retryPolicy?: unknown
|
|
73
77
|
models?: ModelEntryConfig[]
|
|
74
78
|
}
|
|
@@ -138,6 +142,9 @@ const providerProfile = z.object({
|
|
|
138
142
|
.min(Number.MIN_VALUE)
|
|
139
143
|
.max(MAX_TIMER_DELAY_MS)
|
|
140
144
|
.description('单支流式读取的最大空闲间隔毫秒'),
|
|
145
|
+
maxRequestImageBytes: z
|
|
146
|
+
.natural()
|
|
147
|
+
.description('单请求 base64 图片载荷上限字节;缺省 20MiB(rc8 起生效,旧配置免改)'),
|
|
141
148
|
retryPolicy: z.any().description('provider 重试策略(dsh-llm RetryPolicy 形状,构建期校验)'),
|
|
142
149
|
models: z.array(modelEntry).description('本 route 的模型目录;缺省且 provider 有 extends 时继承该源全部模型'),
|
|
143
150
|
})
|
package/src/profiles.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { mergeCompat, validateCompat } from './compat.ts'
|
|
|
20
20
|
import {
|
|
21
21
|
DEFAULT_CONTEXT_WINDOW,
|
|
22
22
|
DEFAULT_MAX_TOKENS,
|
|
23
|
+
DEFAULT_MAX_REQUEST_IMAGE_BYTES,
|
|
23
24
|
DEFAULT_STREAM_IDLE_TIMEOUT_MS,
|
|
24
25
|
MAX_TIMER_DELAY_MS,
|
|
25
26
|
THINKING_LEVELS,
|
|
@@ -311,6 +312,7 @@ export function buildProfiles(
|
|
|
311
312
|
displayName,
|
|
312
313
|
...(profile.apiKeyEnv === undefined ? {} : { apiKeyEnv: credentialRef(profile.apiKeyEnv) }),
|
|
313
314
|
streamIdleTimeoutMs,
|
|
315
|
+
maxRequestImageBytes: profile.maxRequestImageBytes ?? DEFAULT_MAX_REQUEST_IMAGE_BYTES,
|
|
314
316
|
retryPolicy: deps.kit.resolveRetryPolicy(
|
|
315
317
|
profile.retryPolicy as Parameters<DshKit['resolveRetryPolicy']>[0],
|
|
316
318
|
`llm-pi: provider "${route}" retryPolicy`,
|