@agentdocumentformat/cli 0.7.8 → 0.8.1
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/dist/adf.mjs +59 -8
- package/dist/chunks/{APEv2Parser-2CNNHMXV.mjs → APEv2Parser-WIXRJLHB.mjs} +2 -2
- package/dist/chunks/{AiffParser-7BR4RL6G.mjs → AiffParser-ZC4QFOVJ.mjs} +5 -5
- package/dist/chunks/{App-7RIIOHJJ.mjs → App-4AZZJNN2.mjs} +917 -826
- package/dist/chunks/{DsdiffParser-CMD4AX7A.mjs → DsdiffParser-UAPAJHFX.mjs} +5 -5
- package/dist/chunks/{DsfParser-UOGZDS2M.mjs → DsfParser-NNYZK2QX.mjs} +6 -6
- package/dist/chunks/{FlacParser-HB3T3CD4.mjs → FlacParser-MW2W4LO3.mjs} +6 -6
- package/dist/chunks/{MP4Parser-66HBRUSX.mjs → MP4Parser-Z57SYOOQ.mjs} +4 -4
- package/dist/chunks/{MpegParser-YW6LIUEW.mjs → MpegParser-XIIPAZVM.mjs} +7 -7
- package/dist/chunks/{MusepackParser-PAUSXP7D.mjs → MusepackParser-QWNDEYHJ.mjs} +6 -6
- package/dist/chunks/{OggParser-NUBV3GWC.mjs → OggParser-WRX53F77.mjs} +9 -9
- package/dist/chunks/{WavPackParser-WQAGT7TC.mjs → WavPackParser-MJ7WCSJ5.mjs} +2 -2
- package/dist/chunks/{WaveParser-EWLQVDX4.mjs → WaveParser-RAVLHZ5S.mjs} +7 -7
- package/dist/chunks/{adf-schema-US4NFHMR.mjs → adf-schema-AIPBQTR2.mjs} +9 -3
- package/dist/chunks/auth-manager-AJ32FZWS.mjs +19 -0
- package/dist/chunks/auth-manager-C5OBEQK2.mjs +18 -0
- package/dist/chunks/auth-manager-TBNKCJ45.mjs +17 -0
- package/dist/chunks/{chatgpt-subscription-E4MXTIAT.mjs → chatgpt-subscription-MMGNW5KJ.mjs} +5 -2
- package/dist/chunks/chunk-2Z7X3UUR.mjs +678 -0
- package/dist/chunks/chunk-3UGZFWIF.mjs +26 -0
- package/dist/chunks/{chunk-XNPZBLYL.mjs → chunk-75DC5EWN.mjs} +13 -2
- package/dist/chunks/{chunk-5PO5PKRV.mjs → chunk-7JZXMDDF.mjs} +158 -67
- package/dist/chunks/chunk-AEAJDCVK.mjs +517 -0
- package/dist/chunks/{chunk-6VQEXLE2.mjs → chunk-BHY7QDCM.mjs} +41 -3
- package/dist/chunks/{chunk-CD3ATSXE.mjs → chunk-BR3AD5QZ.mjs} +8 -2
- package/dist/chunks/chunk-BS3USVEA.mjs +301 -0
- package/dist/chunks/chunk-C2S64Y6F.mjs +203 -0
- package/dist/chunks/chunk-D7A77SNL.mjs +976 -0
- package/dist/chunks/chunk-DDTTSKGG.mjs +2443 -0
- package/dist/chunks/{chunk-VAUOM3IN.mjs → chunk-DLWCKKIO.mjs} +1 -1
- package/dist/chunks/{chunk-G6PH7RPW.mjs → chunk-E7LC6SHP.mjs} +3 -3
- package/dist/chunks/{chunk-ZESQMP66.mjs → chunk-F3WSCAJD.mjs} +3 -3
- package/dist/chunks/{chunk-KXEF4F4E.mjs → chunk-GAZO6UMI.mjs} +1 -1
- package/dist/chunks/{chunk-XYTWGHFS.mjs → chunk-H3XLRWVE.mjs} +1 -1
- package/dist/chunks/{chunk-7T2YMTWL.mjs → chunk-H4C65MTP.mjs} +4 -4
- package/dist/chunks/chunk-HBOFZRUS.mjs +738 -0
- package/dist/chunks/{chunk-VN7UH7I5.mjs → chunk-IMVMSU3A.mjs} +251 -68
- package/dist/chunks/{chunk-XYV3VCIX.mjs → chunk-JZFONJSL.mjs} +79 -20
- package/dist/chunks/chunk-KCIRFUZH.mjs +12799 -0
- package/dist/chunks/chunk-KDDVQKCG.mjs +65 -0
- package/dist/chunks/chunk-KRPKWOMB.mjs +290 -0
- package/dist/chunks/chunk-LKFHERRV.mjs +145 -0
- package/dist/chunks/chunk-LTX74NU6.mjs +29 -0
- package/dist/chunks/{chunk-HSBV6YFU.mjs → chunk-LVF2DRBR.mjs} +634 -99
- package/dist/chunks/chunk-M2F7C2UJ.mjs +425 -0
- package/dist/chunks/{chunk-62NE4LG4.mjs → chunk-MQAMI5BF.mjs} +5 -5
- package/dist/chunks/chunk-MZRXFWPQ.mjs +278 -0
- package/dist/chunks/{chunk-PRMGZZM5.mjs → chunk-NZLEPJ5M.mjs} +2 -0
- package/dist/chunks/{chunk-I3UYSITV.mjs → chunk-O7XKQ6CH.mjs} +1 -1
- package/dist/chunks/chunk-P3RG5LQA.mjs +244 -0
- package/dist/chunks/chunk-PAK5JCO2.mjs +48 -0
- package/dist/chunks/chunk-PC63YFB7.mjs +34 -0
- package/dist/chunks/{daemon-control-HKFVSQTQ.mjs → chunk-RHBGCOS3.mjs} +67 -26
- package/dist/chunks/{chunk-J74STFKE.mjs → chunk-RJDOVMM4.mjs} +362 -58
- package/dist/chunks/{chunk-QPLEAE6V.mjs → chunk-SOSPQPEN.mjs} +167 -650
- package/dist/chunks/{chunk-LFMB4PAA.mjs → chunk-TKXIH27X.mjs} +974 -113
- package/dist/chunks/{chunk-5W7KES6P.mjs → chunk-UZPDETEU.mjs} +1 -1
- package/dist/chunks/chunk-V3MM6PCH.mjs +366 -0
- package/dist/chunks/chunk-VENQBMOA.mjs +62 -0
- package/dist/chunks/chunk-WJGPNHGX.mjs +67 -0
- package/dist/chunks/{chunk-Y5ZLKFLE.mjs → chunk-XNNJQCZP.mjs} +196 -165
- package/dist/chunks/{chunk-HDBPBORT.mjs → chunk-YRBFIDLB.mjs} +46 -10
- package/dist/chunks/{chunk-BNXUAOO4.mjs → chunk-ZGXUOAWZ.mjs} +3186 -959
- package/dist/chunks/chunk-ZPB3HYM7.mjs +45 -0
- package/dist/chunks/claude-subscription-EB4LAAVV.mjs +29 -0
- package/dist/chunks/{cli-NMFIAR7Z.mjs → cli-PCVFB6B4.mjs} +797 -56
- package/dist/chunks/{commands-KPJWFRUE.mjs → commands-KOMPXJZS.mjs} +4 -3
- package/dist/chunks/{daemon-YDIK3AAM.mjs → daemon-BVDB565V.mjs} +83142 -64424
- package/dist/chunks/daemon-control-MKN7G5M3.mjs +59 -0
- package/dist/chunks/{daemon-token-WRSULP7G.mjs → daemon-token-L5QKTHU5.mjs} +3 -1
- package/dist/chunks/{discord-DSP4HUWI.mjs → discord-IR62565M.mjs} +3 -52
- package/dist/chunks/{email-BRG7KUO2.mjs → email-KHHTJBDW.mjs} +4 -2
- package/dist/chunks/{grok-subscription-4PYX7TBF.mjs → grok-subscription-E74FS5EG.mjs} +5 -2
- package/dist/chunks/{layout-EPJQNFAI.mjs → layout-ECWGJF6M.mjs} +2 -2
- package/dist/chunks/{lib-N7FCZWKH.mjs → lib-L27L5PXM.mjs} +22 -22
- package/dist/chunks/{open-VAU7PXT6.mjs → open-3OR6WT4T.mjs} +6 -6
- package/dist/chunks/{parser-JVY2PWSM.mjs → parser-7GARNT5L.mjs} +1 -1
- package/dist/chunks/{pipeline-executor-O77NTGLP.mjs → pipeline-executor-DRYEEFDR.mjs} +6 -5
- package/dist/chunks/prompt-RRHZX4YT.mjs +13 -0
- package/dist/chunks/remote-access-cli-GLEEP7DI.mjs +268 -0
- package/dist/chunks/remote-hello-UFWUBDQI.mjs +37 -0
- package/dist/chunks/sdk-OJOAF4DP.mjs +30014 -0
- package/dist/chunks/{slack-OCNNF4DX.mjs → slack-IYC5RAB5.mjs} +3 -4
- package/dist/chunks/{store-HUVDJPYN.mjs → store-55CQSAOX.mjs} +7 -3
- package/dist/chunks/tailscale-WLJATFMB.mjs +25 -0
- package/dist/chunks/{theme-SFE3JMA2.mjs → theme-HLBDTF6F.mjs} +1 -1
- package/dist/chunks/{themes-YLXLOIJF.mjs → themes-BQ72P446.mjs} +2 -2
- package/dist/chunks/{token-6G3HCMNX.mjs → token-6D22WECM.mjs} +20 -16
- package/dist/chunks/{token-util-UXYSDQIW.mjs → token-util-YF3ZWBZ4.mjs} +1 -2
- package/dist/chunks/{tui-UQJLK7XI.mjs → tui-RAUVFOYY.mjs} +21 -18
- package/dist/chunks/{welcome-XHXFV7SH.mjs → welcome-J5JZZAM5.mjs} +1 -1
- package/dist/chunks/{whatsapp-AJMRQBT7.mjs → whatsapp-YJFFVN4Q.mjs} +9 -9
- package/package.json +1 -1
- package/dist/chunks/chunk-GKKCMXIZ.mjs +0 -94
- package/dist/chunks/chunk-IHDDCZBS.mjs +0 -112
- package/dist/chunks/chunk-KWFOS5WC.mjs +0 -41
- package/dist/chunks/chunk-UEZR2CNS.mjs +0 -65
- package/dist/chunks/chunk-VMHTYDH4.mjs +0 -172
- package/dist/chunks/chunk-Y2QA53AN.mjs +0 -259
- package/dist/chunks/{chunk-NBTUWMGP.mjs → chunk-2MTE22CR.mjs} +3 -3
- package/dist/chunks/{chunk-APRU6PHC.mjs → chunk-JZ7AQNPM.mjs} +3 -3
- package/dist/chunks/{telegram-2EFGKIVK.mjs → telegram-JYY2VDTI.mjs} +5 -5
|
@@ -5,8 +5,10 @@ const require = __adfCreateRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __adfDirname(__filename);
|
|
7
7
|
import {
|
|
8
|
+
IMAGE_ONLY_MEDIA,
|
|
8
9
|
InvalidPromptError,
|
|
9
10
|
InvalidResponseDataError,
|
|
11
|
+
StreamingToolCallTracker,
|
|
10
12
|
TooManyEmbeddingValuesForCallError,
|
|
11
13
|
UnsupportedFunctionalityError,
|
|
12
14
|
combineHeaders,
|
|
@@ -19,15 +21,21 @@ import {
|
|
|
19
21
|
downloadBlob,
|
|
20
22
|
external_exports,
|
|
21
23
|
generateId,
|
|
22
|
-
isParsableJson,
|
|
23
24
|
parseProviderOptions,
|
|
24
25
|
postFormDataToApi,
|
|
25
26
|
postJsonToApi,
|
|
26
27
|
withUserAgentSuffix,
|
|
27
28
|
withoutTrailingSlash
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-TKXIH27X.mjs";
|
|
29
30
|
|
|
30
31
|
// node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
32
|
+
function toCamelCase(str) {
|
|
33
|
+
return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
|
|
34
|
+
}
|
|
35
|
+
function resolveProviderOptionsKey(rawName, providerOptions) {
|
|
36
|
+
let camelName = toCamelCase(rawName);
|
|
37
|
+
return camelName !== rawName && providerOptions?.[camelName] != null ? camelName : rawName;
|
|
38
|
+
}
|
|
31
39
|
var openaiCompatibleErrorDataSchema = external_exports.object({
|
|
32
40
|
error: external_exports.object({
|
|
33
41
|
message: external_exports.string(),
|
|
@@ -69,7 +77,7 @@ function convertOpenAICompatibleChatUsage(usage) {
|
|
|
69
77
|
},
|
|
70
78
|
outputTokens: {
|
|
71
79
|
total: completionTokens,
|
|
72
|
-
text: completionTokens - reasoningTokens,
|
|
80
|
+
text: Math.max(0, completionTokens - reasoningTokens),
|
|
73
81
|
reasoning: reasoningTokens
|
|
74
82
|
},
|
|
75
83
|
raw: usage
|
|
@@ -164,7 +172,9 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
164
172
|
if (part.mediaType.startsWith("text/"))
|
|
165
173
|
return {
|
|
166
174
|
type: "text",
|
|
167
|
-
text: part.data instanceof URL ? part.data.toString() : typeof part.data == "string" ?
|
|
175
|
+
text: part.data instanceof URL ? part.data.toString() : typeof part.data == "string" ? new TextDecoder().decode(
|
|
176
|
+
convertBase64ToUint8Array(part.data)
|
|
177
|
+
) : new TextDecoder().decode(part.data),
|
|
168
178
|
...partMetadata
|
|
169
179
|
};
|
|
170
180
|
throw new UnsupportedFunctionalityError({
|
|
@@ -215,7 +225,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
215
225
|
}
|
|
216
226
|
messages.push({
|
|
217
227
|
role: "assistant",
|
|
218
|
-
content: text,
|
|
228
|
+
content: toolCalls.length > 0 ? text || null : text,
|
|
219
229
|
...reasoning.length > 0 ? { reasoning_content: reasoning } : {},
|
|
220
230
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
221
231
|
...metadata
|
|
@@ -233,7 +243,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
233
243
|
contentValue = output.value;
|
|
234
244
|
break;
|
|
235
245
|
case "execution-denied":
|
|
236
|
-
contentValue = (_c = output.reason) != null ? _c : "Tool execution denied.";
|
|
246
|
+
contentValue = (_c = output.reason) != null ? _c : "Tool call execution denied.";
|
|
237
247
|
break;
|
|
238
248
|
case "content":
|
|
239
249
|
case "json":
|
|
@@ -285,7 +295,7 @@ function mapOpenAICompatibleFinishReason(finishReason) {
|
|
|
285
295
|
return "other";
|
|
286
296
|
}
|
|
287
297
|
}
|
|
288
|
-
var
|
|
298
|
+
var openaiCompatibleLanguageModelChatOptions = external_exports.object({
|
|
289
299
|
/**
|
|
290
300
|
* A unique identifier representing your end-user, which can help the provider to
|
|
291
301
|
* monitor and detect abuse.
|
|
@@ -380,6 +390,10 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
380
390
|
var _a, _b, _c;
|
|
381
391
|
return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
|
|
382
392
|
}
|
|
393
|
+
convertUsage(usage) {
|
|
394
|
+
var _a, _b, _c;
|
|
395
|
+
return (_c = (_b = (_a = this.config).convertUsage) == null ? void 0 : _b.call(_a, usage)) != null ? _c : convertOpenAICompatibleChatUsage(usage);
|
|
396
|
+
}
|
|
383
397
|
async getArgs({
|
|
384
398
|
prompt,
|
|
385
399
|
maxOutputTokens,
|
|
@@ -399,7 +413,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
399
413
|
let warnings = [], deprecatedOptions = await parseProviderOptions({
|
|
400
414
|
provider: "openai-compatible",
|
|
401
415
|
providerOptions,
|
|
402
|
-
schema:
|
|
416
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
403
417
|
});
|
|
404
418
|
deprecatedOptions != null && warnings.push({
|
|
405
419
|
type: "other",
|
|
@@ -410,14 +424,19 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
410
424
|
(_a = await parseProviderOptions({
|
|
411
425
|
provider: "openaiCompatible",
|
|
412
426
|
providerOptions,
|
|
413
|
-
schema:
|
|
427
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
414
428
|
})) != null ? _a : {},
|
|
415
429
|
(_b = await parseProviderOptions({
|
|
416
430
|
provider: this.providerOptionsName,
|
|
417
431
|
providerOptions,
|
|
418
|
-
schema:
|
|
419
|
-
})) != null ? _b : {}
|
|
420
|
-
|
|
432
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
433
|
+
})) != null ? _b : {},
|
|
434
|
+
(_c = await parseProviderOptions({
|
|
435
|
+
provider: toCamelCase(this.providerOptionsName),
|
|
436
|
+
providerOptions,
|
|
437
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
438
|
+
})) != null ? _c : {}
|
|
439
|
+
), strictJsonSchema = (_d = compatibleOptions?.strictJsonSchema) != null ? _d : !0;
|
|
421
440
|
topK != null && warnings.push({ type: "unsupported", feature: "topK" }), responseFormat?.type === "json" && responseFormat.schema != null && !this.supportsStructuredOutputs && warnings.push({
|
|
422
441
|
type: "unsupported",
|
|
423
442
|
feature: "responseFormat",
|
|
@@ -432,6 +451,10 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
432
451
|
toolChoice
|
|
433
452
|
});
|
|
434
453
|
return {
|
|
454
|
+
metadataKey: resolveProviderOptionsKey(
|
|
455
|
+
this.providerOptionsName,
|
|
456
|
+
providerOptions
|
|
457
|
+
),
|
|
435
458
|
args: {
|
|
436
459
|
// model id:
|
|
437
460
|
model: this.modelId,
|
|
@@ -448,17 +471,20 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
448
471
|
json_schema: {
|
|
449
472
|
schema: responseFormat.schema,
|
|
450
473
|
strict: strictJsonSchema,
|
|
451
|
-
name: (
|
|
474
|
+
name: (_e = responseFormat.name) != null ? _e : "response",
|
|
452
475
|
description: responseFormat.description
|
|
453
476
|
}
|
|
454
477
|
} : { type: "json_object" } : void 0,
|
|
455
478
|
stop: stopSequences,
|
|
456
479
|
seed,
|
|
457
480
|
...Object.fromEntries(
|
|
458
|
-
Object.entries(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
481
|
+
Object.entries({
|
|
482
|
+
...providerOptions?.[this.providerOptionsName],
|
|
483
|
+
...providerOptions?.[toCamelCase(this.providerOptionsName)]
|
|
484
|
+
}).filter(
|
|
485
|
+
([key]) => !Object.keys(
|
|
486
|
+
openaiCompatibleLanguageModelChatOptions.shape
|
|
487
|
+
).includes(key)
|
|
462
488
|
)
|
|
463
489
|
),
|
|
464
490
|
reasoning_effort: compatibleOptions.reasoningEffort,
|
|
@@ -474,7 +500,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
474
500
|
}
|
|
475
501
|
async doGenerate(options) {
|
|
476
502
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
477
|
-
let { args, warnings } = await this.getArgs({ ...options }), transformedBody = this.transformRequestBody(args), body = JSON.stringify(transformedBody), {
|
|
503
|
+
let { args, warnings, metadataKey } = await this.getArgs({ ...options }), transformedBody = this.transformRequestBody(args), body = JSON.stringify(transformedBody), {
|
|
478
504
|
responseHeaders,
|
|
479
505
|
value: responseBody,
|
|
480
506
|
rawValue: rawResponse
|
|
@@ -491,8 +517,14 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
491
517
|
),
|
|
492
518
|
abortSignal: options.abortSignal,
|
|
493
519
|
fetch: this.config.fetch
|
|
494
|
-
}), choice = responseBody.choices[0]
|
|
495
|
-
|
|
520
|
+
}), choice = responseBody.choices[0];
|
|
521
|
+
if (choice == null)
|
|
522
|
+
throw new InvalidResponseDataError({
|
|
523
|
+
data: rawResponse,
|
|
524
|
+
message: "Response did not contain any choices."
|
|
525
|
+
});
|
|
526
|
+
let content = [];
|
|
527
|
+
content.push(...convertOpenAICompatibleContent(choice.message.content));
|
|
496
528
|
let reasoning = (_a = choice.message.reasoning_content) != null ? _a : choice.message.reasoning;
|
|
497
529
|
if (reasoning != null && reasoning.length > 0 && content.push({
|
|
498
530
|
type: "reasoning",
|
|
@@ -507,24 +539,24 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
507
539
|
input: toolCall.function.arguments,
|
|
508
540
|
...thoughtSignature ? {
|
|
509
541
|
providerMetadata: {
|
|
510
|
-
[
|
|
542
|
+
[metadataKey]: { thoughtSignature }
|
|
511
543
|
}
|
|
512
544
|
} : {}
|
|
513
545
|
});
|
|
514
546
|
}
|
|
515
547
|
let providerMetadata = {
|
|
516
|
-
[
|
|
548
|
+
[metadataKey]: {},
|
|
517
549
|
...await ((_f = (_e = this.config.metadataExtractor) == null ? void 0 : _e.extractMetadata) == null ? void 0 : _f.call(_e, {
|
|
518
550
|
parsedBody: rawResponse
|
|
519
551
|
}))
|
|
520
552
|
}, completionTokenDetails = (_g = responseBody.usage) == null ? void 0 : _g.completion_tokens_details;
|
|
521
|
-
return completionTokenDetails?.accepted_prediction_tokens != null && (providerMetadata[
|
|
553
|
+
return completionTokenDetails?.accepted_prediction_tokens != null && (providerMetadata[metadataKey].acceptedPredictionTokens = completionTokenDetails?.accepted_prediction_tokens), completionTokenDetails?.rejected_prediction_tokens != null && (providerMetadata[metadataKey].rejectedPredictionTokens = completionTokenDetails?.rejected_prediction_tokens), {
|
|
522
554
|
content,
|
|
523
555
|
finishReason: {
|
|
524
556
|
unified: mapOpenAICompatibleFinishReason(choice.finish_reason),
|
|
525
557
|
raw: (_h = choice.finish_reason) != null ? _h : void 0
|
|
526
558
|
},
|
|
527
|
-
usage:
|
|
559
|
+
usage: this.convertUsage(responseBody.usage),
|
|
528
560
|
providerMetadata,
|
|
529
561
|
request: { body },
|
|
530
562
|
response: {
|
|
@@ -537,7 +569,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
537
569
|
}
|
|
538
570
|
async doStream(options) {
|
|
539
571
|
var _a;
|
|
540
|
-
let { args, warnings } = await this.getArgs({ ...options }), body = this.transformRequestBody({
|
|
572
|
+
let { args, warnings, metadataKey } = await this.getArgs({ ...options }), body = this.transformRequestBody({
|
|
541
573
|
...args,
|
|
542
574
|
stream: !0,
|
|
543
575
|
// only include stream_options when in strict compatibility mode:
|
|
@@ -555,18 +587,51 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
555
587
|
),
|
|
556
588
|
abortSignal: options.abortSignal,
|
|
557
589
|
fetch: this.config.fetch
|
|
558
|
-
}),
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
590
|
+
}), providerOptionsName = metadataKey, toolCallTracker, pendingToolCalls = /* @__PURE__ */ new Map(), forwardedToolCallIndices = /* @__PURE__ */ new Set(), processToolCallDelta = (toolCallDelta) => {
|
|
591
|
+
var _a2, _b, _c, _d, _e;
|
|
592
|
+
let index = toolCallDelta.index;
|
|
593
|
+
if (index == null || forwardedToolCallIndices.has(index)) {
|
|
594
|
+
toolCallTracker.processDelta(toolCallDelta);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
let pending = pendingToolCalls.get(index);
|
|
598
|
+
pending == null ? (pending = {
|
|
599
|
+
id: (_a2 = toolCallDelta.id) != null ? _a2 : null,
|
|
600
|
+
bufferedArguments: "",
|
|
601
|
+
extraContent: (_b = toolCallDelta.extra_content) != null ? _b : null
|
|
602
|
+
}, pendingToolCalls.set(index, pending)) : (pending.id == null && toolCallDelta.id != null && (pending.id = toolCallDelta.id), pending.extraContent == null && toolCallDelta.extra_content != null && (pending.extraContent = toolCallDelta.extra_content));
|
|
603
|
+
let argumentsDelta = (_c = toolCallDelta.function) == null ? void 0 : _c.arguments;
|
|
604
|
+
argumentsDelta != null && (pending.bufferedArguments += argumentsDelta);
|
|
605
|
+
let name = (_d = toolCallDelta.function) == null ? void 0 : _d.name;
|
|
606
|
+
name != null && (toolCallTracker.processDelta({
|
|
607
|
+
index,
|
|
608
|
+
id: pending.id,
|
|
609
|
+
function: {
|
|
610
|
+
name,
|
|
611
|
+
arguments: pending.bufferedArguments
|
|
612
|
+
},
|
|
613
|
+
extra_content: (_e = pending.extraContent) != null ? _e : void 0
|
|
614
|
+
}), pendingToolCalls.delete(index), forwardedToolCallIndices.add(index));
|
|
615
|
+
}, finishReason, usage, isFirstChunk = !0, isActiveReasoning = !1, isActiveText = !1, convertUsage = (usage2) => this.convertUsage(usage2);
|
|
562
616
|
return {
|
|
563
617
|
stream: response.pipeThrough(
|
|
564
618
|
new TransformStream({
|
|
565
619
|
start(controller) {
|
|
566
|
-
|
|
620
|
+
toolCallTracker = new StreamingToolCallTracker(
|
|
621
|
+
controller,
|
|
622
|
+
{
|
|
623
|
+
generateId,
|
|
624
|
+
extractMetadata: (delta) => {
|
|
625
|
+
var _a2, _b;
|
|
626
|
+
let thoughtSignature = (_b = (_a2 = delta.extra_content) == null ? void 0 : _a2.google) == null ? void 0 : _b.thought_signature;
|
|
627
|
+
return thoughtSignature ? { [providerOptionsName]: { thoughtSignature } } : void 0;
|
|
628
|
+
},
|
|
629
|
+
buildToolCallProviderMetadata: (metadata) => metadata
|
|
630
|
+
}
|
|
631
|
+
), controller.enqueue({ type: "stream-start", warnings });
|
|
567
632
|
},
|
|
568
633
|
transform(chunk, controller) {
|
|
569
|
-
var _a2, _b
|
|
634
|
+
var _a2, _b;
|
|
570
635
|
if (options.includeRawChunks && controller.enqueue({ type: "raw", rawValue: chunk.rawValue }), !chunk.success) {
|
|
571
636
|
finishReason = { unified: "error", raw: void 0 }, controller.enqueue({ type: "error", error: chunk.error });
|
|
572
637
|
return;
|
|
@@ -574,7 +639,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
574
639
|
if (metadataExtractor?.processChunk(chunk.rawValue), "error" in chunk.value) {
|
|
575
640
|
finishReason = { unified: "error", raw: void 0 }, controller.enqueue({
|
|
576
641
|
type: "error",
|
|
577
|
-
error: chunk.value.error
|
|
642
|
+
error: chunk.value.error
|
|
578
643
|
});
|
|
579
644
|
return;
|
|
580
645
|
}
|
|
@@ -589,130 +654,63 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
589
654
|
raw: (_a2 = choice.finish_reason) != null ? _a2 : void 0
|
|
590
655
|
}), choice?.delta == null)
|
|
591
656
|
return;
|
|
592
|
-
let delta = choice.delta,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
id: "txt-0",
|
|
606
|
-
|
|
607
|
-
|
|
657
|
+
let delta = choice.delta, enqueueReasoningDelta = (reasoningDelta) => {
|
|
658
|
+
isActiveText && (controller.enqueue({ type: "text-end", id: "txt-0" }), isActiveText = !1), isActiveReasoning || (controller.enqueue({
|
|
659
|
+
type: "reasoning-start",
|
|
660
|
+
id: "reasoning-0"
|
|
661
|
+
}), isActiveReasoning = !0), controller.enqueue({
|
|
662
|
+
type: "reasoning-delta",
|
|
663
|
+
id: "reasoning-0",
|
|
664
|
+
delta: reasoningDelta
|
|
665
|
+
});
|
|
666
|
+
}, enqueueTextDelta = (textDelta) => {
|
|
667
|
+
isActiveReasoning && (controller.enqueue({
|
|
668
|
+
type: "reasoning-end",
|
|
669
|
+
id: "reasoning-0"
|
|
670
|
+
}), isActiveReasoning = !1), isActiveText || (controller.enqueue({ type: "text-start", id: "txt-0" }), isActiveText = !0), controller.enqueue({
|
|
671
|
+
type: "text-delta",
|
|
672
|
+
id: "txt-0",
|
|
673
|
+
delta: textDelta
|
|
674
|
+
});
|
|
675
|
+
}, reasoningContent = (_b = delta.reasoning_content) != null ? _b : delta.reasoning;
|
|
676
|
+
reasoningContent && enqueueReasoningDelta(reasoningContent);
|
|
677
|
+
for (let contentPart of convertOpenAICompatibleContent(
|
|
678
|
+
delta.content
|
|
679
|
+
))
|
|
680
|
+
contentPart.type === "reasoning" ? enqueueReasoningDelta(contentPart.text) : enqueueTextDelta(contentPart.text);
|
|
681
|
+
if (delta.tool_calls != null && delta.tool_calls.length > 0) {
|
|
608
682
|
isActiveReasoning && (controller.enqueue({
|
|
609
683
|
type: "reasoning-end",
|
|
610
684
|
id: "reasoning-0"
|
|
611
685
|
}), isActiveReasoning = !1);
|
|
612
|
-
for (let toolCallDelta of delta.tool_calls)
|
|
613
|
-
|
|
614
|
-
if (toolCalls[index] == null) {
|
|
615
|
-
if (toolCallDelta.id == null)
|
|
616
|
-
throw new InvalidResponseDataError({
|
|
617
|
-
data: toolCallDelta,
|
|
618
|
-
message: "Expected 'id' to be a string."
|
|
619
|
-
});
|
|
620
|
-
if (((_d = toolCallDelta.function) == null ? void 0 : _d.name) == null)
|
|
621
|
-
throw new InvalidResponseDataError({
|
|
622
|
-
data: toolCallDelta,
|
|
623
|
-
message: "Expected 'function.name' to be a string."
|
|
624
|
-
});
|
|
625
|
-
controller.enqueue({
|
|
626
|
-
type: "tool-input-start",
|
|
627
|
-
id: toolCallDelta.id,
|
|
628
|
-
toolName: toolCallDelta.function.name
|
|
629
|
-
}), toolCalls[index] = {
|
|
630
|
-
id: toolCallDelta.id,
|
|
631
|
-
type: "function",
|
|
632
|
-
function: {
|
|
633
|
-
name: toolCallDelta.function.name,
|
|
634
|
-
arguments: (_e = toolCallDelta.function.arguments) != null ? _e : ""
|
|
635
|
-
},
|
|
636
|
-
hasFinished: !1,
|
|
637
|
-
thoughtSignature: (_h = (_g = (_f = toolCallDelta.extra_content) == null ? void 0 : _f.google) == null ? void 0 : _g.thought_signature) != null ? _h : void 0
|
|
638
|
-
};
|
|
639
|
-
let toolCall2 = toolCalls[index];
|
|
640
|
-
((_i = toolCall2.function) == null ? void 0 : _i.name) != null && ((_j = toolCall2.function) == null ? void 0 : _j.arguments) != null && (toolCall2.function.arguments.length > 0 && controller.enqueue({
|
|
641
|
-
type: "tool-input-delta",
|
|
642
|
-
id: toolCall2.id,
|
|
643
|
-
delta: toolCall2.function.arguments
|
|
644
|
-
}), isParsableJson(toolCall2.function.arguments) && (controller.enqueue({
|
|
645
|
-
type: "tool-input-end",
|
|
646
|
-
id: toolCall2.id
|
|
647
|
-
}), controller.enqueue({
|
|
648
|
-
type: "tool-call",
|
|
649
|
-
toolCallId: (_k = toolCall2.id) != null ? _k : generateId(),
|
|
650
|
-
toolName: toolCall2.function.name,
|
|
651
|
-
input: toolCall2.function.arguments,
|
|
652
|
-
...toolCall2.thoughtSignature ? {
|
|
653
|
-
providerMetadata: {
|
|
654
|
-
[providerOptionsName]: {
|
|
655
|
-
thoughtSignature: toolCall2.thoughtSignature
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
} : {}
|
|
659
|
-
}), toolCall2.hasFinished = !0));
|
|
660
|
-
continue;
|
|
661
|
-
}
|
|
662
|
-
let toolCall = toolCalls[index];
|
|
663
|
-
toolCall.hasFinished || (((_l = toolCallDelta.function) == null ? void 0 : _l.arguments) != null && (toolCall.function.arguments += (_n = (_m = toolCallDelta.function) == null ? void 0 : _m.arguments) != null ? _n : ""), controller.enqueue({
|
|
664
|
-
type: "tool-input-delta",
|
|
665
|
-
id: toolCall.id,
|
|
666
|
-
delta: (_o = toolCallDelta.function.arguments) != null ? _o : ""
|
|
667
|
-
}), ((_p = toolCall.function) == null ? void 0 : _p.name) != null && ((_q = toolCall.function) == null ? void 0 : _q.arguments) != null && isParsableJson(toolCall.function.arguments) && (controller.enqueue({
|
|
668
|
-
type: "tool-input-end",
|
|
669
|
-
id: toolCall.id
|
|
670
|
-
}), controller.enqueue({
|
|
671
|
-
type: "tool-call",
|
|
672
|
-
toolCallId: (_r = toolCall.id) != null ? _r : generateId(),
|
|
673
|
-
toolName: toolCall.function.name,
|
|
674
|
-
input: toolCall.function.arguments,
|
|
675
|
-
...toolCall.thoughtSignature ? {
|
|
676
|
-
providerMetadata: {
|
|
677
|
-
[providerOptionsName]: {
|
|
678
|
-
thoughtSignature: toolCall.thoughtSignature
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
} : {}
|
|
682
|
-
}), toolCall.hasFinished = !0));
|
|
683
|
-
}
|
|
686
|
+
for (let toolCallDelta of delta.tool_calls)
|
|
687
|
+
processToolCallDelta(toolCallDelta);
|
|
684
688
|
}
|
|
685
689
|
},
|
|
686
690
|
flush(controller) {
|
|
687
|
-
var _a2, _b, _c, _d
|
|
691
|
+
var _a2, _b, _c, _d;
|
|
688
692
|
isActiveReasoning && controller.enqueue({ type: "reasoning-end", id: "reasoning-0" }), isActiveText && controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
689
|
-
for (let
|
|
690
|
-
(
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
id: toolCall.id
|
|
695
|
-
}), controller.enqueue({
|
|
696
|
-
type: "tool-call",
|
|
697
|
-
toolCallId: (_a2 = toolCall.id) != null ? _a2 : generateId(),
|
|
698
|
-
toolName: toolCall.function.name,
|
|
699
|
-
input: toolCall.function.arguments,
|
|
700
|
-
...toolCall.thoughtSignature ? {
|
|
701
|
-
providerMetadata: {
|
|
702
|
-
[providerOptionsName]: {
|
|
703
|
-
thoughtSignature: toolCall.thoughtSignature
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
} : {}
|
|
693
|
+
for (let [index, pending] of pendingToolCalls)
|
|
694
|
+
toolCallTracker.processDelta({
|
|
695
|
+
index,
|
|
696
|
+
id: pending.id,
|
|
697
|
+
function: { arguments: pending.bufferedArguments }
|
|
707
698
|
});
|
|
699
|
+
pendingToolCalls.clear(), toolCallTracker.flush(), finishReason == null && (finishReason = { unified: "error", raw: void 0 }, controller.enqueue({
|
|
700
|
+
type: "error",
|
|
701
|
+
error: new InvalidResponseDataError({
|
|
702
|
+
data: void 0,
|
|
703
|
+
message: "Response stream ended without a finish reason."
|
|
704
|
+
})
|
|
705
|
+
}));
|
|
708
706
|
let providerMetadata = {
|
|
709
707
|
[providerOptionsName]: {},
|
|
710
708
|
...metadataExtractor?.buildMetadata()
|
|
711
709
|
};
|
|
712
|
-
((
|
|
710
|
+
((_a2 = usage?.completion_tokens_details) == null ? void 0 : _a2.accepted_prediction_tokens) != null && (providerMetadata[providerOptionsName].acceptedPredictionTokens = (_b = usage?.completion_tokens_details) == null ? void 0 : _b.accepted_prediction_tokens), ((_c = usage?.completion_tokens_details) == null ? void 0 : _c.rejected_prediction_tokens) != null && (providerMetadata[providerOptionsName].rejectedPredictionTokens = (_d = usage?.completion_tokens_details) == null ? void 0 : _d.rejected_prediction_tokens), controller.enqueue({
|
|
713
711
|
type: "finish",
|
|
714
712
|
finishReason,
|
|
715
|
-
usage:
|
|
713
|
+
usage: convertUsage(usage),
|
|
716
714
|
providerMetadata
|
|
717
715
|
});
|
|
718
716
|
}
|
|
@@ -726,15 +724,40 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
726
724
|
prompt_tokens: external_exports.number().nullish(),
|
|
727
725
|
completion_tokens: external_exports.number().nullish(),
|
|
728
726
|
total_tokens: external_exports.number().nullish(),
|
|
729
|
-
prompt_tokens_details: external_exports.
|
|
727
|
+
prompt_tokens_details: external_exports.looseObject({
|
|
730
728
|
cached_tokens: external_exports.number().nullish()
|
|
731
729
|
}).nullish(),
|
|
732
|
-
completion_tokens_details: external_exports.
|
|
730
|
+
completion_tokens_details: external_exports.looseObject({
|
|
733
731
|
reasoning_tokens: external_exports.number().nullish(),
|
|
734
732
|
accepted_prediction_tokens: external_exports.number().nullish(),
|
|
735
733
|
rejected_prediction_tokens: external_exports.number().nullish()
|
|
736
734
|
}).nullish()
|
|
737
|
-
}).nullish(),
|
|
735
|
+
}).nullish(), openAICompatibleContentSchema = external_exports.union([
|
|
736
|
+
external_exports.string(),
|
|
737
|
+
external_exports.array(
|
|
738
|
+
external_exports.looseObject({
|
|
739
|
+
type: external_exports.string()
|
|
740
|
+
})
|
|
741
|
+
)
|
|
742
|
+
]).nullish();
|
|
743
|
+
function convertOpenAICompatibleContent(content) {
|
|
744
|
+
if (content == null)
|
|
745
|
+
return [];
|
|
746
|
+
if (typeof content == "string")
|
|
747
|
+
return content.length > 0 ? [{ type: "text", text: content }] : [];
|
|
748
|
+
let result = [];
|
|
749
|
+
for (let part of content)
|
|
750
|
+
if (part.type === "text" && typeof part.text == "string")
|
|
751
|
+
part.text.length > 0 && result.push({ type: "text", text: part.text });
|
|
752
|
+
else if (part.type === "thinking" && Array.isArray(part.thinking)) {
|
|
753
|
+
let reasoningText = part.thinking.filter(
|
|
754
|
+
(chunk) => chunk != null && typeof chunk == "object" && "type" in chunk && chunk.type === "text" && "text" in chunk && typeof chunk.text == "string"
|
|
755
|
+
).map((chunk) => chunk.text).join("");
|
|
756
|
+
reasoningText.length > 0 && result.push({ type: "reasoning", text: reasoningText });
|
|
757
|
+
}
|
|
758
|
+
return result;
|
|
759
|
+
}
|
|
760
|
+
var OpenAICompatibleChatResponseSchema = external_exports.looseObject({
|
|
738
761
|
id: external_exports.string().nullish(),
|
|
739
762
|
created: external_exports.number().nullish(),
|
|
740
763
|
model: external_exports.string().nullish(),
|
|
@@ -742,7 +765,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
742
765
|
external_exports.object({
|
|
743
766
|
message: external_exports.object({
|
|
744
767
|
role: external_exports.literal("assistant").nullish(),
|
|
745
|
-
content:
|
|
768
|
+
content: openAICompatibleContentSchema,
|
|
746
769
|
reasoning_content: external_exports.string().nullish(),
|
|
747
770
|
reasoning: external_exports.string().nullish(),
|
|
748
771
|
tool_calls: external_exports.array(
|
|
@@ -772,8 +795,8 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
772
795
|
choices: external_exports.array(
|
|
773
796
|
external_exports.object({
|
|
774
797
|
delta: external_exports.object({
|
|
775
|
-
role: external_exports.enum(["assistant"]).nullish(),
|
|
776
|
-
content:
|
|
798
|
+
role: external_exports.enum(["assistant", ""]).nullish(),
|
|
799
|
+
content: openAICompatibleContentSchema,
|
|
777
800
|
// Most openai-compatible models set `reasoning_content`, but some
|
|
778
801
|
// providers serving `gpt-oss` set `reasoning`. See #7866
|
|
779
802
|
reasoning_content: external_exports.string().nullish(),
|
|
@@ -920,7 +943,7 @@ function mapOpenAICompatibleFinishReason2(finishReason) {
|
|
|
920
943
|
return "other";
|
|
921
944
|
}
|
|
922
945
|
}
|
|
923
|
-
var
|
|
946
|
+
var openaiCompatibleLanguageModelCompletionOptions = external_exports.object({
|
|
924
947
|
/**
|
|
925
948
|
* Echo back the prompt in addition to the completion.
|
|
926
949
|
*/
|
|
@@ -977,12 +1000,19 @@ var openaiCompatibleCompletionProviderOptions = external_exports.object({
|
|
|
977
1000
|
tools,
|
|
978
1001
|
toolChoice
|
|
979
1002
|
}) {
|
|
980
|
-
var _a;
|
|
981
|
-
let warnings = [], completionOptions = (
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1003
|
+
var _a, _b;
|
|
1004
|
+
let warnings = [], completionOptions = Object.assign(
|
|
1005
|
+
(_a = await parseProviderOptions({
|
|
1006
|
+
provider: this.providerOptionsName,
|
|
1007
|
+
providerOptions,
|
|
1008
|
+
schema: openaiCompatibleLanguageModelCompletionOptions
|
|
1009
|
+
})) != null ? _a : {},
|
|
1010
|
+
(_b = await parseProviderOptions({
|
|
1011
|
+
provider: toCamelCase(this.providerOptionsName),
|
|
1012
|
+
providerOptions,
|
|
1013
|
+
schema: openaiCompatibleLanguageModelCompletionOptions
|
|
1014
|
+
})) != null ? _b : {}
|
|
1015
|
+
);
|
|
986
1016
|
topK != null && warnings.push({ type: "unsupported", feature: "topK" }), tools?.length && warnings.push({ type: "unsupported", feature: "tools" }), toolChoice != null && warnings.push({ type: "unsupported", feature: "toolChoice" }), responseFormat != null && responseFormat.type !== "text" && warnings.push({
|
|
987
1017
|
type: "unsupported",
|
|
988
1018
|
feature: "responseFormat",
|
|
@@ -1006,6 +1036,7 @@ var openaiCompatibleCompletionProviderOptions = external_exports.object({
|
|
|
1006
1036
|
presence_penalty: presencePenalty,
|
|
1007
1037
|
seed,
|
|
1008
1038
|
...providerOptions?.[this.providerOptionsName],
|
|
1039
|
+
...providerOptions?.[toCamelCase(this.providerOptionsName)],
|
|
1009
1040
|
// prompt:
|
|
1010
1041
|
prompt: completionPrompt,
|
|
1011
1042
|
// stop sequences:
|
|
@@ -1119,7 +1150,7 @@ var openaiCompatibleCompletionProviderOptions = external_exports.object({
|
|
|
1119
1150
|
response: { headers: responseHeaders }
|
|
1120
1151
|
};
|
|
1121
1152
|
}
|
|
1122
|
-
}, usageSchema = external_exports.
|
|
1153
|
+
}, usageSchema = external_exports.looseObject({
|
|
1123
1154
|
prompt_tokens: external_exports.number(),
|
|
1124
1155
|
completion_tokens: external_exports.number(),
|
|
1125
1156
|
total_tokens: external_exports.number()
|
|
@@ -1149,7 +1180,7 @@ var openaiCompatibleCompletionProviderOptions = external_exports.object({
|
|
|
1149
1180
|
usage: usageSchema.nullish()
|
|
1150
1181
|
}),
|
|
1151
1182
|
errorSchema
|
|
1152
|
-
]),
|
|
1183
|
+
]), openaiCompatibleEmbeddingModelOptions = external_exports.object({
|
|
1153
1184
|
/**
|
|
1154
1185
|
* The number of dimensions the resulting output embeddings should have.
|
|
1155
1186
|
* Only supported in text-embedding-3 and later models.
|
|
@@ -1188,7 +1219,7 @@ var openaiCompatibleCompletionProviderOptions = external_exports.object({
|
|
|
1188
1219
|
let warnings = [], deprecatedOptions = await parseProviderOptions({
|
|
1189
1220
|
provider: "openai-compatible",
|
|
1190
1221
|
providerOptions,
|
|
1191
|
-
schema:
|
|
1222
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
1192
1223
|
});
|
|
1193
1224
|
deprecatedOptions != null && warnings.push({
|
|
1194
1225
|
type: "other",
|
|
@@ -1199,12 +1230,12 @@ var openaiCompatibleCompletionProviderOptions = external_exports.object({
|
|
|
1199
1230
|
(_a = await parseProviderOptions({
|
|
1200
1231
|
provider: "openaiCompatible",
|
|
1201
1232
|
providerOptions,
|
|
1202
|
-
schema:
|
|
1233
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
1203
1234
|
})) != null ? _a : {},
|
|
1204
1235
|
(_b = await parseProviderOptions({
|
|
1205
1236
|
provider: this.providerOptionsName,
|
|
1206
1237
|
providerOptions,
|
|
1207
|
-
schema:
|
|
1238
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
1208
1239
|
})) != null ? _b : {}
|
|
1209
1240
|
);
|
|
1210
1241
|
if (values.length > this.maxEmbeddingsPerCall)
|
|
@@ -1369,10 +1400,7 @@ async function fileToBlob(file) {
|
|
|
1369
1400
|
let data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array(file.data);
|
|
1370
1401
|
return new Blob([data], { type: file.mediaType });
|
|
1371
1402
|
}
|
|
1372
|
-
|
|
1373
|
-
return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
|
|
1374
|
-
}
|
|
1375
|
-
var VERSION = "2.0.27";
|
|
1403
|
+
var VERSION = "2.0.82";
|
|
1376
1404
|
function createOpenAICompatible(options) {
|
|
1377
1405
|
let baseURL = withoutTrailingSlash(options.baseURL), providerName = options.name, headers = {
|
|
1378
1406
|
...options.apiKey && { Authorization: `Bearer ${options.apiKey}` },
|
|
@@ -1389,8 +1417,10 @@ function createOpenAICompatible(options) {
|
|
|
1389
1417
|
...getCommonModelConfig("chat"),
|
|
1390
1418
|
includeUsage: options.includeUsage,
|
|
1391
1419
|
supportsStructuredOutputs: options.supportsStructuredOutputs,
|
|
1420
|
+
supportedUrls: options.supportedUrls,
|
|
1392
1421
|
transformRequestBody: options.transformRequestBody,
|
|
1393
|
-
metadataExtractor: options.metadataExtractor
|
|
1422
|
+
metadataExtractor: options.metadataExtractor,
|
|
1423
|
+
convertUsage: options.convertUsage
|
|
1394
1424
|
}), createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(modelId, {
|
|
1395
1425
|
...getCommonModelConfig("completion"),
|
|
1396
1426
|
includeUsage: options.includeUsage
|
|
@@ -1401,7 +1431,7 @@ function createOpenAICompatible(options) {
|
|
|
1401
1431
|
}
|
|
1402
1432
|
|
|
1403
1433
|
// src/main/providers/grok-subscription/index.ts
|
|
1404
|
-
var BASE_URL = "https://api.x.ai/v1";
|
|
1434
|
+
var BASE_URL = "https://api.x.ai/v1", GROK_SUBSCRIPTION_MEDIA = IMAGE_ONLY_MEDIA;
|
|
1405
1435
|
function createGrokSubscriptionProvider(authManager, extraParams) {
|
|
1406
1436
|
return { provider: createOpenAICompatible({
|
|
1407
1437
|
name: "xai",
|
|
@@ -1463,6 +1493,7 @@ async function listGrokSubscriptionModels(authManager) {
|
|
|
1463
1493
|
|
|
1464
1494
|
export {
|
|
1465
1495
|
createOpenAICompatible,
|
|
1496
|
+
GROK_SUBSCRIPTION_MEDIA,
|
|
1466
1497
|
createGrokSubscriptionProvider,
|
|
1467
1498
|
GROK_SUBSCRIPTION_MODELS,
|
|
1468
1499
|
listGrokSubscriptionModels
|