@jeffreycao/copilot-api 1.10.8 → 1.10.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.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/main.js +1 -1
- package/dist/{server-BRFLAT4z.js → server-FPXzFkg9.js} +22 -1
- package/dist/server-FPXzFkg9.js.map +1 -0
- package/dist/{start-Bzfnxzlh.js → start-CbKg_0bY.js} +2 -2
- package/dist/{start-Bzfnxzlh.js.map → start-CbKg_0bY.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-BRFLAT4z.js.map +0 -1
package/README.md
CHANGED
|
@@ -382,7 +382,7 @@ The following command line options are available for the `start` command:
|
|
|
382
382
|
- `temperature` (optional): Default temperature value used when the request does not specify one.
|
|
383
383
|
- `topP` (optional): Default top_p value used when the request does not specify one.
|
|
384
384
|
- `topK` (optional): Default top_k value used when the request does not specify one.
|
|
385
|
-
- `extraBody` (optional): Dynamic fields merged into the upstream request body for that model. Request body fields with the same name take precedence. OpenAI-compatible providers can use this for fields such as `enable_thinking`, `preserve_thinking`, `reasoning_effort`.
|
|
385
|
+
- `extraBody` (optional): Dynamic fields merged into the upstream request body for that model. Request body fields with the same name take precedence. OpenAI-compatible providers can use this for fields such as `enable_thinking`, `preserve_thinking`, `reasoning_effort`. `thinking_budget` is a special OpenAI-compatible provider override: when configured in `extraBody`, it is forced after Anthropic `thinking.budget_tokens` translation and overrides the request-derived budget.
|
|
386
386
|
- `contextCache` (optional): Defaults to `true` for OpenAI-compatible providers. This enables Alibaba Cloud Model Studio/DashScope explicit context cache by injecting `cache_control: { "type": "ephemeral" }` on up to 4 content blocks using the Context Cache format. The cache breakpoint strategy matches opencode's main provider flow: the first 2 system messages plus the last 2 non-system messages. Marked string content is converted to text content part arrays for `system` / `user` / `assistant` / `tool` messages; existing array content is marked on the last part. Set this to `false` when the model already supports implicit caching, or when the upstream does not accept this explicit-cache extension field.
|
|
387
387
|
- `supportPdf` (optional): Controls whether the model supports PDF/document content. Defaults to `false`; unsupported PDFs are converted to a text notice. Set it to `true` to send PDF/document blocks as OpenAI Chat Completions file parts.
|
|
388
388
|
- `toolContentSupportType` (optional): Tool result content capabilities for that model, as an array of `array`, `image`, and `pdf`. Provider routes default to string-only tool content when omitted. If `supportPdf` is `true` but this list does not include `pdf`, file parts in tool results are moved to user role messages. This provider default does not change the Copilot main flow, which continues to support array + image and not PDF.
|
package/README.zh-CN.md
CHANGED
|
@@ -386,7 +386,7 @@ Copilot API 现在使用子命令结构,主要命令包括:
|
|
|
386
386
|
- `temperature`:可选,当请求未指定时使用的默认温度。
|
|
387
387
|
- `topP`:可选,当请求未指定时使用的默认 `top_p`。
|
|
388
388
|
- `topK`:可选,当请求未指定时使用的默认 `top_k`。
|
|
389
|
-
- `extraBody`:可选,按模型合入上游请求体的动态字段;请求体显式同名字段优先。OpenAI 兼容 provider 可用它配置 `enable_thinking`、`preserve_thinking`、`reasoning_effort`
|
|
389
|
+
- `extraBody`:可选,按模型合入上游请求体的动态字段;请求体显式同名字段优先。OpenAI 兼容 provider 可用它配置 `enable_thinking`、`preserve_thinking`、`reasoning_effort` 等字段。`thinking_budget` 是 OpenAI 兼容 provider 的特殊覆盖项:配置在 `extraBody` 后,会在 Anthropic `thinking.budget_tokens` 翻译之后强制写入,并覆盖请求派生出的预算值。
|
|
390
390
|
- `contextCache`:可选,OpenAI 兼容 provider 默认 `true`,用于启用阿里云百炼/DashScope 的显式缓存(explicit context cache),会按其 Context Cache 格式在最多 4 个 content block 上注入 `cache_control: { "type": "ephemeral" }`。缓存断点策略与 opencode 主链路保持一致:前 2 条 system 消息 + 最后 2 条非 system 消息。标记字符串 content 时会把 `system` / `user` / `assistant` / `tool` 消息转换为 text content part 数组;已有数组 content 则标记最后一个 part。如果模型本身已经支持隐式缓存,或上游不支持该显式缓存扩展字段,可在模型配置中设为 `false`。
|
|
391
391
|
- `supportPdf`:可选,控制该模型是否支持 PDF/document content。默认 `false`,不支持时会把 PDF 转成提示文本;设为 `true` 时会把 PDF/document 转成 OpenAI Chat Completions 的 file part。
|
|
392
392
|
- `toolContentSupportType`:可选,配置该模型的 tool result content 支持能力,值为 `array`、`image`、`pdf` 的数组。provider 侧未配置时默认只发送 string tool content。若 `supportPdf` 为 `true` 但这里不包含 `pdf`,tool result 里的 file part 会被转成 user role 消息。Copilot 主链路不使用这个 provider 默认,仍按 array + image 且不支持 PDF 的能力处理。
|
package/dist/main.js
CHANGED
|
@@ -43,7 +43,7 @@ const { auth } = await import("./auth-BHa2OHXf.js");
|
|
|
43
43
|
const { checkUsage } = await import("./check-usage-BdXGp1Wr.js");
|
|
44
44
|
const { debug } = await import("./debug-C_TBkyUw.js");
|
|
45
45
|
const { mcp } = await import("./mcp-CTb-DbQH.js");
|
|
46
|
-
const { start } = await import("./start-
|
|
46
|
+
const { start } = await import("./start-CbKg_0bY.js");
|
|
47
47
|
await runMain(defineCommand({
|
|
48
48
|
meta: {
|
|
49
49
|
name: "copilot-api",
|
|
@@ -2343,6 +2343,25 @@ const applyModelDefaults = (payload, modelConfig) => {
|
|
|
2343
2343
|
const applyMissingExtraBody = (payload, options) => {
|
|
2344
2344
|
for (const [key, value] of Object.entries(options.extraBody ?? {})) if (!Object.hasOwn(payload, key)) payload[key] = value;
|
|
2345
2345
|
};
|
|
2346
|
+
const getRequestThinkingBudget = (payload) => {
|
|
2347
|
+
const budget = payload.thinking?.budget_tokens;
|
|
2348
|
+
if (typeof budget !== "number" || !Number.isFinite(budget)) return;
|
|
2349
|
+
return budget;
|
|
2350
|
+
};
|
|
2351
|
+
const applyOpenAICompatibleThinkingBudget = (payload, source) => {
|
|
2352
|
+
const thinkingBudget = getRequestThinkingBudget(source);
|
|
2353
|
+
if (thinkingBudget !== void 0) {
|
|
2354
|
+
payload.thinking_budget = thinkingBudget;
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
if (payload.thinking_budget === void 0) delete payload.thinking_budget;
|
|
2358
|
+
};
|
|
2359
|
+
const applyOpenAICompatibleExtraBodyThinkingBudget = (payload, options) => {
|
|
2360
|
+
const { extraBody } = options;
|
|
2361
|
+
if (!extraBody || !Object.hasOwn(extraBody, "thinking_budget")) return;
|
|
2362
|
+
const rawPayload = payload;
|
|
2363
|
+
rawPayload.thinking_budget = extraBody.thinking_budget;
|
|
2364
|
+
};
|
|
2346
2365
|
const handleOpenAICompatibleProviderMessages = async (c, options) => {
|
|
2347
2366
|
const { modelConfig, payload, provider, providerConfig } = options;
|
|
2348
2367
|
const openAIPayload = createOpenAICompatiblePayload(payload, modelConfig);
|
|
@@ -2373,6 +2392,7 @@ const createOpenAICompatiblePayload = (payload, modelConfig) => {
|
|
|
2373
2392
|
supportPdf: modelConfig?.supportPdf,
|
|
2374
2393
|
toolContentSupportType: modelConfig?.toolContentSupportType ?? []
|
|
2375
2394
|
});
|
|
2395
|
+
applyOpenAICompatibleThinkingBudget(openAIPayload, payload);
|
|
2376
2396
|
if (payload.top_k !== void 0) openAIPayload.top_k = payload.top_k;
|
|
2377
2397
|
if (openAIPayload.stream) openAIPayload.stream_options = { include_usage: true };
|
|
2378
2398
|
normalizeOpenAICompatibleReasoningContent(openAIPayload);
|
|
@@ -2381,6 +2401,7 @@ const createOpenAICompatiblePayload = (payload, modelConfig) => {
|
|
|
2381
2401
|
source: payload
|
|
2382
2402
|
});
|
|
2383
2403
|
applyMissingExtraBody(openAIPayload, { extraBody: modelConfig?.extraBody });
|
|
2404
|
+
applyOpenAICompatibleExtraBodyThinkingBudget(openAIPayload, { extraBody: modelConfig?.extraBody });
|
|
2384
2405
|
if (!Object.hasOwn(openAIPayload, "parallel_tool_calls")) openAIPayload.parallel_tool_calls = true;
|
|
2385
2406
|
if (modelConfig?.contextCache !== false) applyOpenAICompatibleContextCache(openAIPayload);
|
|
2386
2407
|
return openAIPayload;
|
|
@@ -5019,4 +5040,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
5019
5040
|
//#endregion
|
|
5020
5041
|
export { server };
|
|
5021
5042
|
|
|
5022
|
-
//# sourceMappingURL=server-
|
|
5043
|
+
//# sourceMappingURL=server-FPXzFkg9.js.map
|