dsh-vertex-argon 1.2.1 → 1.3.0
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 +8 -2
- package/adapter.js +173 -53
- package/client.js +338 -5
- package/diagnostic-store.js +258 -0
- package/diagnostics.js +259 -0
- package/index.js +45 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
`dsh-vertex-argon` 为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) 提供完整的 **Gemini 4 Argon** 接入支持,自动聚合 **Google Vertex AI**(服务账号 / ADC)与 **Google Gemini Developer API**(AI Studio API Key)双通道,修复内置 `pi-ai` 适配器误传 `thinkingBudget` 导致的 `HTTP 400` 报错,完整打通原生三档思考、思维链(Thought Summaries)、`v1beta1` **Long Decode 跨段长生成自动续传**与带签名的多轮工具调用。
|
|
16
16
|
|
|
17
|
-
Current release: **[1.
|
|
17
|
+
Current release: **[1.3.0](https://github.com/higekibaka/dsh-vertex-argon)** · [npm](https://www.npmjs.com/package/dsh-vertex-argon)
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -27,7 +27,7 @@ Current release: **[1.2.1](https://github.com/higekibaka/dsh-vertex-argon)** ·
|
|
|
27
27
|
| **多轮工具调用回传** | 路由切换或签名不对齐时易丢失上下文 | 保持 `provider` / `model` 与 `thoughtSignature` 签名全链路一致 |
|
|
28
28
|
| **Long Decode 长生成** | Vertex 硬编码 `v1` 且锁死 64K,遇 `CONTINUATION` 直接抛错断流 | 自动切换 `v1beta1` 跨 64K 分段零延迟续传(最高 512K)、断流检查点指数退避恢复,按首跳输入上报水位防误压缩 |
|
|
29
29
|
| **采样参数净化** | 可能携带被 Argon 拒绝或忽略的采样字段 | 自动剥离 `temperature`、`topP`、`topK` 等无效采样参数 |
|
|
30
|
-
| **通道管理与设置** | 需手改 `cordis.patch.yml` 并反复排查校验报错 | 自动检测双通道 + 内置 **设置 → Vertex Argon**
|
|
30
|
+
| **通道管理与设置** | 需手改 `cordis.patch.yml` 并反复排查校验报错 | 自动检测双通道 + 内置 **设置 → Vertex Argon** 实时调节与「最近请求诊断摘要」折叠面板 |
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
@@ -108,6 +108,12 @@ dsh plugin --profile web add dsh-vertex-argon
|
|
|
108
108
|
| `maxTokens` | `65536` | `1` – `524288` | 最大输出预算(默认 `65,536`;开启 `longDecode` 后最高可设为 `524,288` 跨 64K 分段续传) |
|
|
109
109
|
| `contextWindow` | `1048576` | `1` – `1048576` | 输入、思考与输出共享的总上下文窗口(官方上限为 `1,048,576`) |
|
|
110
110
|
|
|
111
|
+
### 🩺 结构化请求诊断与「最近请求诊断摘要」面板(v1.3.0+)
|
|
112
|
+
|
|
113
|
+
- **有界持久化存储(`vertex_argon_diagnostics`)**:通过宿主 `storageDomain` 自动在 `~/.dsh/storages/vertex_argon_diagnostics/requests/` 下记录最近 **200 条**请求元数据(单请求最多记录 16 跳,异步队列上限 32 条,严格脱敏,绝不保存对话正文、图片、`continuationToken` 明文或密钥)。
|
|
114
|
+
- **逐跳与双轨 Token 追踪**:完整记录每次请求的通道(`google-vertex` / `google-generative-ai`)、API 版本(`v1beta1` / `v1`)、思考档位、每一跳的触发原因(`initial` / `continuation` / `checkpoint-reconnect` / `retry-same-checkpoint`)、退避等待耗时(`backoffDelayMs`)、底层传输错误码白名单(如 `ECONNRESET`、`ETIMEDOUT`)以及上报水位(首跳输入)与多跳累计计费 Token 对比。
|
|
115
|
+
- **图形化折叠面板**:在 **设置 → Vertex Argon** 页面底部点击展开 **「最近请求诊断摘要」**,即可直接查看最近 20 次请求的耗时、跳数、断流自愈状态与逐跳明细。
|
|
116
|
+
|
|
111
117
|
---
|
|
112
118
|
|
|
113
119
|
## ⚠️ 与 `billion-context` 配合使用的兼容性说明
|
package/adapter.js
CHANGED
|
@@ -2,6 +2,7 @@ import { access } from 'node:fs/promises'
|
|
|
2
2
|
import { homedir } from 'node:os'
|
|
3
3
|
import { resolve } from 'node:path'
|
|
4
4
|
import { shared } from './runtime.js'
|
|
5
|
+
import { createArgonDiagnosticTracker } from './diagnostics.js'
|
|
5
6
|
const { LlmAdapter, LlmError, resolveRetryPolicy, resolveImageAttachmentAccess } = await shared('@deepseek-ai/dsh-llm')
|
|
6
7
|
const { PiAiAdapter } = await shared('@deepseek-ai/dsh-llm-pi-ai')
|
|
7
8
|
const { launchEnvironmentOf } = await shared('@deepseek-ai/dsh-launch-environment')
|
|
@@ -142,6 +143,7 @@ function waitWithAbort(delayMs, signal) {
|
|
|
142
143
|
async function continueArgonRequestStream(apiClient, origRequestStream, request, meta) {
|
|
143
144
|
const { [ARGON_LONG_DECODE_SYMBOL]: _, ...restHttpOptions } = request?.httpOptions ?? {}
|
|
144
145
|
const enableContinuation = meta?.enabled !== false
|
|
146
|
+
const tracker = meta?.tracker
|
|
145
147
|
if (
|
|
146
148
|
enableContinuation &&
|
|
147
149
|
typeof apiClient?.isVertexAI === 'function' &&
|
|
@@ -151,10 +153,29 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
151
153
|
) {
|
|
152
154
|
restHttpOptions.apiVersion = 'v1beta1'
|
|
153
155
|
}
|
|
156
|
+
const effectiveApiVersion =
|
|
157
|
+
restHttpOptions.apiVersion || apiClient?.clientOptions?.httpOptions?.apiVersion || 'v1beta1'
|
|
158
|
+
tracker?.setApiVersion(effectiveApiVersion)
|
|
154
159
|
const hopHttpOptions = Object.keys(restHttpOptions).length > 0 ? restHttpOptions : undefined
|
|
155
160
|
const firstReq = { ...request, httpOptions: hopHttpOptions }
|
|
156
|
-
const
|
|
157
|
-
|
|
161
|
+
const hop1Tracker = tracker?.beginHop({
|
|
162
|
+
hopIndex: 1,
|
|
163
|
+
trigger: 'initial',
|
|
164
|
+
usedContinuationToken: false,
|
|
165
|
+
backoffDelayMs: 0,
|
|
166
|
+
body: firstReq.body,
|
|
167
|
+
})
|
|
168
|
+
let firstStream
|
|
169
|
+
try {
|
|
170
|
+
firstStream = await origRequestStream.call(apiClient, firstReq)
|
|
171
|
+
} catch (error) {
|
|
172
|
+
hop1Tracker?.finish({
|
|
173
|
+
error,
|
|
174
|
+
aborted: isAbortedError(error, request?.abortSignal),
|
|
175
|
+
})
|
|
176
|
+
throw error
|
|
177
|
+
}
|
|
178
|
+
if (!enableContinuation && !tracker) return firstStream
|
|
158
179
|
|
|
159
180
|
return (async function* () {
|
|
160
181
|
let baseBodyObj
|
|
@@ -163,6 +184,9 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
163
184
|
let consecutiveReconnectFailures = 0
|
|
164
185
|
let lastError
|
|
165
186
|
let hopCount = 0
|
|
187
|
+
let nextHopTrigger = 'initial'
|
|
188
|
+
let nextHopBackoffMs = 0
|
|
189
|
+
let nextHopBody = firstReq.body
|
|
166
190
|
let initialPromptTokens
|
|
167
191
|
let initialCachedTokens
|
|
168
192
|
let completedCandidatesTokens = 0
|
|
@@ -176,6 +200,16 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
176
200
|
while (true) {
|
|
177
201
|
hopCount += 1
|
|
178
202
|
const hopStartToken = resumeToken
|
|
203
|
+
const hopTracker =
|
|
204
|
+
hopCount === 1
|
|
205
|
+
? hop1Tracker
|
|
206
|
+
: tracker?.beginHop({
|
|
207
|
+
hopIndex: hopCount,
|
|
208
|
+
trigger: nextHopTrigger,
|
|
209
|
+
usedContinuationToken: Boolean(hopStartToken),
|
|
210
|
+
backoffDelayMs: nextHopBackoffMs,
|
|
211
|
+
body: nextHopBody,
|
|
212
|
+
})
|
|
179
213
|
let hopToken
|
|
180
214
|
let hopFinishReason
|
|
181
215
|
let hopHasPromptFeedback = false
|
|
@@ -197,6 +231,13 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
197
231
|
}
|
|
198
232
|
let outRaw = raw
|
|
199
233
|
const candidate = Array.isArray(raw.candidates) ? raw.candidates[0] : undefined
|
|
234
|
+
hopTracker?.onChunk({
|
|
235
|
+
status: 200,
|
|
236
|
+
hasCheckpoint: Boolean(
|
|
237
|
+
candidate && typeof candidate.continuationToken === 'string' && candidate.continuationToken.length > 0,
|
|
238
|
+
),
|
|
239
|
+
finishReason: candidate?.finishReason,
|
|
240
|
+
})
|
|
200
241
|
if (candidate && typeof candidate === 'object') {
|
|
201
242
|
if (typeof candidate.continuationToken === 'string' && candidate.continuationToken.length > 0) {
|
|
202
243
|
hopToken = candidate.continuationToken
|
|
@@ -210,6 +251,7 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
210
251
|
hopHasYieldedContent = true
|
|
211
252
|
}
|
|
212
253
|
const canContinueHop =
|
|
254
|
+
enableContinuation &&
|
|
213
255
|
!hopHasPromptFeedback &&
|
|
214
256
|
Boolean(hopToken) &&
|
|
215
257
|
hopToken !== hopStartToken &&
|
|
@@ -286,13 +328,29 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
286
328
|
completedBilledPromptTokens += hopUsage.prompt
|
|
287
329
|
completedBilledCachedTokens += hopUsage.cached
|
|
288
330
|
completedBilledTotalTokens += hopUsage.total
|
|
331
|
+
tracker?.recordTokenUsage({
|
|
332
|
+
reportedInputTokens: initialPromptTokens,
|
|
333
|
+
reportedCacheTokens: initialCachedTokens ?? 0,
|
|
334
|
+
outputTokens: completedCandidatesTokens,
|
|
335
|
+
thoughtsTokens: completedThoughtsTokens,
|
|
336
|
+
billedPromptTokens: completedBilledPromptTokens,
|
|
337
|
+
billedCachedTokens: completedBilledCachedTokens,
|
|
338
|
+
billedTotalTokens: completedBilledTotalTokens,
|
|
339
|
+
})
|
|
289
340
|
}
|
|
290
341
|
|
|
342
|
+
const abortedHop = Boolean(hopError && isAbortedError(hopError.error, request?.abortSignal))
|
|
291
343
|
if (
|
|
292
344
|
hopError &&
|
|
293
|
-
(
|
|
345
|
+
(abortedHop ||
|
|
294
346
|
isNonRetryableApiRejection(hopError.error, hopReceivedAnyChunk, hopCount, Boolean(hopToken || hopStartToken)))
|
|
295
347
|
) {
|
|
348
|
+
hopTracker?.finish({
|
|
349
|
+
error: hopError.error,
|
|
350
|
+
aborted: abortedHop,
|
|
351
|
+
finishReason: hopFinishReason,
|
|
352
|
+
continued: false,
|
|
353
|
+
})
|
|
296
354
|
throw hopError.error
|
|
297
355
|
}
|
|
298
356
|
|
|
@@ -301,13 +359,14 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
301
359
|
if (hopError) lastError = hopError
|
|
302
360
|
else if (madeProgress) lastError = undefined
|
|
303
361
|
|
|
304
|
-
if (hopCount >= MAX_CONTINUATION_HOPS || hopHasPromptFeedback) {
|
|
362
|
+
if (!enableContinuation || hopCount >= MAX_CONTINUATION_HOPS || hopHasPromptFeedback) {
|
|
305
363
|
resumeToken = undefined
|
|
306
364
|
} else if (hopFinishReason !== undefined) {
|
|
307
365
|
if (hopFinishReason === 'CONTINUATION' && hasNewToken) {
|
|
308
366
|
resumeToken = hopToken
|
|
309
367
|
reconnectsWithoutProgress = 0
|
|
310
368
|
consecutiveReconnectFailures = hopError ? 1 : 0
|
|
369
|
+
nextHopTrigger = hopError ? 'checkpoint-reconnect' : 'continuation'
|
|
311
370
|
} else {
|
|
312
371
|
resumeToken = undefined
|
|
313
372
|
reconnectsWithoutProgress = 0
|
|
@@ -317,28 +376,42 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
317
376
|
resumeToken = hopToken
|
|
318
377
|
reconnectsWithoutProgress = 0
|
|
319
378
|
consecutiveReconnectFailures = 1
|
|
379
|
+
nextHopTrigger = 'checkpoint-reconnect'
|
|
320
380
|
} else if (!hopHasYieldedContent && hopStartToken && reconnectsWithoutProgress < MAX_STREAM_RECONNECTS_WITHOUT_PROGRESS) {
|
|
321
381
|
resumeToken = hopStartToken
|
|
322
382
|
reconnectsWithoutProgress += 1
|
|
323
383
|
consecutiveReconnectFailures += 1
|
|
384
|
+
nextHopTrigger = 'retry-same-checkpoint'
|
|
324
385
|
} else {
|
|
325
386
|
resumeToken = undefined
|
|
326
387
|
}
|
|
327
388
|
|
|
328
389
|
const canResume =
|
|
390
|
+
enableContinuation &&
|
|
329
391
|
Boolean(resumeToken) &&
|
|
330
392
|
!hopHasPromptFeedback &&
|
|
331
393
|
(hopFinishReason === 'CONTINUATION' || hopFinishReason === undefined)
|
|
332
394
|
|
|
395
|
+
hopTracker?.finish({
|
|
396
|
+
error: hopError?.error,
|
|
397
|
+
aborted: false,
|
|
398
|
+
finishReason: hopFinishReason,
|
|
399
|
+
continued: canResume && hopFinishReason === 'CONTINUATION' && !hopError,
|
|
400
|
+
})
|
|
401
|
+
|
|
333
402
|
if (canResume) {
|
|
403
|
+
let delayMs = 0
|
|
334
404
|
if (consecutiveReconnectFailures > 0) {
|
|
335
|
-
|
|
405
|
+
delayMs = computeReconnectDelayMs(consecutiveReconnectFailures, meta?.reconnectBackoff)
|
|
336
406
|
await waitWithAbort(delayMs, request?.abortSignal)
|
|
337
407
|
}
|
|
338
408
|
if (!baseBodyObj) baseBodyObj = JSON.parse(request.body)
|
|
409
|
+
const nextBody = JSON.stringify({ ...baseBodyObj, continuationToken: resumeToken })
|
|
410
|
+
nextHopBackoffMs = delayMs
|
|
411
|
+
nextHopBody = nextBody
|
|
339
412
|
const nextReq = {
|
|
340
413
|
...request,
|
|
341
|
-
body:
|
|
414
|
+
body: nextBody,
|
|
342
415
|
httpOptions: hopHttpOptions,
|
|
343
416
|
}
|
|
344
417
|
openHop = () => origRequestStream.call(apiClient, nextReq)
|
|
@@ -393,24 +466,49 @@ export function ensureGemini4ApiClientPatch() {
|
|
|
393
466
|
}
|
|
394
467
|
}
|
|
395
468
|
|
|
396
|
-
function wrapGemini4Stream(rawStream) {
|
|
469
|
+
function wrapGemini4Stream(rawStream, tracker, signal) {
|
|
397
470
|
if (!rawStream || typeof rawStream[Symbol.asyncIterator] !== 'function') return rawStream
|
|
398
471
|
return {
|
|
399
472
|
[Symbol.asyncIterator]: async function* () {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
473
|
+
try {
|
|
474
|
+
for await (const event of rawStream) {
|
|
475
|
+
if (event?.type === 'done') {
|
|
476
|
+
const stop = event.message?.stopReason
|
|
477
|
+
const outcome = stop === 'toolUse' ? 'tool-calls' : stop === 'length' ? 'max-tokens' : 'done'
|
|
478
|
+
tracker?.finishStream({ outcome })
|
|
479
|
+
} else if (event?.type === 'error') {
|
|
480
|
+
const isTransient =
|
|
481
|
+
typeof event?.error?.errorMessage === 'string' &&
|
|
482
|
+
TRANSIENT_GEMINI_STOP_RE.test(event.error.errorMessage)
|
|
483
|
+
tracker?.finishStream({
|
|
484
|
+
outcome: signal?.aborted ? 'aborted' : 'error',
|
|
485
|
+
error: event.error,
|
|
486
|
+
transientFinishReason: isTransient,
|
|
487
|
+
})
|
|
488
|
+
if (isTransient) {
|
|
489
|
+
yield {
|
|
490
|
+
...event,
|
|
491
|
+
error: {
|
|
492
|
+
...event.error,
|
|
493
|
+
errorMessage: `${event.error.errorMessage} (502 upstream transient finishReason)`,
|
|
494
|
+
},
|
|
495
|
+
}
|
|
496
|
+
continue
|
|
497
|
+
}
|
|
408
498
|
}
|
|
409
|
-
|
|
499
|
+
yield event
|
|
410
500
|
}
|
|
411
|
-
|
|
501
|
+
} catch (error) {
|
|
502
|
+
tracker?.finishStream({
|
|
503
|
+
outcome: signal?.aborted ? 'aborted' : 'error',
|
|
504
|
+
error,
|
|
505
|
+
})
|
|
506
|
+
throw error
|
|
507
|
+
} finally {
|
|
508
|
+
tracker?.finalize(Boolean(signal?.aborted))
|
|
412
509
|
}
|
|
413
510
|
},
|
|
511
|
+
...(typeof rawStream.result === 'function' ? { result: rawStream.result.bind(rawStream) } : {}),
|
|
414
512
|
}
|
|
415
513
|
}
|
|
416
514
|
|
|
@@ -422,6 +520,7 @@ export function gemini4StreamSimple(
|
|
|
422
520
|
defaultLevel = 'medium',
|
|
423
521
|
upstreamModelId = requestModel.id,
|
|
424
522
|
longDecode = true,
|
|
523
|
+
recordDiagnostic,
|
|
425
524
|
) {
|
|
426
525
|
ensureGemini4ApiClientPatch()
|
|
427
526
|
const fallback = defaultLevel ?? (/cyber-permissive/i.test(requestModel?.id ?? '') ? 'high' : 'medium')
|
|
@@ -435,41 +534,60 @@ export function gemini4StreamSimple(
|
|
|
435
534
|
longDecode === false && typeof requestedMaxTokens === 'number' && requestedMaxTokens > MAX_SINGLE_CALL_TOKENS
|
|
436
535
|
? MAX_SINGLE_CALL_TOKENS
|
|
437
536
|
: requestedMaxTokens
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
if (body.model !== requestModel.id && body.model !== upstreamModelId) {
|
|
448
|
-
throw new LlmError('Gemini 4 Argon received an incompatible model payload.', 'INVALID_REQUEST')
|
|
449
|
-
}
|
|
450
|
-
const { temperature: _t, topP: _tp, topK: _tk, candidateCount: _cc, frequencyPenalty: _fp, presencePenalty: _pp, ...cleanConfig } = body.config
|
|
451
|
-
const prevHttpOptions =
|
|
452
|
-
cleanConfig.httpOptions && typeof cleanConfig.httpOptions === 'object' && !Array.isArray(cleanConfig.httpOptions)
|
|
453
|
-
? cleanConfig.httpOptions
|
|
454
|
-
: {}
|
|
455
|
-
return {
|
|
456
|
-
...body,
|
|
457
|
-
model: upstreamModelId,
|
|
458
|
-
config: {
|
|
459
|
-
...cleanConfig,
|
|
460
|
-
automaticContinuation: false,
|
|
461
|
-
thinkingConfig: { thinkingLevel: level.toUpperCase(), includeThoughts: true },
|
|
462
|
-
httpOptions: {
|
|
463
|
-
...prevHttpOptions,
|
|
464
|
-
[ARGON_LONG_DECODE_SYMBOL]: { enabled: longDecode !== false },
|
|
465
|
-
},
|
|
466
|
-
},
|
|
467
|
-
}
|
|
537
|
+
const tracker = createArgonDiagnosticTracker(
|
|
538
|
+
{
|
|
539
|
+
model: requestModel?.id,
|
|
540
|
+
route: requestModel?.api,
|
|
541
|
+
apiVersion: longDecode === false ? 'v1' : 'v1beta1',
|
|
542
|
+
thinkingLevel: level.toUpperCase(),
|
|
543
|
+
longDecode: longDecode !== false,
|
|
544
|
+
maxTokens: effectiveMaxTokens,
|
|
545
|
+
sessionId: options.sessionId,
|
|
468
546
|
},
|
|
469
|
-
|
|
547
|
+
recordDiagnostic,
|
|
548
|
+
)
|
|
549
|
+
return wrapGemini4Stream(
|
|
550
|
+
nativeStream(requestModel, context, {
|
|
551
|
+
...rest,
|
|
552
|
+
maxTokens: effectiveMaxTokens,
|
|
553
|
+
async onPayload(payload, payloadModel) {
|
|
554
|
+
const replacement = await prior?.(payload, payloadModel)
|
|
555
|
+
const body = replacement === undefined ? payload : replacement
|
|
556
|
+
if (!body || typeof body !== 'object' || Array.isArray(body) || !Array.isArray(body.contents) || !body.config || typeof body.config !== 'object' || Array.isArray(body.config)) {
|
|
557
|
+
throw new LlmError('Gemini 4 Argon received an incompatible native payload.', 'INVALID_REQUEST')
|
|
558
|
+
}
|
|
559
|
+
if (body.model !== requestModel.id && body.model !== upstreamModelId) {
|
|
560
|
+
throw new LlmError('Gemini 4 Argon received an incompatible model payload.', 'INVALID_REQUEST')
|
|
561
|
+
}
|
|
562
|
+
const { temperature: _t, topP: _tp, topK: _tk, candidateCount: _cc, frequencyPenalty: _fp, presencePenalty: _pp, ...cleanConfig } = body.config
|
|
563
|
+
const prevHttpOptions =
|
|
564
|
+
cleanConfig.httpOptions && typeof cleanConfig.httpOptions === 'object' && !Array.isArray(cleanConfig.httpOptions)
|
|
565
|
+
? cleanConfig.httpOptions
|
|
566
|
+
: {}
|
|
567
|
+
return {
|
|
568
|
+
...body,
|
|
569
|
+
model: upstreamModelId,
|
|
570
|
+
config: {
|
|
571
|
+
...cleanConfig,
|
|
572
|
+
automaticContinuation: false,
|
|
573
|
+
thinkingConfig: { thinkingLevel: level.toUpperCase(), includeThoughts: true },
|
|
574
|
+
httpOptions: {
|
|
575
|
+
...prevHttpOptions,
|
|
576
|
+
[ARGON_LONG_DECODE_SYMBOL]: {
|
|
577
|
+
enabled: longDecode !== false,
|
|
578
|
+
tracker,
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
},
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
}),
|
|
585
|
+
tracker,
|
|
586
|
+
options.signal,
|
|
587
|
+
)
|
|
470
588
|
}
|
|
471
589
|
|
|
472
|
-
export function installGemini4PiAiPatch() {
|
|
590
|
+
export function installGemini4PiAiPatch(recordDiagnostic) {
|
|
473
591
|
const unpatchApiClient = ensureGemini4ApiClientPatch()
|
|
474
592
|
const proto = PiAiAdapter?.prototype
|
|
475
593
|
if (!proto || typeof proto.current !== 'function') return unpatchApiClient
|
|
@@ -494,7 +612,7 @@ export function installGemini4PiAiPatch() {
|
|
|
494
612
|
patchedProviders.set(piProvider, origStreamSimple)
|
|
495
613
|
piProvider.streamSimple = function (requestModel, context, options = {}) {
|
|
496
614
|
if (isGemini4Model(requestModel)) {
|
|
497
|
-
return gemini4StreamSimple((m, c, o) => piProvider.stream(m, c, o), requestModel, context, options, defaultReasoning, requestModel.id, true)
|
|
615
|
+
return gemini4StreamSimple((m, c, o) => piProvider.stream(m, c, o), requestModel, context, options, defaultReasoning, requestModel.id, true, recordDiagnostic)
|
|
498
616
|
}
|
|
499
617
|
return origStreamSimple.call(this, requestModel, context, options)
|
|
500
618
|
}
|
|
@@ -545,7 +663,7 @@ export function resolveConfigValues(raw = {}) {
|
|
|
545
663
|
}
|
|
546
664
|
|
|
547
665
|
/** Serve both Vertex AI Argon and Gemini API (google) Argon under the unified plugin group. */
|
|
548
|
-
export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nativeGoogle = googleProvider(), longDecode = true) {
|
|
666
|
+
export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nativeGoogle = googleProvider(), longDecode = true, recordDiagnostic) {
|
|
549
667
|
const modelMap = new Map((Array.isArray(models) ? models : [models]).map(m => [m.id, m]))
|
|
550
668
|
return {
|
|
551
669
|
id: PROVIDER,
|
|
@@ -571,6 +689,7 @@ export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nat
|
|
|
571
689
|
defaultLevel,
|
|
572
690
|
MODEL,
|
|
573
691
|
longDecode,
|
|
692
|
+
recordDiagnostic,
|
|
574
693
|
)
|
|
575
694
|
}
|
|
576
695
|
if (requestModel.api !== 'google-vertex') {
|
|
@@ -584,6 +703,7 @@ export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nat
|
|
|
584
703
|
defaultLevel,
|
|
585
704
|
MODEL,
|
|
586
705
|
longDecode,
|
|
706
|
+
recordDiagnostic,
|
|
587
707
|
)
|
|
588
708
|
},
|
|
589
709
|
}
|
|
@@ -607,7 +727,7 @@ export class ArgonAdapter extends LlmAdapter {
|
|
|
607
727
|
stream(options) { return this.inner.stream(options) }
|
|
608
728
|
}
|
|
609
729
|
|
|
610
|
-
export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertexProvider(), nativeGoogle = googleProvider()) {
|
|
730
|
+
export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertexProvider(), nativeGoogle = googleProvider(), recordDiagnostic) {
|
|
611
731
|
resolveConfigValues(configInput)
|
|
612
732
|
const environment = launchEnvironmentOf(ctx)
|
|
613
733
|
const resolveSecret = async name => {
|
|
@@ -698,7 +818,7 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
|
|
|
698
818
|
})
|
|
699
819
|
}
|
|
700
820
|
const configuredMaxTokens = new Map(models.map(m => [m.id, cfg.maxTokens]))
|
|
701
|
-
const provider = argonProvider({ ...nativeVertex, auth }, models, cfg.reasoning, nativeGoogle, cfg.longDecode)
|
|
821
|
+
const provider = argonProvider({ ...nativeVertex, auth }, models, cfg.reasoning, nativeGoogle, cfg.longDecode, recordDiagnostic)
|
|
702
822
|
cachedKey = key
|
|
703
823
|
cachedProfiles = new Map([[PROVIDER, {
|
|
704
824
|
provider: PROVIDER,
|