pi-model-manager 0.4.7 → 0.4.9
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.en.md +4 -1
- package/README.md +4 -1
- package/package.json +1 -1
- package/presets/builtin-client-headers.ts +3 -3
- package/presets/providers.ts +3 -4
- package/presets/thinking.ts +23 -17
- package/provider-transport.ts +42 -4
- package/runtime-base-url.ts +11 -0
- package/state-document.ts +2 -1
- package/state-store.ts +1 -1
- package/tui/editor-provider.ts +2 -2
package/README.en.md
CHANGED
|
@@ -132,6 +132,7 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
|
|
|
132
132
|
- Fetch model IDs from compatible upstream APIs or enter them manually.
|
|
133
133
|
- Configure context window, maximum output, vision support, and reasoning support.
|
|
134
134
|
- Choose Anthropic Adaptive Thinking or Legacy Thinking.
|
|
135
|
+
- New level-based Gemini models expose `minimal / low / medium / high / xhigh / max` by default and send the matching uppercase value; support is determined by the upstream service. Budget-based Gemini models retain native levels and token budgets. Existing explicit level mappings and disabled levels are not automatically rewritten.
|
|
135
136
|
- Select Standard, Fast (`priority`), or Ultrafast (`ultrafast`) service tiers per OpenAI Responses model.
|
|
136
137
|
- Route each provider directly or through its own HTTP(S) proxy.
|
|
137
138
|
- Use recommended, disabled, Claude Code, Codex, or custom client-header profiles.
|
|
@@ -205,7 +206,9 @@ Each provider can define:
|
|
|
205
206
|
|
|
206
207
|
When adding a model, the extension attempts to fetch the upstream model list. The complete discovery flow shares one 10-second limit and can be cancelled with `Esc`. Discovery uses the same API root and configured credentials as chat, and distinguishes authentication failures, missing endpoints, rate limits, and upstream errors. You can still enter a model ID manually after failure or cancellation.
|
|
207
208
|
|
|
208
|
-
Base URL represents the API root
|
|
209
|
+
Base URL represents the API root, to which the protocol endpoint is appended. For example, Anthropic with `https://gw.example.com/xxx` uses `/xxx/messages` for chat and `/xxx/models` for discovery. When entering a URL or switching protocols in the provider editor, a bare domain gets `/v1` for OpenAI / Anthropic or `/v1beta` for Gemini, including custom gateway domains. Gemini converts a final `/v1` path segment to `/v1beta`; switching from Gemini back to OpenAI / Anthropic converts a final `/v1beta` to `/v1`. The host, port, and path prefix are preserved, as are other explicit paths such as `/custom`, `/v1alpha`, and `/v2`.
|
|
210
|
+
|
|
211
|
+
The converted URL appears immediately in the form and, once saved, is shared by chat and model discovery. This version conversion only runs during those configuration actions: it does not migrate unedited URLs or rewrite model-specific endpoints or unmanaged native providers. Base URLs cannot contain query parameters (`?`), fragments (`#`), or embedded credentials; parameters generated by the SDK remain supported.
|
|
209
212
|
|
|
210
213
|
Standard Anthropic endpoints are converted to Pi's native SDK representation in `models.json`, so they also work without the extension. Custom version paths use private `state.json` metadata and require the extension's transport adapter. Toggling the proxy changes only the transport route, preserving the final endpoint, application headers, and payload. Proxy failures are reported.
|
|
211
214
|
|
package/README.md
CHANGED
|
@@ -132,6 +132,7 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
|
|
|
132
132
|
- 从兼容上游拉取模型 ID,也可手动填写模型。
|
|
133
133
|
- 配置上下文窗口、最大输出、视觉支持和 Thinking。
|
|
134
134
|
- 支持 Anthropic Adaptive Thinking 与 Legacy Thinking。
|
|
135
|
+
- 等级制 Gemini 的新模型默认开放 `minimal / low / medium / high / xhigh / max`,按同名值发送(按协议转为大写),是否支持由上游判断;预算制 Gemini 保留原生档位与 token 预算规则。已有显式档位映射和禁用配置不会自动重写。
|
|
135
136
|
- 为 OpenAI Responses 模型选择标准、Fast(`priority`)或 Ultrafast(`ultrafast`)速度档位。
|
|
136
137
|
- 为每个接入单独配置直连或 HTTP(S) 代理。
|
|
137
138
|
- 提供自动推荐、禁用、Claude Code、Codex 和自定义请求头模式。
|
|
@@ -207,7 +208,9 @@ pi install npm:pi-model-manager
|
|
|
207
208
|
|
|
208
209
|
新建模型时,扩展会尝试从上游读取模型列表;整次发现共用一个 10 秒上限,可按 `Esc` 手动取消。列表与聊天使用同一 API 根地址和配置的认证信息,错误会区分认证失败、接口不存在、限流和上游异常。失败或取消后仍可手动输入模型 ID。
|
|
209
210
|
|
|
210
|
-
Base URL 表示 API
|
|
211
|
+
Base URL 表示 API 根地址,再追加协议端点。例如 Anthropic 的 `https://gw.example.com/xxx` 请求 `/xxx/messages`,模型列表请求 `/xxx/models`。在接入编辑器中输入地址或切换协议时,只填域名会按协议补 `/v1`(OpenAI / Anthropic)或 `/v1beta`(Gemini,包括自定义中转域名)。Gemini 会将末尾完整路径段 `/v1` 转为 `/v1beta`;从 Gemini 切回 OpenAI / Anthropic 时,末尾 `/v1beta` 转为 `/v1`。域名、端口和路径前缀保留,其他显式路径(如 `/custom`、`/v1alpha`、`/v2`)不改写。
|
|
212
|
+
|
|
213
|
+
转换后的地址会立即显示在表单中,保存后统一用于聊天和模型列表。此版本转换只发生在上述配置操作中,不自动迁移未编辑的存量地址,也不改写模型级独立地址或未接管的原生接入。Base URL 不支持查询参数(`?`)、片段(`#`)或内嵌认证;SDK 正常生成的请求参数不受影响。
|
|
211
214
|
|
|
212
215
|
Anthropic 标准端点在写入 `models.json` 时转换为 Pi 原生 SDK 所需形式,因此未加载扩展时也能使用;自定义版本路径通过 `state.json` 私有标记衔接,依赖扩展的发送适配。代理开关只改变传输路线,最终端点、业务请求头和 payload 保持一致;代理失败会报错。
|
|
213
216
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-model-manager",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "A TUI model and provider manager for Pi with native models.json persistence, request-header profiles, proxy routing, and protocol compatibility.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
export const CLAUDE_CODE_CLIENT_HEADERS: Record<string, string> = {
|
|
4
4
|
"anthropic-dangerous-direct-browser-access": "true",
|
|
5
5
|
"anthropic-version": "2023-06-01",
|
|
6
|
-
"user-agent": "claude-cli/2.1.
|
|
6
|
+
"user-agent": "claude-cli/2.1.332 (external, sdk-cli)",
|
|
7
7
|
"x-app": "cli",
|
|
8
8
|
"x-stainless-arch": "x64",
|
|
9
9
|
"x-stainless-lang": "js",
|
|
@@ -17,6 +17,6 @@ export const CLAUDE_CODE_CLIENT_HEADERS: Record<string, string> = {
|
|
|
17
17
|
|
|
18
18
|
export const CODEX_CLI_CLIENT_HEADERS: Record<string, string> = {
|
|
19
19
|
"originator": "codex_cli_rs",
|
|
20
|
-
"user-agent": "codex_cli_rs/0.
|
|
21
|
-
"version": "0.
|
|
20
|
+
"user-agent": "codex_cli_rs/0.172.0 (Windows 10.0.26100; x86_64) unknown",
|
|
21
|
+
"version": "0.172.0",
|
|
22
22
|
};
|
package/presets/providers.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 4 种 API 协议的默认预设。新建接入/模型时用,便于一键填好常用字段。
|
|
2
2
|
|
|
3
3
|
import type { ApiKind, ModelInputKind, ProviderDraft } from "../types.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveProviderDraftBaseUrl } from "../runtime-base-url.ts";
|
|
5
5
|
|
|
6
6
|
export interface ProviderPreset {
|
|
7
7
|
api: ApiKind;
|
|
@@ -103,10 +103,9 @@ export function switchProviderDraftApiPreset(draft: ProviderDraft, nextApi: ApiK
|
|
|
103
103
|
if (nextApi === "openai-completions" && draft.openAIChatCompatibilityMode === undefined) {
|
|
104
104
|
draft.openAIChatCompatibilityMode = "standard";
|
|
105
105
|
}
|
|
106
|
-
// [喵喵喵]:
|
|
107
|
-
// 保留的自定义地址必须按新协议重新归一化,否则切完协议就指向错误端点。
|
|
106
|
+
// [喵喵喵]: 自定义地址只在草稿阶段按目标协议转换版本后缀,避免运行时改写存量配置。
|
|
108
107
|
try {
|
|
109
|
-
draft.baseUrl = replaceBaseUrl ? nextPreset.baseUrl :
|
|
108
|
+
draft.baseUrl = replaceBaseUrl ? nextPreset.baseUrl : resolveProviderDraftBaseUrl(nextApi, draft.baseUrl, previousPreset.api);
|
|
110
109
|
} catch {
|
|
111
110
|
draft.baseUrl = nextPreset.baseUrl;
|
|
112
111
|
}
|
package/presets/thinking.ts
CHANGED
|
@@ -16,8 +16,8 @@ const OPENAI_THINKING_LEVEL_MAP: ThinkingLevelMap = {
|
|
|
16
16
|
max: "max",
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
const
|
|
19
|
+
// 预算制模型保留原生档位与 token 预算规则。
|
|
20
|
+
const GOOGLE_BUDGET_THINKING_LEVEL_MAP: ThinkingLevelMap = {
|
|
21
21
|
minimal: "minimal",
|
|
22
22
|
low: "low",
|
|
23
23
|
medium: "medium",
|
|
@@ -26,6 +26,17 @@ const GOOGLE_GENERATIVE_AI_THINKING_LEVEL_MAP: ThinkingLevelMap = {
|
|
|
26
26
|
max: null,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
export function usesGoogleThinkingLevel(modelId: string): boolean {
|
|
30
|
+
const id = modelId.toLowerCase();
|
|
31
|
+
const major = Number(id.match(/gemini(?:-live)?-(\d+)/)?.[1] ?? 0);
|
|
32
|
+
// [喵喵喵]: 与 Pi 的 Google wire-format 分类一致;只区分等级制/预算制,不判断各模型支持哪些档位。
|
|
33
|
+
return /gemini-3(?:\.\d+)?-(?:pro|flash)/.test(id)
|
|
34
|
+
|| major >= 4
|
|
35
|
+
|| id === "gemini-flash-latest"
|
|
36
|
+
|| id === "gemini-flash-lite-latest"
|
|
37
|
+
|| /gemma-?4/.test(id);
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
function isLegacyShiftedMaxLadder(map: ThinkingLevelMap): boolean {
|
|
30
41
|
return map.minimal === "low"
|
|
31
42
|
&& map.low === "medium"
|
|
@@ -35,22 +46,16 @@ function isLegacyShiftedMaxLadder(map: ThinkingLevelMap): boolean {
|
|
|
35
46
|
&& map.max === undefined;
|
|
36
47
|
}
|
|
37
48
|
|
|
38
|
-
function buildThinkingLevelMap(api: ApiKind, reasoning: boolean): ThinkingLevelMap | undefined {
|
|
49
|
+
function buildThinkingLevelMap(api: ApiKind, reasoning: boolean, modelId: string): ThinkingLevelMap | undefined {
|
|
39
50
|
if (!reasoning) return undefined;
|
|
40
|
-
if (api === "google-generative-ai") return { ...GOOGLE_GENERATIVE_AI_THINKING_LEVEL_MAP };
|
|
41
|
-
if (api === "openai-completions" || api === "openai-responses") return { ...OPENAI_THINKING_LEVEL_MAP };
|
|
42
|
-
return { ...EXTENDED_THINKING_LEVEL_MAP };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function applyProtocolThinkingLevelLimits(
|
|
46
|
-
api: ApiKind,
|
|
47
|
-
thinkingLevelMap: ThinkingLevelMap | undefined,
|
|
48
|
-
): ThinkingLevelMap | undefined {
|
|
49
51
|
if (api === "google-generative-ai") {
|
|
50
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
...GOOGLE_BUDGET_THINKING_LEVEL_MAP,
|
|
54
|
+
...(usesGoogleThinkingLevel(modelId) ? EXTENDED_THINKING_LEVEL_MAP : {}),
|
|
55
|
+
};
|
|
51
56
|
}
|
|
52
|
-
if (
|
|
53
|
-
return { ...EXTENDED_THINKING_LEVEL_MAP
|
|
57
|
+
if (api === "openai-completions" || api === "openai-responses") return { ...OPENAI_THINKING_LEVEL_MAP };
|
|
58
|
+
return { ...EXTENDED_THINKING_LEVEL_MAP };
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
function mergeThinkingLevelMap(
|
|
@@ -65,9 +70,10 @@ export function normalizeThinkingLevelMap(
|
|
|
65
70
|
api: ApiKind,
|
|
66
71
|
reasoning: boolean,
|
|
67
72
|
storedMap: ThinkingLevelMap | undefined,
|
|
73
|
+
modelId: string,
|
|
68
74
|
): ThinkingLevelMap | undefined {
|
|
69
75
|
if (!reasoning) return undefined;
|
|
70
|
-
const defaultMap = buildThinkingLevelMap(api, true);
|
|
76
|
+
const defaultMap = buildThinkingLevelMap(api, true, modelId);
|
|
71
77
|
if (storedMap && isLegacyShiftedMaxLadder(storedMap)) return defaultMap;
|
|
72
|
-
return
|
|
78
|
+
return mergeThinkingLevelMap(defaultMap, storedMap);
|
|
73
79
|
}
|
package/provider-transport.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// 在 Pi 已构造请求后选择传输路线;协议判断始终使用真实网关地址。
|
|
2
2
|
|
|
3
3
|
import { lazyStream, type Provider } from "@earendil-works/pi-ai";
|
|
4
|
+
import { isObjectRecord } from "./common.ts";
|
|
4
5
|
import { getClaudeCodeSessionId } from "./claude-code-compat.ts";
|
|
5
6
|
import { applyCodexRequestHeaders } from "./codex-compat.ts";
|
|
6
7
|
import { mergeModelRequestHeaders, resolveClientHeaderProfile } from "./presets/client-headers.ts";
|
|
8
|
+
import { usesGoogleThinkingLevel } from "./presets/thinking.ts";
|
|
7
9
|
import { t } from "./i18n.ts";
|
|
8
10
|
import { getProviderHttpProxyUrl, openTemporaryLocalProxyRoute } from "./local-proxy-service.ts";
|
|
9
11
|
import { appendUrlPath, resolveRuntimeBaseUrl, validateRequestBaseUrl } from "./runtime-base-url.ts";
|
|
@@ -101,15 +103,51 @@ export function createProviderTransport(native: Provider, provider: StoredProvid
|
|
|
101
103
|
}));
|
|
102
104
|
const proxyUrl = provider.httpProxyEnabled ? getProviderHttpProxyUrl(provider) : undefined;
|
|
103
105
|
|
|
104
|
-
const wrap = (stream: Provider["streamSimple"]): Provider["streamSimple"] => (model, context, options) => lazyStream(model, async () => {
|
|
106
|
+
const wrap = (stream: Provider["streamSimple"], simple: boolean): Provider["streamSimple"] => (model, context, options) => lazyStream(model, async () => {
|
|
105
107
|
const endpoint = endpoints.get(model.id);
|
|
106
108
|
if (!endpoint || endpoint.api !== model.api) throw new Error(t("请求模型不属于当前接入配置:{modelId}", { modelId: model.id }));
|
|
107
109
|
validateRequestBaseUrl(endpoint.baseUrl);
|
|
108
110
|
// [喵喵喵]: models.json 已保存完整模型头,由宿主在 transformHeaders 前解析;发送层不能再次合并配置而复活被删除的头。
|
|
109
111
|
options = { ...options };
|
|
110
112
|
// [喵喵喵]: models.json 会叠加在动态 provider 之上;还原用户侧 API 根地址,不能让原生持久化形式参与路径拼接。
|
|
111
|
-
|
|
113
|
+
let upstreamModel = { ...model, baseUrl: endpoint.baseUrl };
|
|
112
114
|
if (model.api === "google-generative-ai") {
|
|
115
|
+
if (simple && model.reasoning && options.reasoning && usesGoogleThinkingLevel(model.id)
|
|
116
|
+
&& model.thinkingLevelMap?.[options.reasoning] !== null) {
|
|
117
|
+
const level = options.reasoning;
|
|
118
|
+
const mappedLevel = model.thinkingLevelMap?.[level] ?? level;
|
|
119
|
+
const originalOptions = options;
|
|
120
|
+
const restoreModel = (requestModel: typeof model) => ({
|
|
121
|
+
...requestModel,
|
|
122
|
+
reasoning: model.reasoning,
|
|
123
|
+
samplingParamsByThinkingLevel: model.samplingParamsByThinkingLevel,
|
|
124
|
+
});
|
|
125
|
+
const { reasoning: _reasoning, ...nativeOptions } = options;
|
|
126
|
+
// [喵喵喵]: 禁用原生档位转换而非借用低档位;通用限额仍由 streamSimple 计算,采样参数按真实选择预先合并。
|
|
127
|
+
upstreamModel = { ...upstreamModel, reasoning: false, samplingParamsByThinkingLevel: undefined };
|
|
128
|
+
options = {
|
|
129
|
+
...nativeOptions,
|
|
130
|
+
samplingParams: {
|
|
131
|
+
...model.samplingParams,
|
|
132
|
+
...model.samplingParamsByThinkingLevel?.[level],
|
|
133
|
+
...options.samplingParams,
|
|
134
|
+
},
|
|
135
|
+
async onPayload(payload, requestModel) {
|
|
136
|
+
if (!isObjectRecord(payload) || !isObjectRecord(payload.config)) {
|
|
137
|
+
throw new Error("Google request payload is missing its config object");
|
|
138
|
+
}
|
|
139
|
+
payload.config.thinkingConfig = { includeThoughts: true, thinkingLevel: mappedLevel.toUpperCase() };
|
|
140
|
+
// [喵喵喵]: 先提供最终档位,再调用原有钩子;钩子的替换、修改和拒绝都保留。
|
|
141
|
+
return originalOptions.onPayload?.(payload, restoreModel(requestModel));
|
|
142
|
+
},
|
|
143
|
+
onResponse: originalOptions.onResponse
|
|
144
|
+
? (response, requestModel) => originalOptions.onResponse!(response, restoreModel(requestModel))
|
|
145
|
+
: undefined,
|
|
146
|
+
onProviderStreamEvent: originalOptions.onProviderStreamEvent
|
|
147
|
+
? (event, requestModel) => originalOptions.onProviderStreamEvent!(event, restoreModel(requestModel))
|
|
148
|
+
: undefined,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
113
151
|
// [喵喵喵]: Google 适配器先按精确键拼入默认 User-Agent,再构造 Headers;使用该拼写才能覆盖而不是合并成两个值。
|
|
114
152
|
if (options.headers?.["user-agent"] !== undefined) {
|
|
115
153
|
const { "user-agent": userAgent, ...headers } = options.headers;
|
|
@@ -203,7 +241,7 @@ export function createProviderTransport(native: Provider, provider: StoredProvid
|
|
|
203
241
|
|
|
204
242
|
return {
|
|
205
243
|
...native,
|
|
206
|
-
stream: wrap(native.stream.bind(native)) as Provider["stream"],
|
|
207
|
-
streamSimple: wrap(native.streamSimple.bind(native)),
|
|
244
|
+
stream: wrap(native.stream.bind(native), false) as Provider["stream"],
|
|
245
|
+
streamSimple: wrap(native.streamSimple.bind(native), true),
|
|
208
246
|
};
|
|
209
247
|
}
|
package/runtime-base-url.ts
CHANGED
|
@@ -39,6 +39,17 @@ export function resolveRuntimeBaseUrl(api: ApiKind, baseUrl: string): string {
|
|
|
39
39
|
return formatUrl(url);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/** 仅用于主动编辑地址或切换协议;运行时和启动迁移必须保留显式版本路径。 */
|
|
43
|
+
export function resolveProviderDraftBaseUrl(api: ApiKind, baseUrl: string, previousApi?: ApiKind): string {
|
|
44
|
+
const url = new URL(resolveRuntimeBaseUrl(api, baseUrl));
|
|
45
|
+
if (api === "google-generative-ai") {
|
|
46
|
+
url.pathname = url.pathname === "/" ? "/v1beta" : url.pathname.replace(/\/v1$/, "/v1beta");
|
|
47
|
+
} else if (previousApi === "google-generative-ai") {
|
|
48
|
+
url.pathname = url.pathname.replace(/\/v1beta$/, "/v1");
|
|
49
|
+
}
|
|
50
|
+
return formatUrl(url);
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
/** 标准 Anthropic 根地址存成 SDK 原生形式,自定义版本路径由私有元数据标识。 */
|
|
43
54
|
export function toNativeBaseUrl(api: string, baseUrl: string): { baseUrl: string; anthropicApiRoot?: true } {
|
|
44
55
|
if (api !== "anthropic-messages") return { baseUrl };
|
package/state-document.ts
CHANGED
|
@@ -348,6 +348,7 @@ function keepModelFieldsSupportedByApi(model: StoredModel, providerApi: ApiKind,
|
|
|
348
348
|
effectiveApi,
|
|
349
349
|
next.reasoning,
|
|
350
350
|
providerApiChanged && !normalized.api ? undefined : next.thinkingLevelMap,
|
|
351
|
+
next.id,
|
|
351
352
|
);
|
|
352
353
|
if (thinkingLevelMap) next.thinkingLevelMap = thinkingLevelMap;
|
|
353
354
|
else delete next.thinkingLevelMap;
|
|
@@ -427,7 +428,7 @@ export function buildModelFromDraft(
|
|
|
427
428
|
const compat: CompatSettings = cloneJson(existing?.compat) ?? {};
|
|
428
429
|
const effectiveApi = isApiKind(existing?.api) ? existing.api : draft.api;
|
|
429
430
|
const storedThinkingLevelMap = cloneJson(existing?.thinkingLevelMap);
|
|
430
|
-
const thinkingLevelMap = normalizeThinkingLevelMap(effectiveApi, reasoning, storedThinkingLevelMap);
|
|
431
|
+
const thinkingLevelMap = normalizeThinkingLevelMap(effectiveApi, reasoning, storedThinkingLevelMap, modelId);
|
|
431
432
|
|
|
432
433
|
const next: StoredModel = {
|
|
433
434
|
id: modelId,
|
package/state-store.ts
CHANGED
|
@@ -164,7 +164,7 @@ function buildStoredModelFromModelsJson(
|
|
|
164
164
|
if (nativeHeaders) stored.headers = nativeHeaders;
|
|
165
165
|
if (model.name) stored.name = model.name;
|
|
166
166
|
const storedThinkingLevelMap = model.thinkingLevelMap ? cloneJson(model.thinkingLevelMap) as ThinkingLevelMap : undefined;
|
|
167
|
-
const thinkingLevelMap = normalizeThinkingLevelMap(effectiveApi, stored.reasoning, storedThinkingLevelMap);
|
|
167
|
+
const thinkingLevelMap = normalizeThinkingLevelMap(effectiveApi, stored.reasoning, storedThinkingLevelMap, stored.id);
|
|
168
168
|
if (thinkingLevelMap) stored.thinkingLevelMap = thinkingLevelMap;
|
|
169
169
|
if (modelCompat) stored.compat = modelCompat;
|
|
170
170
|
if (effectiveApi === "openai-responses" && modelMetadata?.openAIServiceTier) {
|
package/tui/editor-provider.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { hasStringRecordEntries } from "../common.ts";
|
|
|
8
8
|
import { t } from "../i18n.ts";
|
|
9
9
|
import { switchProviderDraftApiPreset } from "../presets/providers.ts";
|
|
10
10
|
import { redactUrlForDisplay } from "../sensitive-redaction.ts";
|
|
11
|
-
import {
|
|
11
|
+
import { resolveProviderDraftBaseUrl, validateRequestBaseUrl } from "../runtime-base-url.ts";
|
|
12
12
|
import {
|
|
13
13
|
DEFAULT_PROVIDER_HTTP_PROXY_URL,
|
|
14
14
|
type OpenAIChatCompatibilityMode,
|
|
@@ -296,7 +296,7 @@ async function editField(
|
|
|
296
296
|
// [喵喵喵]: 当场校验并归一化成 SDK 可直接使用的根地址;若输入有误通过通知友好提示,避免未捕获异常导致 TUI 闪退丢失草稿
|
|
297
297
|
try {
|
|
298
298
|
validateRequestBaseUrl(trimmed);
|
|
299
|
-
draft.baseUrl =
|
|
299
|
+
draft.baseUrl = resolveProviderDraftBaseUrl(draft.api, trimmed);
|
|
300
300
|
} catch (error) {
|
|
301
301
|
const message = error instanceof Error ? error.message : String(error);
|
|
302
302
|
ctx.ui.notify(t("Base URL 格式错误:{error}", { error: message }), "warning");
|