@vibe-lark/larkpal 0.1.84 → 0.1.86
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/dist/account-id-BM1T6029-DYjVxojW.mjs +46 -0
- package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +172 -0
- package/dist/anthropic-TH8ERTXK.mjs +5962 -0
- package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +596 -0
- package/dist/azure-openai-responses-Bt_Ag9Er.mjs +166 -0
- package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +594 -0
- package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +60 -0
- package/dist/build-DgTrEpge.mjs +3333 -0
- package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +5216 -0
- package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +258 -0
- package/dist/call-DimWbpgJ-ColD4W-y.mjs +9993 -0
- package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +2 -0
- package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +33 -0
- package/dist/chunk-D6SyT4dJ.mjs +36 -0
- package/dist/cli.mjs +6 -6
- package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +685 -0
- package/dist/config-Bim2pi8a-BQUdfiEi.mjs +9 -0
- package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +72 -0
- package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +140 -0
- package/dist/dist-CEGw8-2W.mjs +429 -0
- package/dist/dist-DD2aJ2UL.mjs +125135 -0
- package/dist/env-api-keys-BVvSg7T2.mjs +68 -0
- package/dist/event-stream-xaQWmyas.mjs +15226 -0
- package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +194 -0
- package/dist/from-DF7cl2wz.mjs +3842 -0
- package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +28 -0
- package/dist/github-copilot-headers-DjqWtUoP.mjs +22 -0
- package/dist/google-C2pVrgBZ.mjs +336 -0
- package/dist/google-gemini-cli-BBxgS5Ho.mjs +623 -0
- package/dist/google-shared-BsWgwEk1.mjs +22791 -0
- package/dist/google-vertex-BsVLJrrC.mjs +358 -0
- package/dist/hash-DAFtW_W7.mjs +16 -0
- package/dist/headers-R3HdCbAE.mjs +8 -0
- package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +93 -0
- package/dist/ids-BPsM98Uu-CwuxvUai.mjs +77 -0
- package/dist/image-2w3cApg7-CxpHvoB5.mjs +207 -0
- package/dist/io-CH2g3vsv-BOGlLlB8.mjs +26218 -0
- package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +5049 -0
- package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +108 -0
- package/dist/json-parse-v_HIJjjI.mjs +381 -0
- package/dist/jws-GFcTvvVT.mjs +2291 -0
- package/dist/{lark-cli-provider-7LvtOIF_.mjs → lark-cli-provider-BARgbbmo.mjs} +1 -1
- package/dist/{live-smoke-nvTUPtrv.mjs → live-smoke-BhkBOcH9.mjs} +3 -3
- package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +29 -0
- package/dist/loader-708jrx4Y-BOswuvpe.mjs +5053 -0
- package/dist/main.mjs +56780 -476
- package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +3512 -0
- package/dist/mcp-server.mjs +1 -1
- package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +50 -0
- package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +29 -0
- package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +2 -0
- package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +2 -0
- package/dist/mistral-CaR4DiLu.mjs +28657 -0
- package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +1306 -0
- package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +1282 -0
- package/dist/models-config.runtime-BsU_22xk.mjs +2 -0
- package/dist/multipart-parser-DedmaB5g.mjs +294 -0
- package/dist/oauth-DOJeGfcE.mjs +6392 -0
- package/dist/openai-BDtIh3Ja.mjs +6693 -0
- package/dist/openai-codex-responses-C5EORu31.mjs +664 -0
- package/dist/openai-completions-CR_cS6gX.mjs +669 -0
- package/dist/openai-responses-oGxwZyuC.mjs +184 -0
- package/dist/openai-responses-shared-BixMSDZE.mjs +398 -0
- package/dist/paths-D6msg0S1-C2lYuisN.mjs +189 -0
- package/dist/paths-D92DjaZ--CTOESW2b.mjs +192 -0
- package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +227 -0
- package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +2 -0
- package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +399 -0
- package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +1456 -0
- package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +61 -0
- package/dist/provider-discovery.runtime-BPzz1PFj.mjs +58 -0
- package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +118 -0
- package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +2 -0
- package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +573 -0
- package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +35449 -0
- package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +219 -0
- package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +117 -0
- package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +1041 -0
- package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +120 -0
- package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +19 -0
- package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +677 -0
- package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +10 -0
- package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +39 -0
- package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +2 -0
- package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +2 -0
- package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +2 -0
- package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +82 -0
- package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +147 -0
- package/dist/src-BgCX0MLG.mjs +813 -0
- package/dist/src-DYbqlAqf.mjs +1177 -0
- package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +344 -0
- package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +28 -0
- package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +211 -0
- package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +3061 -0
- package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +1002 -0
- package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +2950 -0
- package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +2 -0
- package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +2 -0
- package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +2019 -0
- package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +2 -0
- package/dist/transform-messages-DbhIzTxq.mjs +207 -0
- package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +295 -0
- package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +200 -0
- package/package.json +3 -3
- package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
- /package/dist/{interactive-init-B6j8j_Ap.mjs → interactive-init-BXQBalNr.mjs} +0 -0
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import { r as __exportAll } from "./chunk-D6SyT4dJ.mjs";
|
|
2
|
+
import { t as getEnvApiKey } from "./env-api-keys-BVvSg7T2.mjs";
|
|
3
|
+
import { o as supportsXhigh, r as calculateCost, t as AssistantMessageEventStream } from "./event-stream-xaQWmyas.mjs";
|
|
4
|
+
import { n as parseStreamingJson } from "./json-parse-v_HIJjjI.mjs";
|
|
5
|
+
import { n as OpenAI } from "./openai-BDtIh3Ja.mjs";
|
|
6
|
+
import { t as headersToRecord } from "./headers-R3HdCbAE.mjs";
|
|
7
|
+
import { a as sanitizeSurrogates, i as clampReasoning, r as buildBaseOptions, t as transformMessages } from "./transform-messages-DbhIzTxq.mjs";
|
|
8
|
+
import { n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-DjqWtUoP.mjs";
|
|
9
|
+
//#region node_modules/.pnpm/@mariozechner+pi-ai@0.69.0_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__ws@8.21.0_zod@4.3.6/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js
|
|
10
|
+
var openai_completions_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
convertMessages: () => convertMessages,
|
|
12
|
+
streamOpenAICompletions: () => streamOpenAICompletions,
|
|
13
|
+
streamSimpleOpenAICompletions: () => streamSimpleOpenAICompletions
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Check if conversation messages contain tool calls or tool results.
|
|
17
|
+
* This is needed because Anthropic (via proxy) requires the tools param
|
|
18
|
+
* to be present when messages include tool_calls or tool role messages.
|
|
19
|
+
*/
|
|
20
|
+
function hasToolHistory(messages) {
|
|
21
|
+
for (const msg of messages) {
|
|
22
|
+
if (msg.role === "toolResult") return true;
|
|
23
|
+
if (msg.role === "assistant") {
|
|
24
|
+
if (msg.content.some((block) => block.type === "toolCall")) return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
function isTextContentBlock(block) {
|
|
30
|
+
return block.type === "text";
|
|
31
|
+
}
|
|
32
|
+
function isThinkingContentBlock(block) {
|
|
33
|
+
return block.type === "thinking";
|
|
34
|
+
}
|
|
35
|
+
function isToolCallBlock(block) {
|
|
36
|
+
return block.type === "toolCall";
|
|
37
|
+
}
|
|
38
|
+
function isImageContentBlock(block) {
|
|
39
|
+
return block.type === "image";
|
|
40
|
+
}
|
|
41
|
+
function resolveCacheRetention(cacheRetention) {
|
|
42
|
+
if (cacheRetention) return cacheRetention;
|
|
43
|
+
if (typeof process !== "undefined" && process.env.PI_CACHE_RETENTION === "long") return "long";
|
|
44
|
+
return "short";
|
|
45
|
+
}
|
|
46
|
+
const streamOpenAICompletions = (model, context, options) => {
|
|
47
|
+
const stream = new AssistantMessageEventStream();
|
|
48
|
+
(async () => {
|
|
49
|
+
const output = {
|
|
50
|
+
role: "assistant",
|
|
51
|
+
content: [],
|
|
52
|
+
api: model.api,
|
|
53
|
+
provider: model.provider,
|
|
54
|
+
model: model.id,
|
|
55
|
+
usage: {
|
|
56
|
+
input: 0,
|
|
57
|
+
output: 0,
|
|
58
|
+
cacheRead: 0,
|
|
59
|
+
cacheWrite: 0,
|
|
60
|
+
totalTokens: 0,
|
|
61
|
+
cost: {
|
|
62
|
+
input: 0,
|
|
63
|
+
output: 0,
|
|
64
|
+
cacheRead: 0,
|
|
65
|
+
cacheWrite: 0,
|
|
66
|
+
total: 0
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
stopReason: "stop",
|
|
70
|
+
timestamp: Date.now()
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
74
|
+
const compat = getCompat(model);
|
|
75
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
76
|
+
const cacheSessionId = cacheRetention === "none" ? void 0 : options?.sessionId;
|
|
77
|
+
const client = createClient(model, context, apiKey, options?.headers, cacheSessionId, compat);
|
|
78
|
+
let params = buildParams(model, context, options, compat, cacheRetention);
|
|
79
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
80
|
+
if (nextParams !== void 0) params = nextParams;
|
|
81
|
+
const { data: openaiStream, response } = await client.chat.completions.create(params, { signal: options?.signal }).withResponse();
|
|
82
|
+
await options?.onResponse?.({
|
|
83
|
+
status: response.status,
|
|
84
|
+
headers: headersToRecord(response.headers)
|
|
85
|
+
}, model);
|
|
86
|
+
stream.push({
|
|
87
|
+
type: "start",
|
|
88
|
+
partial: output
|
|
89
|
+
});
|
|
90
|
+
let currentBlock = null;
|
|
91
|
+
const blocks = output.content;
|
|
92
|
+
const blockIndex = () => blocks.length - 1;
|
|
93
|
+
const finishCurrentBlock = (block) => {
|
|
94
|
+
if (block) {
|
|
95
|
+
if (block.type === "text") stream.push({
|
|
96
|
+
type: "text_end",
|
|
97
|
+
contentIndex: blockIndex(),
|
|
98
|
+
content: block.text,
|
|
99
|
+
partial: output
|
|
100
|
+
});
|
|
101
|
+
else if (block.type === "thinking") stream.push({
|
|
102
|
+
type: "thinking_end",
|
|
103
|
+
contentIndex: blockIndex(),
|
|
104
|
+
content: block.thinking,
|
|
105
|
+
partial: output
|
|
106
|
+
});
|
|
107
|
+
else if (block.type === "toolCall") {
|
|
108
|
+
block.arguments = parseStreamingJson(block.partialArgs);
|
|
109
|
+
delete block.partialArgs;
|
|
110
|
+
stream.push({
|
|
111
|
+
type: "toolcall_end",
|
|
112
|
+
contentIndex: blockIndex(),
|
|
113
|
+
toolCall: block,
|
|
114
|
+
partial: output
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
for await (const chunk of openaiStream) {
|
|
120
|
+
if (!chunk || typeof chunk !== "object") continue;
|
|
121
|
+
output.responseId ||= chunk.id;
|
|
122
|
+
if (chunk.usage) output.usage = parseChunkUsage(chunk.usage, model);
|
|
123
|
+
const choice = Array.isArray(chunk.choices) ? chunk.choices[0] : void 0;
|
|
124
|
+
if (!choice) continue;
|
|
125
|
+
if (!chunk.usage && choice.usage) output.usage = parseChunkUsage(choice.usage, model);
|
|
126
|
+
if (choice.finish_reason) {
|
|
127
|
+
const finishReasonResult = mapStopReason(choice.finish_reason);
|
|
128
|
+
output.stopReason = finishReasonResult.stopReason;
|
|
129
|
+
if (finishReasonResult.errorMessage) output.errorMessage = finishReasonResult.errorMessage;
|
|
130
|
+
}
|
|
131
|
+
if (choice.delta) {
|
|
132
|
+
if (choice.delta.content !== null && choice.delta.content !== void 0 && choice.delta.content.length > 0) {
|
|
133
|
+
if (!currentBlock || currentBlock.type !== "text") {
|
|
134
|
+
finishCurrentBlock(currentBlock);
|
|
135
|
+
currentBlock = {
|
|
136
|
+
type: "text",
|
|
137
|
+
text: ""
|
|
138
|
+
};
|
|
139
|
+
output.content.push(currentBlock);
|
|
140
|
+
stream.push({
|
|
141
|
+
type: "text_start",
|
|
142
|
+
contentIndex: blockIndex(),
|
|
143
|
+
partial: output
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (currentBlock.type === "text") {
|
|
147
|
+
currentBlock.text += choice.delta.content;
|
|
148
|
+
stream.push({
|
|
149
|
+
type: "text_delta",
|
|
150
|
+
contentIndex: blockIndex(),
|
|
151
|
+
delta: choice.delta.content,
|
|
152
|
+
partial: output
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const reasoningFields = [
|
|
157
|
+
"reasoning_content",
|
|
158
|
+
"reasoning",
|
|
159
|
+
"reasoning_text"
|
|
160
|
+
];
|
|
161
|
+
let foundReasoningField = null;
|
|
162
|
+
for (const field of reasoningFields) if (choice.delta[field] !== null && choice.delta[field] !== void 0 && choice.delta[field].length > 0) {
|
|
163
|
+
if (!foundReasoningField) {
|
|
164
|
+
foundReasoningField = field;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (foundReasoningField) {
|
|
169
|
+
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
170
|
+
finishCurrentBlock(currentBlock);
|
|
171
|
+
currentBlock = {
|
|
172
|
+
type: "thinking",
|
|
173
|
+
thinking: "",
|
|
174
|
+
thinkingSignature: foundReasoningField
|
|
175
|
+
};
|
|
176
|
+
output.content.push(currentBlock);
|
|
177
|
+
stream.push({
|
|
178
|
+
type: "thinking_start",
|
|
179
|
+
contentIndex: blockIndex(),
|
|
180
|
+
partial: output
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (currentBlock.type === "thinking") {
|
|
184
|
+
const delta = choice.delta[foundReasoningField];
|
|
185
|
+
currentBlock.thinking += delta;
|
|
186
|
+
stream.push({
|
|
187
|
+
type: "thinking_delta",
|
|
188
|
+
contentIndex: blockIndex(),
|
|
189
|
+
delta,
|
|
190
|
+
partial: output
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (choice?.delta?.tool_calls) for (const toolCall of choice.delta.tool_calls) {
|
|
195
|
+
if (!currentBlock || currentBlock.type !== "toolCall" || toolCall.id && currentBlock.id !== toolCall.id) {
|
|
196
|
+
finishCurrentBlock(currentBlock);
|
|
197
|
+
currentBlock = {
|
|
198
|
+
type: "toolCall",
|
|
199
|
+
id: toolCall.id || "",
|
|
200
|
+
name: toolCall.function?.name || "",
|
|
201
|
+
arguments: {},
|
|
202
|
+
partialArgs: ""
|
|
203
|
+
};
|
|
204
|
+
output.content.push(currentBlock);
|
|
205
|
+
stream.push({
|
|
206
|
+
type: "toolcall_start",
|
|
207
|
+
contentIndex: blockIndex(),
|
|
208
|
+
partial: output
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (currentBlock.type === "toolCall") {
|
|
212
|
+
if (toolCall.id) currentBlock.id = toolCall.id;
|
|
213
|
+
if (toolCall.function?.name) currentBlock.name = toolCall.function.name;
|
|
214
|
+
let delta = "";
|
|
215
|
+
if (toolCall.function?.arguments) {
|
|
216
|
+
delta = toolCall.function.arguments;
|
|
217
|
+
currentBlock.partialArgs += toolCall.function.arguments;
|
|
218
|
+
currentBlock.arguments = parseStreamingJson(currentBlock.partialArgs);
|
|
219
|
+
}
|
|
220
|
+
stream.push({
|
|
221
|
+
type: "toolcall_delta",
|
|
222
|
+
contentIndex: blockIndex(),
|
|
223
|
+
delta,
|
|
224
|
+
partial: output
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const reasoningDetails = choice.delta.reasoning_details;
|
|
229
|
+
if (reasoningDetails && Array.isArray(reasoningDetails)) {
|
|
230
|
+
for (const detail of reasoningDetails) if (detail.type === "reasoning.encrypted" && detail.id && detail.data) {
|
|
231
|
+
const matchingToolCall = output.content.find((b) => b.type === "toolCall" && b.id === detail.id);
|
|
232
|
+
if (matchingToolCall) matchingToolCall.thoughtSignature = JSON.stringify(detail);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
finishCurrentBlock(currentBlock);
|
|
238
|
+
if (options?.signal?.aborted) throw new Error("Request was aborted");
|
|
239
|
+
if (output.stopReason === "aborted") throw new Error("Request was aborted");
|
|
240
|
+
if (output.stopReason === "error") throw new Error(output.errorMessage || "Provider returned an error stop reason");
|
|
241
|
+
stream.push({
|
|
242
|
+
type: "done",
|
|
243
|
+
reason: output.stopReason,
|
|
244
|
+
message: output
|
|
245
|
+
});
|
|
246
|
+
stream.end();
|
|
247
|
+
} catch (error) {
|
|
248
|
+
for (const block of output.content) {
|
|
249
|
+
delete block.index;
|
|
250
|
+
delete block.partialArgs;
|
|
251
|
+
}
|
|
252
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
253
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
254
|
+
const rawMetadata = error?.error?.metadata?.raw;
|
|
255
|
+
if (rawMetadata) output.errorMessage += `\n${rawMetadata}`;
|
|
256
|
+
stream.push({
|
|
257
|
+
type: "error",
|
|
258
|
+
reason: output.stopReason,
|
|
259
|
+
error: output
|
|
260
|
+
});
|
|
261
|
+
stream.end();
|
|
262
|
+
}
|
|
263
|
+
})();
|
|
264
|
+
return stream;
|
|
265
|
+
};
|
|
266
|
+
const streamSimpleOpenAICompletions = (model, context, options) => {
|
|
267
|
+
const apiKey = options?.apiKey || getEnvApiKey(model.provider);
|
|
268
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
269
|
+
const base = buildBaseOptions(model, options, apiKey);
|
|
270
|
+
const reasoningEffort = supportsXhigh(model) ? options?.reasoning : clampReasoning(options?.reasoning);
|
|
271
|
+
const toolChoice = options?.toolChoice;
|
|
272
|
+
return streamOpenAICompletions(model, context, {
|
|
273
|
+
...base,
|
|
274
|
+
reasoningEffort,
|
|
275
|
+
toolChoice
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
function createClient(model, context, apiKey, optionsHeaders, sessionId, compat = getCompat(model)) {
|
|
279
|
+
if (!apiKey) {
|
|
280
|
+
if (!process.env.OPENAI_API_KEY) throw new Error("OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.");
|
|
281
|
+
apiKey = process.env.OPENAI_API_KEY;
|
|
282
|
+
}
|
|
283
|
+
const headers = { ...model.headers };
|
|
284
|
+
if (model.provider === "github-copilot") {
|
|
285
|
+
const hasImages = hasCopilotVisionInput(context.messages);
|
|
286
|
+
const copilotHeaders = buildCopilotDynamicHeaders({
|
|
287
|
+
messages: context.messages,
|
|
288
|
+
hasImages
|
|
289
|
+
});
|
|
290
|
+
Object.assign(headers, copilotHeaders);
|
|
291
|
+
}
|
|
292
|
+
if (sessionId && compat.sendSessionAffinityHeaders) {
|
|
293
|
+
headers.session_id = sessionId;
|
|
294
|
+
headers["x-client-request-id"] = sessionId;
|
|
295
|
+
headers["x-session-affinity"] = sessionId;
|
|
296
|
+
}
|
|
297
|
+
if (optionsHeaders) Object.assign(headers, optionsHeaders);
|
|
298
|
+
return new OpenAI({
|
|
299
|
+
apiKey,
|
|
300
|
+
baseURL: model.baseUrl,
|
|
301
|
+
dangerouslyAllowBrowser: true,
|
|
302
|
+
defaultHeaders: headers
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function buildParams(model, context, options, compat = getCompat(model), cacheRetention = resolveCacheRetention(options?.cacheRetention)) {
|
|
306
|
+
const messages = convertMessages(model, context, compat);
|
|
307
|
+
const cacheControl = getCompatCacheControl(model, compat, cacheRetention);
|
|
308
|
+
const params = {
|
|
309
|
+
model: model.id,
|
|
310
|
+
messages,
|
|
311
|
+
stream: true,
|
|
312
|
+
prompt_cache_key: model.baseUrl.includes("api.openai.com") && cacheRetention !== "none" ? options?.sessionId : void 0,
|
|
313
|
+
prompt_cache_retention: model.baseUrl.includes("api.openai.com") && cacheRetention === "long" ? "24h" : void 0
|
|
314
|
+
};
|
|
315
|
+
if (compat.supportsUsageInStreaming !== false) params.stream_options = { include_usage: true };
|
|
316
|
+
if (compat.supportsStore) params.store = false;
|
|
317
|
+
if (options?.maxTokens) if (compat.maxTokensField === "max_tokens") params.max_tokens = options.maxTokens;
|
|
318
|
+
else params.max_completion_tokens = options.maxTokens;
|
|
319
|
+
if (options?.temperature !== void 0) params.temperature = options.temperature;
|
|
320
|
+
if (context.tools) {
|
|
321
|
+
params.tools = convertTools(context.tools, compat);
|
|
322
|
+
if (compat.zaiToolStream) params.tool_stream = true;
|
|
323
|
+
} else if (hasToolHistory(context.messages)) params.tools = [];
|
|
324
|
+
if (cacheControl) applyAnthropicCacheControl(messages, params.tools, cacheControl);
|
|
325
|
+
if (options?.toolChoice) params.tool_choice = options.toolChoice;
|
|
326
|
+
if (compat.thinkingFormat === "zai" && model.reasoning) params.enable_thinking = !!options?.reasoningEffort;
|
|
327
|
+
else if (compat.thinkingFormat === "qwen" && model.reasoning) params.enable_thinking = !!options?.reasoningEffort;
|
|
328
|
+
else if (compat.thinkingFormat === "qwen-chat-template" && model.reasoning) params.chat_template_kwargs = {
|
|
329
|
+
enable_thinking: !!options?.reasoningEffort,
|
|
330
|
+
preserve_thinking: true
|
|
331
|
+
};
|
|
332
|
+
else if (compat.thinkingFormat === "openrouter" && model.reasoning) {
|
|
333
|
+
const openRouterParams = params;
|
|
334
|
+
if (options?.reasoningEffort) openRouterParams.reasoning = { effort: mapReasoningEffort(options.reasoningEffort, compat.reasoningEffortMap) };
|
|
335
|
+
else openRouterParams.reasoning = { effort: "none" };
|
|
336
|
+
} else if (options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) params.reasoning_effort = mapReasoningEffort(options.reasoningEffort, compat.reasoningEffortMap);
|
|
337
|
+
if (model.baseUrl.includes("openrouter.ai") && model.compat?.openRouterRouting) params.provider = model.compat.openRouterRouting;
|
|
338
|
+
if (model.baseUrl.includes("ai-gateway.vercel.sh") && model.compat?.vercelGatewayRouting) {
|
|
339
|
+
const routing = model.compat.vercelGatewayRouting;
|
|
340
|
+
if (routing.only || routing.order) {
|
|
341
|
+
const gatewayOptions = {};
|
|
342
|
+
if (routing.only) gatewayOptions.only = routing.only;
|
|
343
|
+
if (routing.order) gatewayOptions.order = routing.order;
|
|
344
|
+
params.providerOptions = { gateway: gatewayOptions };
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return params;
|
|
348
|
+
}
|
|
349
|
+
function mapReasoningEffort(effort, reasoningEffortMap) {
|
|
350
|
+
return reasoningEffortMap[effort] ?? effort;
|
|
351
|
+
}
|
|
352
|
+
function getCompatCacheControl(model, compat, cacheRetention) {
|
|
353
|
+
if (compat.cacheControlFormat !== "anthropic" || cacheRetention === "none") return;
|
|
354
|
+
const ttl = cacheRetention === "long" && model.baseUrl.includes("api.anthropic.com") ? "1h" : void 0;
|
|
355
|
+
return {
|
|
356
|
+
type: "ephemeral",
|
|
357
|
+
...ttl ? { ttl } : {}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function applyAnthropicCacheControl(messages, tools, cacheControl) {
|
|
361
|
+
addCacheControlToSystemPrompt(messages, cacheControl);
|
|
362
|
+
addCacheControlToLastTool(tools, cacheControl);
|
|
363
|
+
addCacheControlToLastConversationMessage(messages, cacheControl);
|
|
364
|
+
}
|
|
365
|
+
function addCacheControlToSystemPrompt(messages, cacheControl) {
|
|
366
|
+
for (const message of messages) if (message.role === "system" || message.role === "developer") {
|
|
367
|
+
addCacheControlToInstructionMessage(message, cacheControl);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function addCacheControlToLastConversationMessage(messages, cacheControl) {
|
|
372
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
373
|
+
const message = messages[i];
|
|
374
|
+
if (message.role === "user" || message.role === "assistant") {
|
|
375
|
+
if (addCacheControlToMessage(message, cacheControl)) return;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function addCacheControlToLastTool(tools, cacheControl) {
|
|
380
|
+
if (!tools || tools.length === 0) return;
|
|
381
|
+
const lastTool = tools[tools.length - 1];
|
|
382
|
+
lastTool.cache_control = cacheControl;
|
|
383
|
+
}
|
|
384
|
+
function addCacheControlToInstructionMessage(message, cacheControl) {
|
|
385
|
+
return addCacheControlToTextContent(message, cacheControl);
|
|
386
|
+
}
|
|
387
|
+
function addCacheControlToMessage(message, cacheControl) {
|
|
388
|
+
if (message.role === "user" || message.role === "assistant") return addCacheControlToTextContent(message, cacheControl);
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
function addCacheControlToTextContent(message, cacheControl) {
|
|
392
|
+
const content = message.content;
|
|
393
|
+
if (typeof content === "string") {
|
|
394
|
+
if (content.length === 0) return false;
|
|
395
|
+
message.content = [{
|
|
396
|
+
type: "text",
|
|
397
|
+
text: content,
|
|
398
|
+
cache_control: cacheControl
|
|
399
|
+
}];
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
if (!Array.isArray(content)) return false;
|
|
403
|
+
for (let i = content.length - 1; i >= 0; i--) {
|
|
404
|
+
const part = content[i];
|
|
405
|
+
if (part?.type === "text") {
|
|
406
|
+
const textPart = part;
|
|
407
|
+
textPart.cache_control = cacheControl;
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
function convertMessages(model, context, compat) {
|
|
414
|
+
const params = [];
|
|
415
|
+
const normalizeToolCallId = (id) => {
|
|
416
|
+
if (id.includes("|")) {
|
|
417
|
+
const [callId] = id.split("|");
|
|
418
|
+
return callId.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 40);
|
|
419
|
+
}
|
|
420
|
+
if (model.provider === "openai") return id.length > 40 ? id.slice(0, 40) : id;
|
|
421
|
+
return id;
|
|
422
|
+
};
|
|
423
|
+
const transformedMessages = transformMessages(context.messages, model, (id) => normalizeToolCallId(id));
|
|
424
|
+
if (context.systemPrompt) {
|
|
425
|
+
const role = model.reasoning && compat.supportsDeveloperRole ? "developer" : "system";
|
|
426
|
+
params.push({
|
|
427
|
+
role,
|
|
428
|
+
content: sanitizeSurrogates(context.systemPrompt)
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
let lastRole = null;
|
|
432
|
+
for (let i = 0; i < transformedMessages.length; i++) {
|
|
433
|
+
const msg = transformedMessages[i];
|
|
434
|
+
if (compat.requiresAssistantAfterToolResult && lastRole === "toolResult" && msg.role === "user") params.push({
|
|
435
|
+
role: "assistant",
|
|
436
|
+
content: "I have processed the tool results."
|
|
437
|
+
});
|
|
438
|
+
if (msg.role === "user") if (typeof msg.content === "string") params.push({
|
|
439
|
+
role: "user",
|
|
440
|
+
content: sanitizeSurrogates(msg.content)
|
|
441
|
+
});
|
|
442
|
+
else {
|
|
443
|
+
const content = msg.content.map((item) => {
|
|
444
|
+
if (item.type === "text") return {
|
|
445
|
+
type: "text",
|
|
446
|
+
text: sanitizeSurrogates(item.text)
|
|
447
|
+
};
|
|
448
|
+
else return {
|
|
449
|
+
type: "image_url",
|
|
450
|
+
image_url: { url: `data:${item.mimeType};base64,${item.data}` }
|
|
451
|
+
};
|
|
452
|
+
});
|
|
453
|
+
if (content.length === 0) continue;
|
|
454
|
+
params.push({
|
|
455
|
+
role: "user",
|
|
456
|
+
content
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
else if (msg.role === "assistant") {
|
|
460
|
+
const assistantMsg = {
|
|
461
|
+
role: "assistant",
|
|
462
|
+
content: compat.requiresAssistantAfterToolResult ? "" : null
|
|
463
|
+
};
|
|
464
|
+
const assistantTextParts = msg.content.filter(isTextContentBlock).filter((block) => block.text.trim().length > 0).map((block) => ({
|
|
465
|
+
type: "text",
|
|
466
|
+
text: sanitizeSurrogates(block.text)
|
|
467
|
+
}));
|
|
468
|
+
const assistantText = assistantTextParts.map((part) => part.text).join("");
|
|
469
|
+
const nonEmptyThinkingBlocks = msg.content.filter(isThinkingContentBlock).filter((block) => block.thinking.trim().length > 0);
|
|
470
|
+
if (nonEmptyThinkingBlocks.length > 0) if (compat.requiresThinkingAsText) assistantMsg.content = [{
|
|
471
|
+
type: "text",
|
|
472
|
+
text: nonEmptyThinkingBlocks.map((block) => sanitizeSurrogates(block.thinking)).join("\n\n")
|
|
473
|
+
}, ...assistantTextParts];
|
|
474
|
+
else {
|
|
475
|
+
if (assistantText.length > 0) assistantMsg.content = assistantText;
|
|
476
|
+
const signature = nonEmptyThinkingBlocks[0].thinkingSignature;
|
|
477
|
+
if (signature && signature.length > 0) assistantMsg[signature] = nonEmptyThinkingBlocks.map((block) => block.thinking).join("\n");
|
|
478
|
+
}
|
|
479
|
+
else if (assistantText.length > 0) assistantMsg.content = assistantText;
|
|
480
|
+
const toolCalls = msg.content.filter(isToolCallBlock);
|
|
481
|
+
if (toolCalls.length > 0) {
|
|
482
|
+
assistantMsg.tool_calls = toolCalls.map((tc) => ({
|
|
483
|
+
id: tc.id,
|
|
484
|
+
type: "function",
|
|
485
|
+
function: {
|
|
486
|
+
name: tc.name,
|
|
487
|
+
arguments: JSON.stringify(tc.arguments)
|
|
488
|
+
}
|
|
489
|
+
}));
|
|
490
|
+
const reasoningDetails = toolCalls.filter((tc) => tc.thoughtSignature).map((tc) => {
|
|
491
|
+
try {
|
|
492
|
+
return JSON.parse(tc.thoughtSignature);
|
|
493
|
+
} catch {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
}).filter(Boolean);
|
|
497
|
+
if (reasoningDetails.length > 0) assistantMsg.reasoning_details = reasoningDetails;
|
|
498
|
+
}
|
|
499
|
+
const content = assistantMsg.content;
|
|
500
|
+
if (!(content !== null && content !== void 0 && (typeof content === "string" ? content.length > 0 : content.length > 0)) && !assistantMsg.tool_calls) continue;
|
|
501
|
+
params.push(assistantMsg);
|
|
502
|
+
} else if (msg.role === "toolResult") {
|
|
503
|
+
const imageBlocks = [];
|
|
504
|
+
let j = i;
|
|
505
|
+
for (; j < transformedMessages.length && transformedMessages[j].role === "toolResult"; j++) {
|
|
506
|
+
const toolMsg = transformedMessages[j];
|
|
507
|
+
const textResult = toolMsg.content.filter(isTextContentBlock).map((block) => block.text).join("\n");
|
|
508
|
+
const hasImages = toolMsg.content.some((c) => c.type === "image");
|
|
509
|
+
const toolResultMsg = {
|
|
510
|
+
role: "tool",
|
|
511
|
+
content: sanitizeSurrogates(textResult.length > 0 ? textResult : "(see attached image)"),
|
|
512
|
+
tool_call_id: toolMsg.toolCallId
|
|
513
|
+
};
|
|
514
|
+
if (compat.requiresToolResultName && toolMsg.toolName) toolResultMsg.name = toolMsg.toolName;
|
|
515
|
+
params.push(toolResultMsg);
|
|
516
|
+
if (hasImages && model.input.includes("image")) {
|
|
517
|
+
for (const block of toolMsg.content) if (isImageContentBlock(block)) imageBlocks.push({
|
|
518
|
+
type: "image_url",
|
|
519
|
+
image_url: { url: `data:${block.mimeType};base64,${block.data}` }
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
i = j - 1;
|
|
524
|
+
if (imageBlocks.length > 0) {
|
|
525
|
+
if (compat.requiresAssistantAfterToolResult) params.push({
|
|
526
|
+
role: "assistant",
|
|
527
|
+
content: "I have processed the tool results."
|
|
528
|
+
});
|
|
529
|
+
params.push({
|
|
530
|
+
role: "user",
|
|
531
|
+
content: [{
|
|
532
|
+
type: "text",
|
|
533
|
+
text: "Attached image(s) from tool result:"
|
|
534
|
+
}, ...imageBlocks]
|
|
535
|
+
});
|
|
536
|
+
lastRole = "user";
|
|
537
|
+
} else lastRole = "toolResult";
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
lastRole = msg.role;
|
|
541
|
+
}
|
|
542
|
+
return params;
|
|
543
|
+
}
|
|
544
|
+
function convertTools(tools, compat) {
|
|
545
|
+
return tools.map((tool) => ({
|
|
546
|
+
type: "function",
|
|
547
|
+
function: {
|
|
548
|
+
name: tool.name,
|
|
549
|
+
description: tool.description,
|
|
550
|
+
parameters: tool.parameters,
|
|
551
|
+
...compat.supportsStrictMode !== false && { strict: false }
|
|
552
|
+
}
|
|
553
|
+
}));
|
|
554
|
+
}
|
|
555
|
+
function parseChunkUsage(rawUsage, model) {
|
|
556
|
+
const promptTokens = rawUsage.prompt_tokens || 0;
|
|
557
|
+
const reportedCachedTokens = rawUsage.prompt_tokens_details?.cached_tokens || 0;
|
|
558
|
+
const cacheWriteTokens = rawUsage.prompt_tokens_details?.cache_write_tokens || 0;
|
|
559
|
+
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens || 0;
|
|
560
|
+
const cacheReadTokens = cacheWriteTokens > 0 ? Math.max(0, reportedCachedTokens - cacheWriteTokens) : reportedCachedTokens;
|
|
561
|
+
const input = Math.max(0, promptTokens - cacheReadTokens - cacheWriteTokens);
|
|
562
|
+
const outputTokens = (rawUsage.completion_tokens || 0) + reasoningTokens;
|
|
563
|
+
const usage = {
|
|
564
|
+
input,
|
|
565
|
+
output: outputTokens,
|
|
566
|
+
cacheRead: cacheReadTokens,
|
|
567
|
+
cacheWrite: cacheWriteTokens,
|
|
568
|
+
totalTokens: input + outputTokens + cacheReadTokens + cacheWriteTokens,
|
|
569
|
+
cost: {
|
|
570
|
+
input: 0,
|
|
571
|
+
output: 0,
|
|
572
|
+
cacheRead: 0,
|
|
573
|
+
cacheWrite: 0,
|
|
574
|
+
total: 0
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
calculateCost(model, usage);
|
|
578
|
+
return usage;
|
|
579
|
+
}
|
|
580
|
+
function mapStopReason(reason) {
|
|
581
|
+
if (reason === null) return { stopReason: "stop" };
|
|
582
|
+
switch (reason) {
|
|
583
|
+
case "stop":
|
|
584
|
+
case "end": return { stopReason: "stop" };
|
|
585
|
+
case "length": return { stopReason: "length" };
|
|
586
|
+
case "function_call":
|
|
587
|
+
case "tool_calls": return { stopReason: "toolUse" };
|
|
588
|
+
case "content_filter": return {
|
|
589
|
+
stopReason: "error",
|
|
590
|
+
errorMessage: "Provider finish_reason: content_filter"
|
|
591
|
+
};
|
|
592
|
+
case "network_error": return {
|
|
593
|
+
stopReason: "error",
|
|
594
|
+
errorMessage: "Provider finish_reason: network_error"
|
|
595
|
+
};
|
|
596
|
+
default: return {
|
|
597
|
+
stopReason: "error",
|
|
598
|
+
errorMessage: `Provider finish_reason: ${reason}`
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Detect compatibility settings from provider and baseUrl for known providers.
|
|
604
|
+
* Provider takes precedence over URL-based detection since it's explicitly configured.
|
|
605
|
+
* Returns a fully resolved OpenAICompletionsCompat object with all fields set.
|
|
606
|
+
*/
|
|
607
|
+
function detectCompat(model) {
|
|
608
|
+
const provider = model.provider;
|
|
609
|
+
const baseUrl = model.baseUrl;
|
|
610
|
+
const isZai = provider === "zai" || baseUrl.includes("api.z.ai");
|
|
611
|
+
const isNonStandard = provider === "cerebras" || baseUrl.includes("cerebras.ai") || provider === "xai" || baseUrl.includes("api.x.ai") || baseUrl.includes("chutes.ai") || baseUrl.includes("deepseek.com") || isZai || provider === "opencode" || baseUrl.includes("opencode.ai");
|
|
612
|
+
const useMaxTokens = baseUrl.includes("chutes.ai");
|
|
613
|
+
const isGrok = provider === "xai" || baseUrl.includes("api.x.ai");
|
|
614
|
+
const isGroq = provider === "groq" || baseUrl.includes("groq.com");
|
|
615
|
+
const cacheControlFormat = provider === "openrouter" && model.id.startsWith("anthropic/") ? "anthropic" : void 0;
|
|
616
|
+
const reasoningEffortMap = isGroq && model.id === "qwen/qwen3-32b" ? {
|
|
617
|
+
minimal: "default",
|
|
618
|
+
low: "default",
|
|
619
|
+
medium: "default",
|
|
620
|
+
high: "default",
|
|
621
|
+
xhigh: "default"
|
|
622
|
+
} : {};
|
|
623
|
+
return {
|
|
624
|
+
supportsStore: !isNonStandard,
|
|
625
|
+
supportsDeveloperRole: !isNonStandard,
|
|
626
|
+
supportsReasoningEffort: !isGrok && !isZai,
|
|
627
|
+
reasoningEffortMap,
|
|
628
|
+
supportsUsageInStreaming: true,
|
|
629
|
+
maxTokensField: useMaxTokens ? "max_tokens" : "max_completion_tokens",
|
|
630
|
+
requiresToolResultName: false,
|
|
631
|
+
requiresAssistantAfterToolResult: false,
|
|
632
|
+
requiresThinkingAsText: false,
|
|
633
|
+
thinkingFormat: isZai ? "zai" : provider === "openrouter" || baseUrl.includes("openrouter.ai") ? "openrouter" : "openai",
|
|
634
|
+
openRouterRouting: {},
|
|
635
|
+
vercelGatewayRouting: {},
|
|
636
|
+
zaiToolStream: false,
|
|
637
|
+
supportsStrictMode: true,
|
|
638
|
+
cacheControlFormat,
|
|
639
|
+
sendSessionAffinityHeaders: false
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Get resolved compatibility settings for a model.
|
|
644
|
+
* Uses explicit model.compat if provided, otherwise auto-detects from provider/URL.
|
|
645
|
+
*/
|
|
646
|
+
function getCompat(model) {
|
|
647
|
+
const detected = detectCompat(model);
|
|
648
|
+
if (!model.compat) return detected;
|
|
649
|
+
return {
|
|
650
|
+
supportsStore: model.compat.supportsStore ?? detected.supportsStore,
|
|
651
|
+
supportsDeveloperRole: model.compat.supportsDeveloperRole ?? detected.supportsDeveloperRole,
|
|
652
|
+
supportsReasoningEffort: model.compat.supportsReasoningEffort ?? detected.supportsReasoningEffort,
|
|
653
|
+
reasoningEffortMap: model.compat.reasoningEffortMap ?? detected.reasoningEffortMap,
|
|
654
|
+
supportsUsageInStreaming: model.compat.supportsUsageInStreaming ?? detected.supportsUsageInStreaming,
|
|
655
|
+
maxTokensField: model.compat.maxTokensField ?? detected.maxTokensField,
|
|
656
|
+
requiresToolResultName: model.compat.requiresToolResultName ?? detected.requiresToolResultName,
|
|
657
|
+
requiresAssistantAfterToolResult: model.compat.requiresAssistantAfterToolResult ?? detected.requiresAssistantAfterToolResult,
|
|
658
|
+
requiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
|
|
659
|
+
thinkingFormat: model.compat.thinkingFormat ?? detected.thinkingFormat,
|
|
660
|
+
openRouterRouting: model.compat.openRouterRouting ?? {},
|
|
661
|
+
vercelGatewayRouting: model.compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,
|
|
662
|
+
zaiToolStream: model.compat.zaiToolStream ?? detected.zaiToolStream,
|
|
663
|
+
supportsStrictMode: model.compat.supportsStrictMode ?? detected.supportsStrictMode,
|
|
664
|
+
cacheControlFormat: model.compat.cacheControlFormat ?? detected.cacheControlFormat,
|
|
665
|
+
sendSessionAffinityHeaders: model.compat.sendSessionAffinityHeaders ?? detected.sendSessionAffinityHeaders
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
//#endregion
|
|
669
|
+
export { openai_completions_exports as n, convertMessages as t };
|