custom-provider-pi 0.1.5 → 0.1.6
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/custom-provider.ts +8 -8
- package/package.json +1 -1
package/custom-provider.ts
CHANGED
|
@@ -36,7 +36,7 @@ const UA_PRESETS: Record<string, string> = {
|
|
|
36
36
|
|
|
37
37
|
// 请求头模板(借鉴 LiveAgent:按客户端/CLI 预设整组请求头,而非只预设 UA):
|
|
38
38
|
// 不同客户端携带的头集合不同(Claude Code 有 x-app/anthropic-version/X-Stainless-* 等)。
|
|
39
|
-
//
|
|
39
|
+
// 选模板一次性灌入;选"自定义"逐头输入。
|
|
40
40
|
interface HeaderPreset {
|
|
41
41
|
label: string;
|
|
42
42
|
key?: string; // undefined = 自定义
|
|
@@ -91,8 +91,8 @@ function hasHeader(headers: Record<string, string> | undefined, name: string): b
|
|
|
91
91
|
// ---- 远程规格查询(OpenRouter 公开目录,带磁盘缓存)----
|
|
92
92
|
|
|
93
93
|
// 输出上限处置(借鉴 LiveAgent normalizeModelLimits)
|
|
94
|
-
//
|
|
95
|
-
//
|
|
94
|
+
// 社区目录/中转对不公布独立输出上限的模型常给退化值"输出==窗口",
|
|
95
|
+
// 照单全收会把"窗口−输出预留"的输入预算挤成零。处理:钳到保守上限,
|
|
96
96
|
// 并保底留 3/4 窗口给输入。
|
|
97
97
|
const MAX_OUTPUT_TOKEN_CAP = 32000;
|
|
98
98
|
|
|
@@ -1370,7 +1370,7 @@ export default function customProviderExtension(pi: ExtensionAPI) {
|
|
|
1370
1370
|
|
|
1371
1371
|
// ---- 4. 协议类型 ----
|
|
1372
1372
|
const apiType = await ctx.ui.select(
|
|
1373
|
-
"API
|
|
1373
|
+
"API 协议类型(推荐"自动推断",按 URL 自动识别)",
|
|
1374
1374
|
["自动推断", "openai-completions", "openai-responses", "anthropic-messages", "google-generative-ai"]
|
|
1375
1375
|
);
|
|
1376
1376
|
if (!apiType) return;
|
|
@@ -1438,7 +1438,7 @@ export default function customProviderExtension(pi: ExtensionAPI) {
|
|
|
1438
1438
|
"若服务支持模型列表端点可自动获取;否则将手动输入"
|
|
1439
1439
|
);
|
|
1440
1440
|
|
|
1441
|
-
// ---- 6. 请求头模板(预设整组请求头,不同 CLI
|
|
1441
|
+
// ---- 6. 请求头模板(预设整组请求头,不同 CLI 头集合不同;选"自定义"逐头输入)----
|
|
1442
1442
|
const presetLabels = HEADER_PRESETS.map((p) => p.label);
|
|
1443
1443
|
const presetChoice = await ctx.ui.select(
|
|
1444
1444
|
"请求头模板?",
|
|
@@ -1470,9 +1470,9 @@ export default function customProviderExtension(pi: ExtensionAPI) {
|
|
|
1470
1470
|
const preset = HEADER_PRESETS.find((p) => p.label === presetChoice);
|
|
1471
1471
|
if (preset?.key) {
|
|
1472
1472
|
if (preset.key !== "browser") {
|
|
1473
|
-
applyHeaderSet({ ...preset.headers },
|
|
1473
|
+
applyHeaderSet({ ...preset.headers }, `模板"${preset.label}"`);
|
|
1474
1474
|
ctx.ui.notify(
|
|
1475
|
-
|
|
1475
|
+
`已应用请求头模板"${preset.label}": ${Object.keys(preset.headers).join(", ")}`,
|
|
1476
1476
|
"info"
|
|
1477
1477
|
);
|
|
1478
1478
|
} // 浏览器模板 = 不写头,由 pi 自动补充浏览器 UA
|
|
@@ -2442,7 +2442,7 @@ export default function customProviderExtension(pi: ExtensionAPI) {
|
|
|
2442
2442
|
description: "管理第三方 Provider:add / remove / refresh / list / test / help",
|
|
2443
2443
|
getArgumentCompletions: (prefix: string) => {
|
|
2444
2444
|
// 注意: pi 会用 item.value 替换整个参数段(命令名后的全部文本),
|
|
2445
|
-
// 所以 value
|
|
2445
|
+
// 所以 value 必须是"子命令 + 完整名称"的完整参数,label 才是用于显示的名称。
|
|
2446
2446
|
const trimmed = prefix.trim();
|
|
2447
2447
|
const match = trimmed.match(/^(\S+)(?:\s+(.*))?$/);
|
|
2448
2448
|
const first = (match?.[1] ?? "").toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "custom-provider-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "pi 扩展:统一管理第三方模型 Provider。子命令体系 /custom-provider add|remove|refresh|list|test|config|enable|disable|prune,支持交互向导、flags/JSON 非交互添加、双协议混用(OpenAI + Anthropic)、模型关键字过滤与修剪、per-provider 代理配置、负载均衡",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|