@fa-software/semi2-dsh 0.0.19-preview.20261010083605 → 0.0.19
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/api/http-models.js
CHANGED
|
@@ -64,6 +64,8 @@ export function decodeModel(value) {
|
|
|
64
64
|
defaultReasoningLevel: reasoning(model.defaultReasoningLevel),
|
|
65
65
|
connection: {
|
|
66
66
|
id: string(connection.id),
|
|
67
|
+
// 连接名可缺席(对端尚未下发):按未命名处理,不让整段模型目录降级。
|
|
68
|
+
displayName: connection.displayName == null ? null : string(connection.displayName),
|
|
67
69
|
provider: nullableString(connection.provider),
|
|
68
70
|
protocol: protocol(connection.protocol),
|
|
69
71
|
baseUrl: string(connection.baseUrl),
|
package/lib/hub/compile.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export const
|
|
1
|
+
/** hub 下发的 provider 显示名前缀:`semi2-<连接名>`。 */
|
|
2
|
+
export const HUB_PROVIDER_NAME_PREFIX = 'semi2-';
|
|
3
|
+
/** 连接名缺席(对端未下发)时的显示名回落。 */
|
|
4
|
+
export const HUB_PROVIDER_FALLBACK_NAME = 'semi2-hub';
|
|
3
5
|
/** 路由键必须留 hex——协议路由与 `agent-default-model` 都引用它。 */
|
|
4
6
|
export function connectionRoute(connectionId) {
|
|
5
7
|
return `semi2-${connectionId.replaceAll('-', '')}`;
|
|
@@ -18,6 +20,14 @@ export function connectionProviderName(connection) {
|
|
|
18
20
|
return 'deepseek-official';
|
|
19
21
|
return connection.provider ?? connectionRoute(connection.id);
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* hub 下发的 provider 在 dsh 里的显示名:`semi2-<连接名>`,连接名缺席取回落名。
|
|
25
|
+
* 只影响选择器与设置面;路由键(协议路由与 `agent-default-model` 的引用)不受它影响。
|
|
26
|
+
*/
|
|
27
|
+
export function hubProviderDisplayName(connection) {
|
|
28
|
+
const name = connection.displayName?.trim() ?? '';
|
|
29
|
+
return name === '' ? HUB_PROVIDER_FALLBACK_NAME : `${HUB_PROVIDER_NAME_PREFIX}${name}`;
|
|
30
|
+
}
|
|
21
31
|
/** 密钥的进程 env 名(= dsh credentials 引用名)。 */
|
|
22
32
|
export function connectionApiKeyEnv(connectionId) {
|
|
23
33
|
return `SEMI2_MODEL_KEY_${connectionId.replaceAll('-', '').toUpperCase()}`;
|
|
@@ -86,14 +96,14 @@ function selectionOf(model) {
|
|
|
86
96
|
* `/api`、其余在 `/api/v1`);hub 的预设地址就是目录地址,交给目录逐模型给。
|
|
87
97
|
* 于是 compat / headers / cost / thinkingLevelMap 全部沿用 dsh 目录里的值。
|
|
88
98
|
*/
|
|
89
|
-
function presetProvider(
|
|
99
|
+
function presetProvider(connection, models) {
|
|
90
100
|
return {
|
|
91
101
|
preset: true,
|
|
92
102
|
connectionId: connection.id,
|
|
93
103
|
api: protocolApi(connection.protocol),
|
|
94
104
|
baseURL: connection.baseUrl,
|
|
95
105
|
apiKeyEnv: connectionApiKeyEnv(connection.id),
|
|
96
|
-
displayName:
|
|
106
|
+
displayName: hubProviderDisplayName(connection),
|
|
97
107
|
models: models.map(model => ({
|
|
98
108
|
id: model.upstreamId,
|
|
99
109
|
name: modelName(model),
|
|
@@ -149,7 +159,7 @@ export function compileBoot(models, defaultModelId) {
|
|
|
149
159
|
api: protocolApi(model.connection.protocol),
|
|
150
160
|
baseURL: model.connection.baseUrl,
|
|
151
161
|
apiKeyEnv: connectionApiKeyEnv(model.connection.id),
|
|
152
|
-
displayName:
|
|
162
|
+
displayName: hubProviderDisplayName(model.connection),
|
|
153
163
|
models: [],
|
|
154
164
|
});
|
|
155
165
|
provider.models.push({
|
|
@@ -162,7 +172,7 @@ export function compileBoot(models, defaultModelId) {
|
|
|
162
172
|
});
|
|
163
173
|
}
|
|
164
174
|
for (const [route, bucket] of presetConnections)
|
|
165
|
-
providers[route] = presetProvider(
|
|
175
|
+
providers[route] = presetProvider(bucket.connection, bucket.models);
|
|
166
176
|
const defaultModel = defaultModelId === null ? null : (selections.get(defaultModelId) ?? null);
|
|
167
177
|
return { providers, deepseek, defaultModel, selections };
|
|
168
178
|
}
|
|
@@ -13,6 +13,7 @@ export declare function decodeModel(value: unknown): {
|
|
|
13
13
|
defaultReasoningLevel: "OFF" | "MINIMAL" | "LOW" | "MEDIUM" | "HIGH" | "XHIGH" | "MAX" | null;
|
|
14
14
|
connection: {
|
|
15
15
|
id: string;
|
|
16
|
+
displayName: string | null;
|
|
16
17
|
provider: string | null;
|
|
17
18
|
protocol: "DEEPSEEK" | "OPENAI_CHAT" | "OPENAI_RESPONSES" | "ANTHROPIC";
|
|
18
19
|
baseUrl: string;
|
|
@@ -36,6 +37,7 @@ export declare function decodeModelConfiguration(value: unknown): {
|
|
|
36
37
|
defaultReasoningLevel: "OFF" | "MINIMAL" | "LOW" | "MEDIUM" | "HIGH" | "XHIGH" | "MAX" | null;
|
|
37
38
|
connection: {
|
|
38
39
|
id: string;
|
|
40
|
+
displayName: string | null;
|
|
39
41
|
provider: string | null;
|
|
40
42
|
protocol: "DEEPSEEK" | "OPENAI_CHAT" | "OPENAI_RESPONSES" | "ANTHROPIC";
|
|
41
43
|
baseUrl: string;
|
|
@@ -11,8 +11,10 @@ export type RuntimeModelCredential = NonNullable<BootFacts['runtimeModelCredenti
|
|
|
11
11
|
export type { InputModality, ModelProtocol, ReasoningLevel };
|
|
12
12
|
/** dsh 通用 provider 的 api 适配器(`llm-pi-ai.providers[].api`)。 */
|
|
13
13
|
export type ProviderApi = 'openai-completions' | 'openai-responses' | 'anthropic-messages';
|
|
14
|
-
/**
|
|
15
|
-
export declare const
|
|
14
|
+
/** hub 下发的 provider 显示名前缀:`semi2-<连接名>`。 */
|
|
15
|
+
export declare const HUB_PROVIDER_NAME_PREFIX = "semi2-";
|
|
16
|
+
/** 连接名缺席(对端未下发)时的显示名回落。 */
|
|
17
|
+
export declare const HUB_PROVIDER_FALLBACK_NAME = "semi2-hub";
|
|
16
18
|
/** 路由键必须留 hex——协议路由与 `agent-default-model` 都引用它。 */
|
|
17
19
|
export declare function connectionRoute(connectionId: string): string;
|
|
18
20
|
/**
|
|
@@ -25,6 +27,11 @@ export declare function connectionRoute(connectionId: string): string;
|
|
|
25
27
|
* DEEPSEEK 协议走内置原生适配器(独立于 pi-ai 目录),与预设/自定义无关。
|
|
26
28
|
*/
|
|
27
29
|
export declare function connectionProviderName(connection: RuntimeConnection): string;
|
|
30
|
+
/**
|
|
31
|
+
* hub 下发的 provider 在 dsh 里的显示名:`semi2-<连接名>`,连接名缺席取回落名。
|
|
32
|
+
* 只影响选择器与设置面;路由键(协议路由与 `agent-default-model` 的引用)不受它影响。
|
|
33
|
+
*/
|
|
34
|
+
export declare function hubProviderDisplayName(connection: RuntimeConnection): string;
|
|
28
35
|
/** 密钥的进程 env 名(= dsh credentials 引用名)。 */
|
|
29
36
|
export declare function connectionApiKeyEnv(connectionId: string): string;
|
|
30
37
|
export declare function protocolApi(protocol: ModelProtocol): ProviderApi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fa-software/semi2-dsh",
|
|
3
|
-
"version": "0.0.19
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Semi2 单插件:semi2-hub 配置引导 + 公共 Web 能力。",
|
|
5
5
|
"homepage": "https://cnb.cool/fa-software/semi2/dsh/dsh-mono",
|
|
6
6
|
"bugs": "https://cnb.cool/fa-software/semi2/dsh/dsh-mono/-/issues",
|