@mastra/core 1.26.0 → 1.26.1-alpha.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/CHANGELOG.md +17 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/channels/index.cjs +4 -4
- package/dist/channels/index.js +1 -1
- package/dist/{chunk-CXW3Z2OL.js → chunk-4QTY73BW.js} +4 -4
- package/dist/chunk-4QTY73BW.js.map +1 -0
- package/dist/{chunk-VOP4TUHG.cjs → chunk-5HLY6ZVZ.cjs} +17 -17
- package/dist/{chunk-VOP4TUHG.cjs.map → chunk-5HLY6ZVZ.cjs.map} +1 -1
- package/dist/{chunk-GSVFJAVS.js → chunk-65IATTED.js} +3 -3
- package/dist/{chunk-GSVFJAVS.js.map → chunk-65IATTED.js.map} +1 -1
- package/dist/{chunk-PBGNXXU5.cjs → chunk-7432OHPH.cjs} +13 -13
- package/dist/chunk-7432OHPH.cjs.map +1 -0
- package/dist/{chunk-PLCLLPJL.js → chunk-BDGDMJRC.js} +9 -9
- package/dist/{chunk-PLCLLPJL.js.map → chunk-BDGDMJRC.js.map} +1 -1
- package/dist/{chunk-VYRRGSYO.cjs → chunk-BQN2KODN.cjs} +292 -292
- package/dist/{chunk-VYRRGSYO.cjs.map → chunk-BQN2KODN.cjs.map} +1 -1
- package/dist/{chunk-ZOCCZPSK.js → chunk-BVXKM2NV.js} +6 -6
- package/dist/{chunk-ZOCCZPSK.js.map → chunk-BVXKM2NV.js.map} +1 -1
- package/dist/{chunk-FFZJH35S.js → chunk-D4VTONCA.js} +3 -3
- package/dist/{chunk-FFZJH35S.js.map → chunk-D4VTONCA.js.map} +1 -1
- package/dist/{chunk-YZH6VQAS.cjs → chunk-DUJPIL2U.cjs} +5 -5
- package/dist/{chunk-YZH6VQAS.cjs.map → chunk-DUJPIL2U.cjs.map} +1 -1
- package/dist/{chunk-QNSBW2X4.js → chunk-EB7MYCTO.js} +3 -3
- package/dist/chunk-EB7MYCTO.js.map +1 -0
- package/dist/{chunk-HEAKZCPY.cjs → chunk-F3DC3HPB.cjs} +224 -224
- package/dist/{chunk-HEAKZCPY.cjs.map → chunk-F3DC3HPB.cjs.map} +1 -1
- package/dist/{chunk-PHQEKA3K.cjs → chunk-FKRKSEDS.cjs} +57 -57
- package/dist/{chunk-PHQEKA3K.cjs.map → chunk-FKRKSEDS.cjs.map} +1 -1
- package/dist/{chunk-2KWFY2Z4.cjs → chunk-IIV77JRY.cjs} +24 -30
- package/dist/chunk-IIV77JRY.cjs.map +1 -0
- package/dist/{chunk-EK2NCPVI.cjs → chunk-JZ4NE7PC.cjs} +7 -7
- package/dist/{chunk-EK2NCPVI.cjs.map → chunk-JZ4NE7PC.cjs.map} +1 -1
- package/dist/{chunk-Q5JACXBM.cjs → chunk-L24YAW4G.cjs} +3 -3
- package/dist/chunk-L24YAW4G.cjs.map +1 -0
- package/dist/{chunk-YHKM3BEY.cjs → chunk-MM7USNIY.cjs} +6 -6
- package/dist/{chunk-YHKM3BEY.cjs.map → chunk-MM7USNIY.cjs.map} +1 -1
- package/dist/{chunk-USTQPLUM.js → chunk-MZPEIW2H.js} +4 -4
- package/dist/{chunk-USTQPLUM.js.map → chunk-MZPEIW2H.js.map} +1 -1
- package/dist/{chunk-OUAM366B.cjs → chunk-NC4C5XMF.cjs} +9 -9
- package/dist/{chunk-OUAM366B.cjs.map → chunk-NC4C5XMF.cjs.map} +1 -1
- package/dist/{chunk-42ZT2Z2G.js → chunk-NQGCZAEB.js} +12 -18
- package/dist/chunk-NQGCZAEB.js.map +1 -0
- package/dist/{chunk-5L2Z472N.js → chunk-NYMU25CS.js} +3 -3
- package/dist/{chunk-5L2Z472N.js.map → chunk-NYMU25CS.js.map} +1 -1
- package/dist/{chunk-AW2NDGPK.js → chunk-QRZI6IPG.js} +3 -3
- package/dist/{chunk-AW2NDGPK.js.map → chunk-QRZI6IPG.js.map} +1 -1
- package/dist/{chunk-PKJJATBP.js → chunk-ZIURHKSV.js} +4 -4
- package/dist/{chunk-PKJJATBP.js.map → chunk-ZIURHKSV.js.map} +1 -1
- package/dist/datasets/index.cjs +11 -11
- package/dist/datasets/index.js +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +134 -134
- package/dist/evals/index.cjs +5 -5
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/index.cjs +7 -7
- package/dist/harness/index.js +5 -5
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +20 -20
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/provider-types.generated.d.ts +2 -1
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/mastra-4PNTYVGX.js +3 -0
- package/dist/{mastra-GNYYE3LZ.js.map → mastra-4PNTYVGX.js.map} +1 -1
- package/dist/mastra-GD4IDWX2.cjs +12 -0
- package/dist/{mastra-TDQOUJVC.cjs.map → mastra-GD4IDWX2.cjs.map} +1 -1
- package/dist/memory/index.cjs +19 -19
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-3XJMRBHD.js +3 -0
- package/dist/{models-dev-SWQOXATZ.js.map → models-dev-3XJMRBHD.js.map} +1 -1
- package/dist/models-dev-MO5D6ABH.cjs +12 -0
- package/dist/{models-dev-F44ZVNMB.cjs.map → models-dev-MO5D6ABH.cjs.map} +1 -1
- package/dist/netlify-7GWUCWBI.cjs +12 -0
- package/dist/{netlify-SM6JU5OO.cjs.map → netlify-7GWUCWBI.cjs.map} +1 -1
- package/dist/netlify-KWFGDMNK.js +3 -0
- package/dist/{netlify-CTXSBLLU.js.map → netlify-KWFGDMNK.js.map} +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +45 -45
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-IVDLHER6.js +3 -0
- package/dist/{provider-registry-CPP455MT.js.map → provider-registry-IVDLHER6.js.map} +1 -1
- package/dist/provider-registry-IXCOQD3Z.cjs +44 -0
- package/dist/{provider-registry-OKP5HT5E.cjs.map → provider-registry-IXCOQD3Z.cjs.map} +1 -1
- package/dist/provider-registry.json +4 -10
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/package.json +6 -6
- package/src/llm/model/provider-types.generated.d.ts +2 -1
- package/dist/chunk-2KWFY2Z4.cjs.map +0 -1
- package/dist/chunk-42ZT2Z2G.js.map +0 -1
- package/dist/chunk-CXW3Z2OL.js.map +0 -1
- package/dist/chunk-PBGNXXU5.cjs.map +0 -1
- package/dist/chunk-Q5JACXBM.cjs.map +0 -1
- package/dist/chunk-QNSBW2X4.js.map +0 -1
- package/dist/mastra-GNYYE3LZ.js +0 -3
- package/dist/mastra-TDQOUJVC.cjs +0 -12
- package/dist/models-dev-F44ZVNMB.cjs +0 -12
- package/dist/models-dev-SWQOXATZ.js +0 -3
- package/dist/netlify-CTXSBLLU.js +0 -3
- package/dist/netlify-SM6JU5OO.cjs +0 -12
- package/dist/provider-registry-CPP455MT.js +0 -3
- package/dist/provider-registry-OKP5HT5E.cjs +0 -44
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkIIV77JRY_cjs = require('./chunk-IIV77JRY.cjs');
|
|
4
|
+
var chunkF3DC3HPB_cjs = require('./chunk-F3DC3HPB.cjs');
|
|
5
|
+
var chunkNC4C5XMF_cjs = require('./chunk-NC4C5XMF.cjs');
|
|
6
|
+
var chunkL24YAW4G_cjs = require('./chunk-L24YAW4G.cjs');
|
|
7
7
|
var chunkFM6MTRWJ_cjs = require('./chunk-FM6MTRWJ.cjs');
|
|
8
8
|
var chunkI4YMMVQ3_cjs = require('./chunk-I4YMMVQ3.cjs');
|
|
9
9
|
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
@@ -119,7 +119,7 @@ chunkBVWXTWXP_cjs.__export(dist_exports2, {
|
|
|
119
119
|
DEFAULT_MAX_DOWNLOAD_SIZE: () => DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
120
120
|
DelayedPromise: () => DelayedPromise,
|
|
121
121
|
DownloadError: () => DownloadError,
|
|
122
|
-
EventSourceParserStream: () =>
|
|
122
|
+
EventSourceParserStream: () => chunkL24YAW4G_cjs.EventSourceParserStream,
|
|
123
123
|
VERSION: () => VERSION,
|
|
124
124
|
asSchema: () => asSchema,
|
|
125
125
|
asValidator: () => asValidator,
|
|
@@ -305,7 +305,7 @@ var marker = `vercel.ai.error.${name}`;
|
|
|
305
305
|
var symbol = Symbol.for(marker);
|
|
306
306
|
var _a;
|
|
307
307
|
var _b;
|
|
308
|
-
var DownloadError = class extends (_b =
|
|
308
|
+
var DownloadError = class extends (_b = chunkL24YAW4G_cjs.AISDKError, _a = symbol, _b) {
|
|
309
309
|
constructor({
|
|
310
310
|
url,
|
|
311
311
|
statusCode,
|
|
@@ -320,7 +320,7 @@ var DownloadError = class extends (_b = chunkQ5JACXBM_cjs.AISDKError, _a = symbo
|
|
|
320
320
|
this.statusText = statusText;
|
|
321
321
|
}
|
|
322
322
|
static isInstance(error) {
|
|
323
|
-
return
|
|
323
|
+
return chunkL24YAW4G_cjs.AISDKError.hasMarker(error, marker);
|
|
324
324
|
}
|
|
325
325
|
};
|
|
326
326
|
var DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
|
|
@@ -394,7 +394,7 @@ var createIdGenerator = ({
|
|
|
394
394
|
return generator;
|
|
395
395
|
}
|
|
396
396
|
if (alphabet.includes(separator)) {
|
|
397
|
-
throw new
|
|
397
|
+
throw new chunkL24YAW4G_cjs.InvalidArgumentError({
|
|
398
398
|
argument: "separator",
|
|
399
399
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
400
400
|
});
|
|
@@ -430,7 +430,7 @@ function handleFetchError({
|
|
|
430
430
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
431
431
|
const cause = error.cause;
|
|
432
432
|
if (cause != null) {
|
|
433
|
-
return new
|
|
433
|
+
return new chunkL24YAW4G_cjs.APICallError({
|
|
434
434
|
message: `Cannot connect to API: ${cause.message}`,
|
|
435
435
|
cause,
|
|
436
436
|
url,
|
|
@@ -518,10 +518,10 @@ var getFromApi = async ({
|
|
|
518
518
|
requestBodyValues: {}
|
|
519
519
|
});
|
|
520
520
|
} catch (error) {
|
|
521
|
-
if (isAbortError(error) ||
|
|
521
|
+
if (isAbortError(error) || chunkL24YAW4G_cjs.APICallError.isInstance(error)) {
|
|
522
522
|
throw error;
|
|
523
523
|
}
|
|
524
|
-
throw new
|
|
524
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
525
525
|
message: "Failed to process error response",
|
|
526
526
|
cause: error,
|
|
527
527
|
statusCode: response.status,
|
|
@@ -540,11 +540,11 @@ var getFromApi = async ({
|
|
|
540
540
|
});
|
|
541
541
|
} catch (error) {
|
|
542
542
|
if (error instanceof Error) {
|
|
543
|
-
if (isAbortError(error) ||
|
|
543
|
+
if (isAbortError(error) || chunkL24YAW4G_cjs.APICallError.isInstance(error)) {
|
|
544
544
|
throw error;
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
throw new
|
|
547
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
548
548
|
message: "Failed to process successful response",
|
|
549
549
|
cause: error,
|
|
550
550
|
statusCode: response.status,
|
|
@@ -616,23 +616,23 @@ function loadApiKey2({
|
|
|
616
616
|
return apiKey;
|
|
617
617
|
}
|
|
618
618
|
if (apiKey != null) {
|
|
619
|
-
throw new
|
|
619
|
+
throw new chunkL24YAW4G_cjs.LoadAPIKeyError({
|
|
620
620
|
message: `${description} API key must be a string.`
|
|
621
621
|
});
|
|
622
622
|
}
|
|
623
623
|
if (typeof process === "undefined") {
|
|
624
|
-
throw new
|
|
624
|
+
throw new chunkL24YAW4G_cjs.LoadAPIKeyError({
|
|
625
625
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
626
626
|
});
|
|
627
627
|
}
|
|
628
628
|
apiKey = process.env[environmentVariableName];
|
|
629
629
|
if (apiKey == null) {
|
|
630
|
-
throw new
|
|
630
|
+
throw new chunkL24YAW4G_cjs.LoadAPIKeyError({
|
|
631
631
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
632
632
|
});
|
|
633
633
|
}
|
|
634
634
|
if (typeof apiKey !== "string") {
|
|
635
|
-
throw new
|
|
635
|
+
throw new chunkL24YAW4G_cjs.LoadAPIKeyError({
|
|
636
636
|
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
637
637
|
});
|
|
638
638
|
}
|
|
@@ -664,23 +664,23 @@ function loadSetting({
|
|
|
664
664
|
return settingValue;
|
|
665
665
|
}
|
|
666
666
|
if (settingValue != null) {
|
|
667
|
-
throw new
|
|
667
|
+
throw new chunkL24YAW4G_cjs.LoadSettingError({
|
|
668
668
|
message: `${description} setting must be a string.`
|
|
669
669
|
});
|
|
670
670
|
}
|
|
671
671
|
if (typeof process === "undefined") {
|
|
672
|
-
throw new
|
|
672
|
+
throw new chunkL24YAW4G_cjs.LoadSettingError({
|
|
673
673
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables is not supported in this environment.`
|
|
674
674
|
});
|
|
675
675
|
}
|
|
676
676
|
settingValue = process.env[environmentVariableName];
|
|
677
677
|
if (settingValue == null) {
|
|
678
|
-
throw new
|
|
678
|
+
throw new chunkL24YAW4G_cjs.LoadSettingError({
|
|
679
679
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter or the ${environmentVariableName} environment variable.`
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
if (typeof settingValue !== "string") {
|
|
683
|
-
throw new
|
|
683
|
+
throw new chunkL24YAW4G_cjs.LoadSettingError({
|
|
684
684
|
message: `${description} setting must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
685
685
|
});
|
|
686
686
|
}
|
|
@@ -768,7 +768,7 @@ function standardSchemaValidator(standardSchema) {
|
|
|
768
768
|
const result = await standardSchema["~standard"].validate(value);
|
|
769
769
|
return result.issues == null ? { success: true, value: result.value } : {
|
|
770
770
|
success: false,
|
|
771
|
-
error: new
|
|
771
|
+
error: new chunkL24YAW4G_cjs.TypeValidationError({
|
|
772
772
|
value,
|
|
773
773
|
cause: result.issues
|
|
774
774
|
})
|
|
@@ -781,7 +781,7 @@ async function validateTypes2({
|
|
|
781
781
|
}) {
|
|
782
782
|
const result = await safeValidateTypes({ value, schema });
|
|
783
783
|
if (!result.success) {
|
|
784
|
-
throw
|
|
784
|
+
throw chunkL24YAW4G_cjs.TypeValidationError.wrap({ value, cause: result.error });
|
|
785
785
|
}
|
|
786
786
|
return result.value;
|
|
787
787
|
}
|
|
@@ -800,13 +800,13 @@ async function safeValidateTypes({
|
|
|
800
800
|
}
|
|
801
801
|
return {
|
|
802
802
|
success: false,
|
|
803
|
-
error:
|
|
803
|
+
error: chunkL24YAW4G_cjs.TypeValidationError.wrap({ value, cause: result.error }),
|
|
804
804
|
rawValue: value
|
|
805
805
|
};
|
|
806
806
|
} catch (error) {
|
|
807
807
|
return {
|
|
808
808
|
success: false,
|
|
809
|
-
error:
|
|
809
|
+
error: chunkL24YAW4G_cjs.TypeValidationError.wrap({ value, cause: error }),
|
|
810
810
|
rawValue: value
|
|
811
811
|
};
|
|
812
812
|
}
|
|
@@ -822,10 +822,10 @@ async function parseJSON({
|
|
|
822
822
|
}
|
|
823
823
|
return validateTypes2({ value, schema });
|
|
824
824
|
} catch (error) {
|
|
825
|
-
if (
|
|
825
|
+
if (chunkL24YAW4G_cjs.JSONParseError.isInstance(error) || chunkL24YAW4G_cjs.TypeValidationError.isInstance(error)) {
|
|
826
826
|
throw error;
|
|
827
827
|
}
|
|
828
|
-
throw new
|
|
828
|
+
throw new chunkL24YAW4G_cjs.JSONParseError({ text, cause: error });
|
|
829
829
|
}
|
|
830
830
|
}
|
|
831
831
|
async function safeParseJSON({
|
|
@@ -841,7 +841,7 @@ async function safeParseJSON({
|
|
|
841
841
|
} catch (error) {
|
|
842
842
|
return {
|
|
843
843
|
success: false,
|
|
844
|
-
error:
|
|
844
|
+
error: chunkL24YAW4G_cjs.JSONParseError.isInstance(error) ? error : new chunkL24YAW4G_cjs.JSONParseError({ text, cause: error }),
|
|
845
845
|
rawValue: void 0
|
|
846
846
|
};
|
|
847
847
|
}
|
|
@@ -858,7 +858,7 @@ function parseJsonEventStream({
|
|
|
858
858
|
stream,
|
|
859
859
|
schema
|
|
860
860
|
}) {
|
|
861
|
-
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
861
|
+
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new chunkL24YAW4G_cjs.EventSourceParserStream()).pipeThrough(
|
|
862
862
|
new TransformStream({
|
|
863
863
|
async transform({ data }, controller) {
|
|
864
864
|
if (data === "[DONE]") {
|
|
@@ -882,7 +882,7 @@ async function parseProviderOptions2({
|
|
|
882
882
|
schema
|
|
883
883
|
});
|
|
884
884
|
if (!parsedProviderOptions.success) {
|
|
885
|
-
throw new
|
|
885
|
+
throw new chunkL24YAW4G_cjs.InvalidArgumentError({
|
|
886
886
|
argument: "providerOptions",
|
|
887
887
|
message: `invalid ${provider} provider options`,
|
|
888
888
|
cause: parsedProviderOptions.error
|
|
@@ -964,10 +964,10 @@ var postToApi = async ({
|
|
|
964
964
|
requestBodyValues: body.values
|
|
965
965
|
});
|
|
966
966
|
} catch (error) {
|
|
967
|
-
if (isAbortError(error) ||
|
|
967
|
+
if (isAbortError(error) || chunkL24YAW4G_cjs.APICallError.isInstance(error)) {
|
|
968
968
|
throw error;
|
|
969
969
|
}
|
|
970
|
-
throw new
|
|
970
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
971
971
|
message: "Failed to process error response",
|
|
972
972
|
cause: error,
|
|
973
973
|
statusCode: response.status,
|
|
@@ -986,11 +986,11 @@ var postToApi = async ({
|
|
|
986
986
|
});
|
|
987
987
|
} catch (error) {
|
|
988
988
|
if (error instanceof Error) {
|
|
989
|
-
if (isAbortError(error) ||
|
|
989
|
+
if (isAbortError(error) || chunkL24YAW4G_cjs.APICallError.isInstance(error)) {
|
|
990
990
|
throw error;
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
|
-
throw new
|
|
993
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
994
994
|
message: "Failed to process successful response",
|
|
995
995
|
cause: error,
|
|
996
996
|
statusCode: response.status,
|
|
@@ -1084,7 +1084,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1084
1084
|
if (responseBody.trim() === "") {
|
|
1085
1085
|
return {
|
|
1086
1086
|
responseHeaders,
|
|
1087
|
-
value: new
|
|
1087
|
+
value: new chunkL24YAW4G_cjs.APICallError({
|
|
1088
1088
|
message: response.statusText,
|
|
1089
1089
|
url,
|
|
1090
1090
|
requestBodyValues,
|
|
@@ -1102,7 +1102,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1102
1102
|
});
|
|
1103
1103
|
return {
|
|
1104
1104
|
responseHeaders,
|
|
1105
|
-
value: new
|
|
1105
|
+
value: new chunkL24YAW4G_cjs.APICallError({
|
|
1106
1106
|
message: errorToMessage(parsedError),
|
|
1107
1107
|
url,
|
|
1108
1108
|
requestBodyValues,
|
|
@@ -1116,7 +1116,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1116
1116
|
} catch (parseError) {
|
|
1117
1117
|
return {
|
|
1118
1118
|
responseHeaders,
|
|
1119
|
-
value: new
|
|
1119
|
+
value: new chunkL24YAW4G_cjs.APICallError({
|
|
1120
1120
|
message: response.statusText,
|
|
1121
1121
|
url,
|
|
1122
1122
|
requestBodyValues,
|
|
@@ -1131,7 +1131,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1131
1131
|
var createEventSourceResponseHandler2 = (chunkSchema2) => async ({ response }) => {
|
|
1132
1132
|
const responseHeaders = extractResponseHeaders(response);
|
|
1133
1133
|
if (response.body == null) {
|
|
1134
|
-
throw new
|
|
1134
|
+
throw new chunkL24YAW4G_cjs.EmptyResponseBodyError({});
|
|
1135
1135
|
}
|
|
1136
1136
|
return {
|
|
1137
1137
|
responseHeaders,
|
|
@@ -1144,7 +1144,7 @@ var createEventSourceResponseHandler2 = (chunkSchema2) => async ({ response }) =
|
|
|
1144
1144
|
var createJsonStreamResponseHandler = (chunkSchema2) => async ({ response }) => {
|
|
1145
1145
|
const responseHeaders = extractResponseHeaders(response);
|
|
1146
1146
|
if (response.body == null) {
|
|
1147
|
-
throw new
|
|
1147
|
+
throw new chunkL24YAW4G_cjs.EmptyResponseBodyError({});
|
|
1148
1148
|
}
|
|
1149
1149
|
let buffer = "";
|
|
1150
1150
|
return {
|
|
@@ -1176,7 +1176,7 @@ var createJsonResponseHandler2 = (responseSchema2) => async ({ response, url, re
|
|
|
1176
1176
|
});
|
|
1177
1177
|
const responseHeaders = extractResponseHeaders(response);
|
|
1178
1178
|
if (!parsedResult.success) {
|
|
1179
|
-
throw new
|
|
1179
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
1180
1180
|
message: "Invalid JSON response",
|
|
1181
1181
|
cause: parsedResult.error,
|
|
1182
1182
|
statusCode: response.status,
|
|
@@ -1195,7 +1195,7 @@ var createJsonResponseHandler2 = (responseSchema2) => async ({ response, url, re
|
|
|
1195
1195
|
var createBinaryResponseHandler2 = () => async ({ response, url, requestBodyValues }) => {
|
|
1196
1196
|
const responseHeaders = extractResponseHeaders(response);
|
|
1197
1197
|
if (!response.body) {
|
|
1198
|
-
throw new
|
|
1198
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
1199
1199
|
message: "Response body is empty",
|
|
1200
1200
|
url,
|
|
1201
1201
|
requestBodyValues,
|
|
@@ -1211,7 +1211,7 @@ var createBinaryResponseHandler2 = () => async ({ response, url, requestBodyValu
|
|
|
1211
1211
|
value: new Uint8Array(buffer)
|
|
1212
1212
|
};
|
|
1213
1213
|
} catch (error) {
|
|
1214
|
-
throw new
|
|
1214
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
1215
1215
|
message: "Failed to read response as array buffer",
|
|
1216
1216
|
url,
|
|
1217
1217
|
requestBodyValues,
|
|
@@ -1227,7 +1227,7 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
1227
1227
|
const responseBody = await response.text();
|
|
1228
1228
|
return {
|
|
1229
1229
|
responseHeaders,
|
|
1230
|
-
value: new
|
|
1230
|
+
value: new chunkL24YAW4G_cjs.APICallError({
|
|
1231
1231
|
message: response.statusText,
|
|
1232
1232
|
url,
|
|
1233
1233
|
requestBodyValues,
|
|
@@ -2649,7 +2649,7 @@ function convertToOpenAIChatMessages({
|
|
|
2649
2649
|
};
|
|
2650
2650
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
2651
2651
|
if (part.data instanceof URL) {
|
|
2652
|
-
throw new
|
|
2652
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
2653
2653
|
functionality: "audio file parts with URLs"
|
|
2654
2654
|
});
|
|
2655
2655
|
}
|
|
@@ -2674,14 +2674,14 @@ function convertToOpenAIChatMessages({
|
|
|
2674
2674
|
};
|
|
2675
2675
|
}
|
|
2676
2676
|
default: {
|
|
2677
|
-
throw new
|
|
2677
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
2678
2678
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
2679
2679
|
});
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
2682
|
} else if (part.mediaType === "application/pdf") {
|
|
2683
2683
|
if (part.data instanceof URL) {
|
|
2684
|
-
throw new
|
|
2684
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
2685
2685
|
functionality: "PDF file parts with URLs"
|
|
2686
2686
|
});
|
|
2687
2687
|
}
|
|
@@ -2693,7 +2693,7 @@ function convertToOpenAIChatMessages({
|
|
|
2693
2693
|
}
|
|
2694
2694
|
};
|
|
2695
2695
|
} else {
|
|
2696
|
-
throw new
|
|
2696
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
2697
2697
|
functionality: `file part media type ${part.mediaType}`
|
|
2698
2698
|
});
|
|
2699
2699
|
}
|
|
@@ -3081,7 +3081,7 @@ function prepareChatTools({
|
|
|
3081
3081
|
};
|
|
3082
3082
|
default: {
|
|
3083
3083
|
const _exhaustiveCheck = type;
|
|
3084
|
-
throw new
|
|
3084
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
3085
3085
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
3086
3086
|
});
|
|
3087
3087
|
}
|
|
@@ -3473,19 +3473,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
3473
3473
|
const index = toolCallDelta.index;
|
|
3474
3474
|
if (toolCalls[index] == null) {
|
|
3475
3475
|
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
3476
|
-
throw new
|
|
3476
|
+
throw new chunkL24YAW4G_cjs.InvalidResponseDataError({
|
|
3477
3477
|
data: toolCallDelta,
|
|
3478
3478
|
message: `Expected 'function' type.`
|
|
3479
3479
|
});
|
|
3480
3480
|
}
|
|
3481
3481
|
if (toolCallDelta.id == null) {
|
|
3482
|
-
throw new
|
|
3482
|
+
throw new chunkL24YAW4G_cjs.InvalidResponseDataError({
|
|
3483
3483
|
data: toolCallDelta,
|
|
3484
3484
|
message: `Expected 'id' to be a string.`
|
|
3485
3485
|
});
|
|
3486
3486
|
}
|
|
3487
3487
|
if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
|
|
3488
|
-
throw new
|
|
3488
|
+
throw new chunkL24YAW4G_cjs.InvalidResponseDataError({
|
|
3489
3489
|
data: toolCallDelta,
|
|
3490
3490
|
message: `Expected 'function.name' to be a string.`
|
|
3491
3491
|
});
|
|
@@ -3601,7 +3601,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
3601
3601
|
for (const { role, content } of prompt) {
|
|
3602
3602
|
switch (role) {
|
|
3603
3603
|
case "system": {
|
|
3604
|
-
throw new
|
|
3604
|
+
throw new chunkL24YAW4G_cjs.InvalidPromptError({
|
|
3605
3605
|
message: "Unexpected system message in prompt: ${content}",
|
|
3606
3606
|
prompt
|
|
3607
3607
|
});
|
|
@@ -3627,7 +3627,7 @@ ${userMessage}
|
|
|
3627
3627
|
return part.text;
|
|
3628
3628
|
}
|
|
3629
3629
|
case "tool-call": {
|
|
3630
|
-
throw new
|
|
3630
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
3631
3631
|
functionality: "tool-call messages"
|
|
3632
3632
|
});
|
|
3633
3633
|
}
|
|
@@ -3640,7 +3640,7 @@ ${assistantMessage}
|
|
|
3640
3640
|
break;
|
|
3641
3641
|
}
|
|
3642
3642
|
case "tool": {
|
|
3643
|
-
throw new
|
|
3643
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
3644
3644
|
functionality: "tool messages"
|
|
3645
3645
|
});
|
|
3646
3646
|
}
|
|
@@ -4053,7 +4053,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
4053
4053
|
}) {
|
|
4054
4054
|
var _a2;
|
|
4055
4055
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
4056
|
-
throw new
|
|
4056
|
+
throw new chunkL24YAW4G_cjs.TooManyEmbeddingValuesForCallError({
|
|
4057
4057
|
provider: this.provider,
|
|
4058
4058
|
modelId: this.modelId,
|
|
4059
4059
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -4670,7 +4670,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4670
4670
|
}
|
|
4671
4671
|
};
|
|
4672
4672
|
} else {
|
|
4673
|
-
throw new
|
|
4673
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
4674
4674
|
functionality: `file part media type ${part.mediaType}`
|
|
4675
4675
|
});
|
|
4676
4676
|
}
|
|
@@ -5735,7 +5735,7 @@ async function prepareResponsesTools({
|
|
|
5735
5735
|
};
|
|
5736
5736
|
default: {
|
|
5737
5737
|
const _exhaustiveCheck = type;
|
|
5738
|
-
throw new
|
|
5738
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
5739
5739
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
5740
5740
|
});
|
|
5741
5741
|
}
|
|
@@ -5993,7 +5993,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5993
5993
|
fetch: this.config.fetch
|
|
5994
5994
|
});
|
|
5995
5995
|
if (response.error) {
|
|
5996
|
-
throw new
|
|
5996
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
5997
5997
|
message: response.error.message,
|
|
5998
5998
|
url,
|
|
5999
5999
|
requestBodyValues: body,
|
|
@@ -6936,7 +6936,7 @@ function createAzure(options = {}) {
|
|
|
6936
6936
|
createAzure();
|
|
6937
6937
|
|
|
6938
6938
|
// src/llm/model/gateways/azure.ts
|
|
6939
|
-
var AzureOpenAIGateway = class extends
|
|
6939
|
+
var AzureOpenAIGateway = class extends chunkL24YAW4G_cjs.MastraModelGateway {
|
|
6940
6940
|
constructor(config) {
|
|
6941
6941
|
super();
|
|
6942
6942
|
this.config = config;
|
|
@@ -7145,7 +7145,7 @@ var AzureOpenAIGateway = class extends chunkQ5JACXBM_cjs.MastraModelGateway {
|
|
|
7145
7145
|
apiKey,
|
|
7146
7146
|
apiVersion,
|
|
7147
7147
|
useDeploymentBasedUrls: true,
|
|
7148
|
-
headers: { "User-Agent":
|
|
7148
|
+
headers: { "User-Agent": chunkL24YAW4G_cjs.MASTRA_USER_AGENT, ...headers }
|
|
7149
7149
|
})(modelId);
|
|
7150
7150
|
}
|
|
7151
7151
|
};
|
|
@@ -7381,12 +7381,12 @@ function stableHeaderKey(headers) {
|
|
|
7381
7381
|
return JSON.stringify(entries.sort(([a], [b]) => a.localeCompare(b)));
|
|
7382
7382
|
}
|
|
7383
7383
|
function getStaticProvidersByGateway(name2) {
|
|
7384
|
-
return Object.fromEntries(Object.entries(
|
|
7384
|
+
return Object.fromEntries(Object.entries(chunkIIV77JRY_cjs.PROVIDER_REGISTRY).filter(([_provider, config]) => config.gateway === name2));
|
|
7385
7385
|
}
|
|
7386
7386
|
var defaultGateways = [
|
|
7387
|
-
new
|
|
7388
|
-
new
|
|
7389
|
-
new
|
|
7387
|
+
new chunkNC4C5XMF_cjs.NetlifyGateway(),
|
|
7388
|
+
new chunkIIV77JRY_cjs.MastraGateway(),
|
|
7389
|
+
new chunkF3DC3HPB_cjs.ModelsDevGateway(getStaticProvidersByGateway(`models.dev`))
|
|
7390
7390
|
];
|
|
7391
7391
|
var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
7392
7392
|
specificationVersion = "v2";
|
|
@@ -7435,7 +7435,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7435
7435
|
this.gateway = findGatewayForModel(normalizedConfig.id, allGateways);
|
|
7436
7436
|
this.gatewayId = this.gateway.id;
|
|
7437
7437
|
const gatewayPrefix = this.gateway.id === "models.dev" ? void 0 : this.gateway.id;
|
|
7438
|
-
const parsed =
|
|
7438
|
+
const parsed = chunkF3DC3HPB_cjs.parseModelRouterId(normalizedConfig.id, gatewayPrefix);
|
|
7439
7439
|
this.provider = parsed.providerId || "openai-compatible";
|
|
7440
7440
|
if (parsed.providerId && parsed.modelId !== normalizedConfig.id) {
|
|
7441
7441
|
parsedConfig.id = parsed.modelId;
|
|
@@ -7481,7 +7481,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7481
7481
|
const model = await this.resolveLanguageModel({
|
|
7482
7482
|
apiKey,
|
|
7483
7483
|
headers: this.config.headers,
|
|
7484
|
-
...
|
|
7484
|
+
...chunkF3DC3HPB_cjs.parseModelRouterId(this.config.routerId, gatewayPrefix)
|
|
7485
7485
|
});
|
|
7486
7486
|
const modelSupportedUrls = model.supportedUrls;
|
|
7487
7487
|
if (!modelSupportedUrls) {
|
|
@@ -7559,7 +7559,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7559
7559
|
const model = await this.resolveLanguageModel({
|
|
7560
7560
|
apiKey,
|
|
7561
7561
|
headers: this.config.headers,
|
|
7562
|
-
...
|
|
7562
|
+
...chunkF3DC3HPB_cjs.parseModelRouterId(this.config.routerId, gatewayPrefix)
|
|
7563
7563
|
});
|
|
7564
7564
|
if (isLanguageModelV3(model)) {
|
|
7565
7565
|
const aiSDKV6Model = new AISDKV6LanguageModel(model);
|
|
@@ -7599,7 +7599,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7599
7599
|
headers: this.config.headers,
|
|
7600
7600
|
transport: resolvedTransport,
|
|
7601
7601
|
openaiWebSocket: websocket,
|
|
7602
|
-
...
|
|
7602
|
+
...chunkF3DC3HPB_cjs.parseModelRouterId(this.config.routerId, gatewayPrefix)
|
|
7603
7603
|
});
|
|
7604
7604
|
if (isLanguageModelV3(model)) {
|
|
7605
7605
|
const aiSDKV6Model = new AISDKV6LanguageModel(model);
|
|
@@ -7626,7 +7626,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7626
7626
|
return _ModelRouterLanguageModel.modelInstances.get(key);
|
|
7627
7627
|
}
|
|
7628
7628
|
if (this.config.url) {
|
|
7629
|
-
const modelInstance2 =
|
|
7629
|
+
const modelInstance2 = chunkL24YAW4G_cjs.createOpenAICompatible({
|
|
7630
7630
|
name: providerId,
|
|
7631
7631
|
apiKey,
|
|
7632
7632
|
baseURL: this.config.url,
|
|
@@ -7669,7 +7669,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7669
7669
|
url: openaiWebSocket?.url,
|
|
7670
7670
|
headers: openaiWebSocket?.headers
|
|
7671
7671
|
});
|
|
7672
|
-
const modelInstance =
|
|
7672
|
+
const modelInstance = chunkL24YAW4G_cjs.createOpenAI({
|
|
7673
7673
|
apiKey,
|
|
7674
7674
|
baseURL,
|
|
7675
7675
|
headers,
|
|
@@ -7761,8 +7761,8 @@ async function resolveModelConfig(modelConfig, requestContext = new chunkNCM7IIB
|
|
|
7761
7761
|
throw new Error("Invalid model configuration provided");
|
|
7762
7762
|
}
|
|
7763
7763
|
var VERSION3 = "2.0.68" ;
|
|
7764
|
-
var googleErrorDataSchema =
|
|
7765
|
-
() =>
|
|
7764
|
+
var googleErrorDataSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
7765
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
7766
7766
|
z4.z.object({
|
|
7767
7767
|
error: z4.z.object({
|
|
7768
7768
|
code: z4.z.number().nullable(),
|
|
@@ -7772,7 +7772,7 @@ var googleErrorDataSchema = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
7772
7772
|
})
|
|
7773
7773
|
)
|
|
7774
7774
|
);
|
|
7775
|
-
var googleFailedResponseHandler =
|
|
7775
|
+
var googleFailedResponseHandler = chunkL24YAW4G_cjs.createJsonErrorResponseHandler({
|
|
7776
7776
|
errorSchema: googleErrorDataSchema,
|
|
7777
7777
|
errorToMessage: (data) => data.error.message
|
|
7778
7778
|
});
|
|
@@ -7785,8 +7785,8 @@ var googleEmbeddingContentPartSchema = z4.z.union([
|
|
|
7785
7785
|
})
|
|
7786
7786
|
})
|
|
7787
7787
|
]);
|
|
7788
|
-
var googleGenerativeAIEmbeddingProviderOptions =
|
|
7789
|
-
() =>
|
|
7788
|
+
var googleGenerativeAIEmbeddingProviderOptions = chunkL24YAW4G_cjs.lazySchema(
|
|
7789
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
7790
7790
|
z4.z.object({
|
|
7791
7791
|
/**
|
|
7792
7792
|
* Optional. Optional reduced dimension for the output embedding.
|
|
@@ -7845,21 +7845,21 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7845
7845
|
abortSignal,
|
|
7846
7846
|
providerOptions
|
|
7847
7847
|
}) {
|
|
7848
|
-
const googleOptions = await
|
|
7848
|
+
const googleOptions = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
7849
7849
|
provider: "google",
|
|
7850
7850
|
providerOptions,
|
|
7851
7851
|
schema: googleGenerativeAIEmbeddingProviderOptions
|
|
7852
7852
|
});
|
|
7853
7853
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
7854
|
-
throw new
|
|
7854
|
+
throw new chunkL24YAW4G_cjs.TooManyEmbeddingValuesForCallError({
|
|
7855
7855
|
provider: this.provider,
|
|
7856
7856
|
modelId: this.modelId,
|
|
7857
7857
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
7858
7858
|
values
|
|
7859
7859
|
});
|
|
7860
7860
|
}
|
|
7861
|
-
const mergedHeaders =
|
|
7862
|
-
await
|
|
7861
|
+
const mergedHeaders = chunkL24YAW4G_cjs.combineHeaders(
|
|
7862
|
+
await chunkL24YAW4G_cjs.resolve(this.config.headers),
|
|
7863
7863
|
headers
|
|
7864
7864
|
);
|
|
7865
7865
|
const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
|
|
@@ -7876,7 +7876,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7876
7876
|
responseHeaders: responseHeaders2,
|
|
7877
7877
|
value: response2,
|
|
7878
7878
|
rawValue: rawValue2
|
|
7879
|
-
} = await
|
|
7879
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
7880
7880
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
7881
7881
|
headers: mergedHeaders,
|
|
7882
7882
|
body: {
|
|
@@ -7888,7 +7888,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7888
7888
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
7889
7889
|
},
|
|
7890
7890
|
failedResponseHandler: googleFailedResponseHandler,
|
|
7891
|
-
successfulResponseHandler:
|
|
7891
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
7892
7892
|
googleGenerativeAISingleEmbeddingResponseSchema
|
|
7893
7893
|
),
|
|
7894
7894
|
abortSignal,
|
|
@@ -7904,7 +7904,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7904
7904
|
responseHeaders,
|
|
7905
7905
|
value: response,
|
|
7906
7906
|
rawValue
|
|
7907
|
-
} = await
|
|
7907
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
7908
7908
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
7909
7909
|
headers: mergedHeaders,
|
|
7910
7910
|
body: {
|
|
@@ -7923,7 +7923,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7923
7923
|
})
|
|
7924
7924
|
},
|
|
7925
7925
|
failedResponseHandler: googleFailedResponseHandler,
|
|
7926
|
-
successfulResponseHandler:
|
|
7926
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
7927
7927
|
googleGenerativeAITextEmbeddingResponseSchema
|
|
7928
7928
|
),
|
|
7929
7929
|
abortSignal,
|
|
@@ -7936,15 +7936,15 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7936
7936
|
};
|
|
7937
7937
|
}
|
|
7938
7938
|
};
|
|
7939
|
-
var googleGenerativeAITextEmbeddingResponseSchema =
|
|
7940
|
-
() =>
|
|
7939
|
+
var googleGenerativeAITextEmbeddingResponseSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
7940
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
7941
7941
|
z4.z.object({
|
|
7942
7942
|
embeddings: z4.z.array(z4.z.object({ values: z4.z.array(z4.z.number()) }))
|
|
7943
7943
|
})
|
|
7944
7944
|
)
|
|
7945
7945
|
);
|
|
7946
|
-
var googleGenerativeAISingleEmbeddingResponseSchema =
|
|
7947
|
-
() =>
|
|
7946
|
+
var googleGenerativeAISingleEmbeddingResponseSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
7947
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
7948
7948
|
z4.z.object({
|
|
7949
7949
|
embedding: z4.z.object({ values: z4.z.array(z4.z.number()) })
|
|
7950
7950
|
})
|
|
@@ -8075,7 +8075,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
8075
8075
|
switch (role) {
|
|
8076
8076
|
case "system": {
|
|
8077
8077
|
if (!systemMessagesAllowed) {
|
|
8078
|
-
throw new
|
|
8078
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
8079
8079
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
8080
8080
|
});
|
|
8081
8081
|
}
|
|
@@ -8102,7 +8102,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
8102
8102
|
} : {
|
|
8103
8103
|
inlineData: {
|
|
8104
8104
|
mimeType: mediaType,
|
|
8105
|
-
data:
|
|
8105
|
+
data: chunkL24YAW4G_cjs.convertToBase64(part.data)
|
|
8106
8106
|
}
|
|
8107
8107
|
}
|
|
8108
8108
|
);
|
|
@@ -8136,19 +8136,19 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
8136
8136
|
}
|
|
8137
8137
|
case "file": {
|
|
8138
8138
|
if (part.mediaType !== "image/png") {
|
|
8139
|
-
throw new
|
|
8139
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
8140
8140
|
functionality: "Only PNG images are supported in assistant messages"
|
|
8141
8141
|
});
|
|
8142
8142
|
}
|
|
8143
8143
|
if (part.data instanceof URL) {
|
|
8144
|
-
throw new
|
|
8144
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
8145
8145
|
functionality: "File data URLs in assistant messages are not supported"
|
|
8146
8146
|
});
|
|
8147
8147
|
}
|
|
8148
8148
|
return {
|
|
8149
8149
|
inlineData: {
|
|
8150
8150
|
mimeType: part.mediaType,
|
|
8151
|
-
data:
|
|
8151
|
+
data: chunkL24YAW4G_cjs.convertToBase64(part.data)
|
|
8152
8152
|
}
|
|
8153
8153
|
};
|
|
8154
8154
|
}
|
|
@@ -8280,8 +8280,8 @@ function appendLegacyToolResultParts({
|
|
|
8280
8280
|
function getModelPath(modelId) {
|
|
8281
8281
|
return modelId.includes("/") ? modelId : `models/${modelId}`;
|
|
8282
8282
|
}
|
|
8283
|
-
var googleGenerativeAIProviderOptions =
|
|
8284
|
-
() =>
|
|
8283
|
+
var googleGenerativeAIProviderOptions = chunkL24YAW4G_cjs.lazySchema(
|
|
8284
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
8285
8285
|
z4.z.object({
|
|
8286
8286
|
responseModalities: z4.z.array(z4.z.enum(["TEXT", "IMAGE"])).optional(),
|
|
8287
8287
|
thinkingConfig: z4.z.object({
|
|
@@ -8596,7 +8596,7 @@ function prepareTools({
|
|
|
8596
8596
|
};
|
|
8597
8597
|
default: {
|
|
8598
8598
|
const _exhaustiveCheck = type;
|
|
8599
|
-
throw new
|
|
8599
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
8600
8600
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
8601
8601
|
});
|
|
8602
8602
|
}
|
|
@@ -8633,7 +8633,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8633
8633
|
var _a2;
|
|
8634
8634
|
this.modelId = modelId;
|
|
8635
8635
|
this.config = config;
|
|
8636
|
-
this.generateId = (_a2 = config.generateId) != null ? _a2 :
|
|
8636
|
+
this.generateId = (_a2 = config.generateId) != null ? _a2 : chunkL24YAW4G_cjs.generateId;
|
|
8637
8637
|
}
|
|
8638
8638
|
get provider() {
|
|
8639
8639
|
return this.config.provider;
|
|
@@ -8659,7 +8659,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8659
8659
|
}) {
|
|
8660
8660
|
var _a2;
|
|
8661
8661
|
const warnings = [];
|
|
8662
|
-
const googleOptions = await
|
|
8662
|
+
const googleOptions = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
8663
8663
|
provider: "google",
|
|
8664
8664
|
providerOptions,
|
|
8665
8665
|
schema: googleGenerativeAIProviderOptions
|
|
@@ -8742,22 +8742,22 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8742
8742
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8743
8743
|
const { args, warnings } = await this.getArgs(options);
|
|
8744
8744
|
const body = JSON.stringify(args);
|
|
8745
|
-
const mergedHeaders =
|
|
8746
|
-
await
|
|
8745
|
+
const mergedHeaders = chunkL24YAW4G_cjs.combineHeaders(
|
|
8746
|
+
await chunkL24YAW4G_cjs.resolve(this.config.headers),
|
|
8747
8747
|
options.headers
|
|
8748
8748
|
);
|
|
8749
8749
|
const {
|
|
8750
8750
|
responseHeaders,
|
|
8751
8751
|
value: response,
|
|
8752
8752
|
rawValue: rawResponse
|
|
8753
|
-
} = await
|
|
8753
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
8754
8754
|
url: `${this.config.baseURL}/${getModelPath(
|
|
8755
8755
|
this.modelId
|
|
8756
8756
|
)}:generateContent`,
|
|
8757
8757
|
headers: mergedHeaders,
|
|
8758
8758
|
body: args,
|
|
8759
8759
|
failedResponseHandler: googleFailedResponseHandler,
|
|
8760
|
-
successfulResponseHandler:
|
|
8760
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(responseSchema),
|
|
8761
8761
|
abortSignal: options.abortSignal,
|
|
8762
8762
|
fetch: this.config.fetch
|
|
8763
8763
|
});
|
|
@@ -8863,18 +8863,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8863
8863
|
async doStream(options) {
|
|
8864
8864
|
const { args, warnings } = await this.getArgs(options);
|
|
8865
8865
|
const body = JSON.stringify(args);
|
|
8866
|
-
const headers =
|
|
8867
|
-
await
|
|
8866
|
+
const headers = chunkL24YAW4G_cjs.combineHeaders(
|
|
8867
|
+
await chunkL24YAW4G_cjs.resolve(this.config.headers),
|
|
8868
8868
|
options.headers
|
|
8869
8869
|
);
|
|
8870
|
-
const { responseHeaders, value: response } = await
|
|
8870
|
+
const { responseHeaders, value: response } = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
8871
8871
|
url: `${this.config.baseURL}/${getModelPath(
|
|
8872
8872
|
this.modelId
|
|
8873
8873
|
)}:streamGenerateContent?alt=sse`,
|
|
8874
8874
|
headers,
|
|
8875
8875
|
body: args,
|
|
8876
8876
|
failedResponseHandler: googleFailedResponseHandler,
|
|
8877
|
-
successfulResponseHandler:
|
|
8877
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createEventSourceResponseHandler(chunkSchema),
|
|
8878
8878
|
abortSignal: options.abortSignal,
|
|
8879
8879
|
fetch: this.config.fetch
|
|
8880
8880
|
});
|
|
@@ -9347,8 +9347,8 @@ var getUrlContextMetadataSchema = () => z4.z.object({
|
|
|
9347
9347
|
})
|
|
9348
9348
|
)
|
|
9349
9349
|
});
|
|
9350
|
-
var responseSchema =
|
|
9351
|
-
() =>
|
|
9350
|
+
var responseSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
9351
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
9352
9352
|
z4.z.object({
|
|
9353
9353
|
candidates: z4.z.array(
|
|
9354
9354
|
z4.z.object({
|
|
@@ -9368,8 +9368,8 @@ var responseSchema = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
9368
9368
|
})
|
|
9369
9369
|
)
|
|
9370
9370
|
);
|
|
9371
|
-
var chunkSchema =
|
|
9372
|
-
() =>
|
|
9371
|
+
var chunkSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
9372
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
9373
9373
|
z4.z.object({
|
|
9374
9374
|
candidates: z4.z.array(
|
|
9375
9375
|
z4.z.object({
|
|
@@ -9389,7 +9389,7 @@ var chunkSchema = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
9389
9389
|
})
|
|
9390
9390
|
)
|
|
9391
9391
|
);
|
|
9392
|
-
var codeExecution =
|
|
9392
|
+
var codeExecution = chunkL24YAW4G_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
9393
9393
|
id: "google.code_execution",
|
|
9394
9394
|
name: "code_execution",
|
|
9395
9395
|
inputSchema: z4.z.object({
|
|
@@ -9401,10 +9401,10 @@ var codeExecution = chunkQ5JACXBM_cjs.createProviderDefinedToolFactoryWithOutput
|
|
|
9401
9401
|
output: z4.z.string().describe("The output from the code execution.")
|
|
9402
9402
|
})
|
|
9403
9403
|
});
|
|
9404
|
-
var enterpriseWebSearch =
|
|
9404
|
+
var enterpriseWebSearch = chunkL24YAW4G_cjs.createProviderDefinedToolFactory({
|
|
9405
9405
|
id: "google.enterprise_web_search",
|
|
9406
9406
|
name: "enterprise_web_search",
|
|
9407
|
-
inputSchema:
|
|
9407
|
+
inputSchema: chunkL24YAW4G_cjs.lazySchema(() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({})))
|
|
9408
9408
|
});
|
|
9409
9409
|
var fileSearchArgsBaseSchema = z4.z.object({
|
|
9410
9410
|
/** The names of the file_search_stores to retrieve from.
|
|
@@ -9422,18 +9422,18 @@ var fileSearchArgsBaseSchema = z4.z.object({
|
|
|
9422
9422
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
9423
9423
|
).optional()
|
|
9424
9424
|
}).passthrough();
|
|
9425
|
-
var fileSearchArgsSchema2 =
|
|
9426
|
-
() =>
|
|
9425
|
+
var fileSearchArgsSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
9426
|
+
() => chunkL24YAW4G_cjs.zodSchema(fileSearchArgsBaseSchema)
|
|
9427
9427
|
);
|
|
9428
|
-
var fileSearch2 =
|
|
9428
|
+
var fileSearch2 = chunkL24YAW4G_cjs.createProviderDefinedToolFactory({
|
|
9429
9429
|
id: "google.file_search",
|
|
9430
9430
|
name: "file_search",
|
|
9431
9431
|
inputSchema: fileSearchArgsSchema2
|
|
9432
9432
|
});
|
|
9433
|
-
var googleMaps =
|
|
9433
|
+
var googleMaps = chunkL24YAW4G_cjs.createProviderDefinedToolFactory({
|
|
9434
9434
|
id: "google.google_maps",
|
|
9435
9435
|
name: "google_maps",
|
|
9436
|
-
inputSchema:
|
|
9436
|
+
inputSchema: chunkL24YAW4G_cjs.lazySchema(() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({})))
|
|
9437
9437
|
});
|
|
9438
9438
|
var googleSearchToolArgsBaseSchema = z4.z.object({
|
|
9439
9439
|
searchTypes: z4.z.object({
|
|
@@ -9445,20 +9445,20 @@ var googleSearchToolArgsBaseSchema = z4.z.object({
|
|
|
9445
9445
|
endTime: z4.z.string()
|
|
9446
9446
|
}).optional()
|
|
9447
9447
|
}).passthrough();
|
|
9448
|
-
var googleSearchToolArgsSchema =
|
|
9449
|
-
() =>
|
|
9448
|
+
var googleSearchToolArgsSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
9449
|
+
() => chunkL24YAW4G_cjs.zodSchema(googleSearchToolArgsBaseSchema)
|
|
9450
9450
|
);
|
|
9451
|
-
var googleSearch =
|
|
9451
|
+
var googleSearch = chunkL24YAW4G_cjs.createProviderDefinedToolFactory({
|
|
9452
9452
|
id: "google.google_search",
|
|
9453
9453
|
name: "google_search",
|
|
9454
9454
|
inputSchema: googleSearchToolArgsSchema
|
|
9455
9455
|
});
|
|
9456
|
-
var urlContext =
|
|
9456
|
+
var urlContext = chunkL24YAW4G_cjs.createProviderDefinedToolFactory({
|
|
9457
9457
|
id: "google.url_context",
|
|
9458
9458
|
name: "url_context",
|
|
9459
|
-
inputSchema:
|
|
9459
|
+
inputSchema: chunkL24YAW4G_cjs.lazySchema(() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({})))
|
|
9460
9460
|
});
|
|
9461
|
-
var vertexRagStore =
|
|
9461
|
+
var vertexRagStore = chunkL24YAW4G_cjs.createProviderDefinedToolFactory({
|
|
9462
9462
|
id: "google.vertex_rag_store",
|
|
9463
9463
|
name: "vertex_rag_store",
|
|
9464
9464
|
inputSchema: z4.z.object({
|
|
@@ -9565,7 +9565,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
9565
9565
|
details: "This model does not support the `seed` option through this provider."
|
|
9566
9566
|
});
|
|
9567
9567
|
}
|
|
9568
|
-
const googleOptions = await
|
|
9568
|
+
const googleOptions = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
9569
9569
|
provider: "google",
|
|
9570
9570
|
providerOptions,
|
|
9571
9571
|
schema: googleImageProviderOptionsSchema
|
|
@@ -9584,12 +9584,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
9584
9584
|
instances: [{ prompt }],
|
|
9585
9585
|
parameters
|
|
9586
9586
|
};
|
|
9587
|
-
const { responseHeaders, value: response } = await
|
|
9587
|
+
const { responseHeaders, value: response } = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
9588
9588
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
9589
|
-
headers:
|
|
9589
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(await chunkL24YAW4G_cjs.resolve(this.config.headers), headers),
|
|
9590
9590
|
body,
|
|
9591
9591
|
failedResponseHandler: googleFailedResponseHandler,
|
|
9592
|
-
successfulResponseHandler:
|
|
9592
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
9593
9593
|
googleImageResponseSchema
|
|
9594
9594
|
),
|
|
9595
9595
|
abortSignal,
|
|
@@ -9615,15 +9615,15 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
9615
9615
|
};
|
|
9616
9616
|
}
|
|
9617
9617
|
};
|
|
9618
|
-
var googleImageResponseSchema =
|
|
9619
|
-
() =>
|
|
9618
|
+
var googleImageResponseSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
9619
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
9620
9620
|
z4.z.object({
|
|
9621
9621
|
predictions: z4.z.array(z4.z.object({ bytesBase64Encoded: z4.z.string() })).default([])
|
|
9622
9622
|
})
|
|
9623
9623
|
)
|
|
9624
9624
|
);
|
|
9625
|
-
var googleImageProviderOptionsSchema =
|
|
9626
|
-
() =>
|
|
9625
|
+
var googleImageProviderOptionsSchema = chunkL24YAW4G_cjs.lazySchema(
|
|
9626
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
9627
9627
|
z4.z.object({
|
|
9628
9628
|
personGeneration: z4.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
9629
9629
|
aspectRatio: z4.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
@@ -9632,11 +9632,11 @@ var googleImageProviderOptionsSchema = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
9632
9632
|
);
|
|
9633
9633
|
function createGoogleGenerativeAI(options = {}) {
|
|
9634
9634
|
var _a2, _b2;
|
|
9635
|
-
const baseURL = (_a2 =
|
|
9635
|
+
const baseURL = (_a2 = chunkL24YAW4G_cjs.withoutTrailingSlash(options.baseURL)) != null ? _a2 : "https://generativelanguage.googleapis.com/v1beta";
|
|
9636
9636
|
const providerName = (_b2 = options.name) != null ? _b2 : "google.generative-ai";
|
|
9637
|
-
const getHeaders = () =>
|
|
9637
|
+
const getHeaders = () => chunkL24YAW4G_cjs.withUserAgentSuffix(
|
|
9638
9638
|
{
|
|
9639
|
-
"x-goog-api-key":
|
|
9639
|
+
"x-goog-api-key": chunkL24YAW4G_cjs.loadApiKey({
|
|
9640
9640
|
apiKey: options.apiKey,
|
|
9641
9641
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
9642
9642
|
description: "Google Generative AI"
|
|
@@ -9651,7 +9651,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
9651
9651
|
provider: providerName,
|
|
9652
9652
|
baseURL,
|
|
9653
9653
|
headers: getHeaders,
|
|
9654
|
-
generateId: (_a22 = options.generateId) != null ? _a22 :
|
|
9654
|
+
generateId: (_a22 = options.generateId) != null ? _a22 : chunkL24YAW4G_cjs.generateId,
|
|
9655
9655
|
supportedUrls: () => ({
|
|
9656
9656
|
"*": [
|
|
9657
9657
|
// Google Generative Language "files" endpoint
|
|
@@ -9710,7 +9710,7 @@ var openaiErrorDataSchema2 = z4.z.object({
|
|
|
9710
9710
|
code: z4.z.union([z4.z.string(), z4.z.number()]).nullish()
|
|
9711
9711
|
})
|
|
9712
9712
|
});
|
|
9713
|
-
var openaiFailedResponseHandler2 =
|
|
9713
|
+
var openaiFailedResponseHandler2 = chunkL24YAW4G_cjs.createJsonErrorResponseHandler({
|
|
9714
9714
|
errorSchema: openaiErrorDataSchema2,
|
|
9715
9715
|
errorToMessage: (data) => data.error.message
|
|
9716
9716
|
});
|
|
@@ -9781,14 +9781,14 @@ function convertToOpenAIChatMessages2({
|
|
|
9781
9781
|
return {
|
|
9782
9782
|
type: "image_url",
|
|
9783
9783
|
image_url: {
|
|
9784
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
9784
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunkL24YAW4G_cjs.convertToBase64(part.data)}`,
|
|
9785
9785
|
// OpenAI specific extension: image detail
|
|
9786
9786
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
9787
9787
|
}
|
|
9788
9788
|
};
|
|
9789
9789
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
9790
9790
|
if (part.data instanceof URL) {
|
|
9791
|
-
throw new
|
|
9791
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
9792
9792
|
functionality: "audio file parts with URLs"
|
|
9793
9793
|
});
|
|
9794
9794
|
}
|
|
@@ -9797,7 +9797,7 @@ function convertToOpenAIChatMessages2({
|
|
|
9797
9797
|
return {
|
|
9798
9798
|
type: "input_audio",
|
|
9799
9799
|
input_audio: {
|
|
9800
|
-
data:
|
|
9800
|
+
data: chunkL24YAW4G_cjs.convertToBase64(part.data),
|
|
9801
9801
|
format: "wav"
|
|
9802
9802
|
}
|
|
9803
9803
|
};
|
|
@@ -9807,20 +9807,20 @@ function convertToOpenAIChatMessages2({
|
|
|
9807
9807
|
return {
|
|
9808
9808
|
type: "input_audio",
|
|
9809
9809
|
input_audio: {
|
|
9810
|
-
data:
|
|
9810
|
+
data: chunkL24YAW4G_cjs.convertToBase64(part.data),
|
|
9811
9811
|
format: "mp3"
|
|
9812
9812
|
}
|
|
9813
9813
|
};
|
|
9814
9814
|
}
|
|
9815
9815
|
default: {
|
|
9816
|
-
throw new
|
|
9816
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
9817
9817
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
9818
9818
|
});
|
|
9819
9819
|
}
|
|
9820
9820
|
}
|
|
9821
9821
|
} else if (part.mediaType === "application/pdf") {
|
|
9822
9822
|
if (part.data instanceof URL) {
|
|
9823
|
-
throw new
|
|
9823
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
9824
9824
|
functionality: "PDF file parts with URLs"
|
|
9825
9825
|
});
|
|
9826
9826
|
}
|
|
@@ -9828,11 +9828,11 @@ function convertToOpenAIChatMessages2({
|
|
|
9828
9828
|
type: "file",
|
|
9829
9829
|
file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
9830
9830
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
9831
|
-
file_data: `data:application/pdf;base64,${
|
|
9831
|
+
file_data: `data:application/pdf;base64,${chunkL24YAW4G_cjs.convertToBase64(part.data)}`
|
|
9832
9832
|
}
|
|
9833
9833
|
};
|
|
9834
9834
|
} else {
|
|
9835
|
-
throw new
|
|
9835
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
9836
9836
|
functionality: `file part media type ${part.mediaType}`
|
|
9837
9837
|
});
|
|
9838
9838
|
}
|
|
@@ -9928,8 +9928,8 @@ function mapOpenAIFinishReason3(finishReason) {
|
|
|
9928
9928
|
return "unknown";
|
|
9929
9929
|
}
|
|
9930
9930
|
}
|
|
9931
|
-
var openaiChatResponseSchema2 =
|
|
9932
|
-
() =>
|
|
9931
|
+
var openaiChatResponseSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
9932
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
9933
9933
|
z4.z.object({
|
|
9934
9934
|
id: z4.z.string().nullish(),
|
|
9935
9935
|
created: z4.z.number().nullish(),
|
|
@@ -9995,8 +9995,8 @@ var openaiChatResponseSchema2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
9995
9995
|
})
|
|
9996
9996
|
)
|
|
9997
9997
|
);
|
|
9998
|
-
var openaiChatChunkSchema2 =
|
|
9999
|
-
() =>
|
|
9998
|
+
var openaiChatChunkSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
9999
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
10000
10000
|
z4.z.union([
|
|
10001
10001
|
z4.z.object({
|
|
10002
10002
|
id: z4.z.string().nullish(),
|
|
@@ -10066,8 +10066,8 @@ var openaiChatChunkSchema2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
10066
10066
|
])
|
|
10067
10067
|
)
|
|
10068
10068
|
);
|
|
10069
|
-
var openaiChatLanguageModelOptions2 =
|
|
10070
|
-
() =>
|
|
10069
|
+
var openaiChatLanguageModelOptions2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
10070
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
10071
10071
|
z4.z.object({
|
|
10072
10072
|
/**
|
|
10073
10073
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
@@ -10220,7 +10220,7 @@ function prepareChatTools2({
|
|
|
10220
10220
|
};
|
|
10221
10221
|
default: {
|
|
10222
10222
|
const _exhaustiveCheck = type;
|
|
10223
|
-
throw new
|
|
10223
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
10224
10224
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
10225
10225
|
});
|
|
10226
10226
|
}
|
|
@@ -10255,7 +10255,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10255
10255
|
}) {
|
|
10256
10256
|
var _a2, _b2, _c, _d;
|
|
10257
10257
|
const warnings = [];
|
|
10258
|
-
const openaiOptions = (_a2 = await
|
|
10258
|
+
const openaiOptions = (_a2 = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
10259
10259
|
provider: "openai",
|
|
10260
10260
|
providerOptions,
|
|
10261
10261
|
schema: openaiChatLanguageModelOptions2
|
|
@@ -10438,15 +10438,15 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10438
10438
|
responseHeaders,
|
|
10439
10439
|
value: response,
|
|
10440
10440
|
rawValue: rawResponse
|
|
10441
|
-
} = await
|
|
10441
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
10442
10442
|
url: this.config.url({
|
|
10443
10443
|
path: "/chat/completions",
|
|
10444
10444
|
modelId: this.modelId
|
|
10445
10445
|
}),
|
|
10446
|
-
headers:
|
|
10446
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
10447
10447
|
body,
|
|
10448
10448
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
10449
|
-
successfulResponseHandler:
|
|
10449
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
10450
10450
|
openaiChatResponseSchema2
|
|
10451
10451
|
),
|
|
10452
10452
|
abortSignal: options.abortSignal,
|
|
@@ -10461,7 +10461,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10461
10461
|
for (const toolCall of (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
|
|
10462
10462
|
content.push({
|
|
10463
10463
|
type: "tool-call",
|
|
10464
|
-
toolCallId: (_b2 = toolCall.id) != null ? _b2 :
|
|
10464
|
+
toolCallId: (_b2 = toolCall.id) != null ? _b2 : chunkL24YAW4G_cjs.generateId(),
|
|
10465
10465
|
toolName: toolCall.function.name,
|
|
10466
10466
|
input: toolCall.function.arguments
|
|
10467
10467
|
});
|
|
@@ -10470,7 +10470,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10470
10470
|
content.push({
|
|
10471
10471
|
type: "source",
|
|
10472
10472
|
sourceType: "url",
|
|
10473
|
-
id:
|
|
10473
|
+
id: chunkL24YAW4G_cjs.generateId(),
|
|
10474
10474
|
url: annotation.url_citation.url,
|
|
10475
10475
|
title: annotation.url_citation.title
|
|
10476
10476
|
});
|
|
@@ -10516,15 +10516,15 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10516
10516
|
include_usage: true
|
|
10517
10517
|
}
|
|
10518
10518
|
};
|
|
10519
|
-
const { responseHeaders, value: response } = await
|
|
10519
|
+
const { responseHeaders, value: response } = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
10520
10520
|
url: this.config.url({
|
|
10521
10521
|
path: "/chat/completions",
|
|
10522
10522
|
modelId: this.modelId
|
|
10523
10523
|
}),
|
|
10524
|
-
headers:
|
|
10524
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
10525
10525
|
body,
|
|
10526
10526
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
10527
|
-
successfulResponseHandler:
|
|
10527
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createEventSourceResponseHandler(
|
|
10528
10528
|
openaiChatChunkSchema2
|
|
10529
10529
|
),
|
|
10530
10530
|
abortSignal: options.abortSignal,
|
|
@@ -10612,19 +10612,19 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10612
10612
|
const index = toolCallDelta.index;
|
|
10613
10613
|
if (toolCalls[index] == null) {
|
|
10614
10614
|
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
10615
|
-
throw new
|
|
10615
|
+
throw new chunkL24YAW4G_cjs.InvalidResponseDataError({
|
|
10616
10616
|
data: toolCallDelta,
|
|
10617
10617
|
message: `Expected 'function' type.`
|
|
10618
10618
|
});
|
|
10619
10619
|
}
|
|
10620
10620
|
if (toolCallDelta.id == null) {
|
|
10621
|
-
throw new
|
|
10621
|
+
throw new chunkL24YAW4G_cjs.InvalidResponseDataError({
|
|
10622
10622
|
data: toolCallDelta,
|
|
10623
10623
|
message: `Expected 'id' to be a string.`
|
|
10624
10624
|
});
|
|
10625
10625
|
}
|
|
10626
10626
|
if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
|
|
10627
|
-
throw new
|
|
10627
|
+
throw new chunkL24YAW4G_cjs.InvalidResponseDataError({
|
|
10628
10628
|
data: toolCallDelta,
|
|
10629
10629
|
message: `Expected 'function.name' to be a string.`
|
|
10630
10630
|
});
|
|
@@ -10652,14 +10652,14 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10652
10652
|
delta: toolCall2.function.arguments
|
|
10653
10653
|
});
|
|
10654
10654
|
}
|
|
10655
|
-
if (
|
|
10655
|
+
if (chunkL24YAW4G_cjs.isParsableJson(toolCall2.function.arguments)) {
|
|
10656
10656
|
controller.enqueue({
|
|
10657
10657
|
type: "tool-input-end",
|
|
10658
10658
|
id: toolCall2.id
|
|
10659
10659
|
});
|
|
10660
10660
|
controller.enqueue({
|
|
10661
10661
|
type: "tool-call",
|
|
10662
|
-
toolCallId: (_q = toolCall2.id) != null ? _q :
|
|
10662
|
+
toolCallId: (_q = toolCall2.id) != null ? _q : chunkL24YAW4G_cjs.generateId(),
|
|
10663
10663
|
toolName: toolCall2.function.name,
|
|
10664
10664
|
input: toolCall2.function.arguments
|
|
10665
10665
|
});
|
|
@@ -10680,14 +10680,14 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10680
10680
|
id: toolCall.id,
|
|
10681
10681
|
delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
|
|
10682
10682
|
});
|
|
10683
|
-
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null &&
|
|
10683
|
+
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && chunkL24YAW4G_cjs.isParsableJson(toolCall.function.arguments)) {
|
|
10684
10684
|
controller.enqueue({
|
|
10685
10685
|
type: "tool-input-end",
|
|
10686
10686
|
id: toolCall.id
|
|
10687
10687
|
});
|
|
10688
10688
|
controller.enqueue({
|
|
10689
10689
|
type: "tool-call",
|
|
10690
|
-
toolCallId: (_x = toolCall.id) != null ? _x :
|
|
10690
|
+
toolCallId: (_x = toolCall.id) != null ? _x : chunkL24YAW4G_cjs.generateId(),
|
|
10691
10691
|
toolName: toolCall.function.name,
|
|
10692
10692
|
input: toolCall.function.arguments
|
|
10693
10693
|
});
|
|
@@ -10700,7 +10700,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10700
10700
|
controller.enqueue({
|
|
10701
10701
|
type: "source",
|
|
10702
10702
|
sourceType: "url",
|
|
10703
|
-
id:
|
|
10703
|
+
id: chunkL24YAW4G_cjs.generateId(),
|
|
10704
10704
|
url: annotation.url_citation.url,
|
|
10705
10705
|
title: annotation.url_citation.title
|
|
10706
10706
|
});
|
|
@@ -10740,7 +10740,7 @@ function convertToOpenAICompletionPrompt2({
|
|
|
10740
10740
|
for (const { role, content } of prompt) {
|
|
10741
10741
|
switch (role) {
|
|
10742
10742
|
case "system": {
|
|
10743
|
-
throw new
|
|
10743
|
+
throw new chunkL24YAW4G_cjs.InvalidPromptError({
|
|
10744
10744
|
message: "Unexpected system message in prompt: ${content}",
|
|
10745
10745
|
prompt
|
|
10746
10746
|
});
|
|
@@ -10766,7 +10766,7 @@ ${userMessage}
|
|
|
10766
10766
|
return part.text;
|
|
10767
10767
|
}
|
|
10768
10768
|
case "tool-call": {
|
|
10769
|
-
throw new
|
|
10769
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
10770
10770
|
functionality: "tool-call messages"
|
|
10771
10771
|
});
|
|
10772
10772
|
}
|
|
@@ -10779,7 +10779,7 @@ ${assistantMessage}
|
|
|
10779
10779
|
break;
|
|
10780
10780
|
}
|
|
10781
10781
|
case "tool": {
|
|
10782
|
-
throw new
|
|
10782
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
10783
10783
|
functionality: "tool messages"
|
|
10784
10784
|
});
|
|
10785
10785
|
}
|
|
@@ -10823,8 +10823,8 @@ function mapOpenAIFinishReason22(finishReason) {
|
|
|
10823
10823
|
return "unknown";
|
|
10824
10824
|
}
|
|
10825
10825
|
}
|
|
10826
|
-
var openaiCompletionResponseSchema2 =
|
|
10827
|
-
() =>
|
|
10826
|
+
var openaiCompletionResponseSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
10827
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
10828
10828
|
z4.z.object({
|
|
10829
10829
|
id: z4.z.string().nullish(),
|
|
10830
10830
|
created: z4.z.number().nullish(),
|
|
@@ -10848,8 +10848,8 @@ var openaiCompletionResponseSchema2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
10848
10848
|
})
|
|
10849
10849
|
)
|
|
10850
10850
|
);
|
|
10851
|
-
var openaiCompletionChunkSchema2 =
|
|
10852
|
-
() =>
|
|
10851
|
+
var openaiCompletionChunkSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
10852
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
10853
10853
|
z4.z.union([
|
|
10854
10854
|
z4.z.object({
|
|
10855
10855
|
id: z4.z.string().nullish(),
|
|
@@ -10877,8 +10877,8 @@ var openaiCompletionChunkSchema2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
10877
10877
|
])
|
|
10878
10878
|
)
|
|
10879
10879
|
);
|
|
10880
|
-
var openaiCompletionProviderOptions2 =
|
|
10881
|
-
() =>
|
|
10880
|
+
var openaiCompletionProviderOptions2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
10881
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
10882
10882
|
z4.z.object({
|
|
10883
10883
|
/**
|
|
10884
10884
|
Echo back the prompt in addition to the completion.
|
|
@@ -10953,12 +10953,12 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
10953
10953
|
}) {
|
|
10954
10954
|
const warnings = [];
|
|
10955
10955
|
const openaiOptions = {
|
|
10956
|
-
...await
|
|
10956
|
+
...await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
10957
10957
|
provider: "openai",
|
|
10958
10958
|
providerOptions,
|
|
10959
10959
|
schema: openaiCompletionProviderOptions2
|
|
10960
10960
|
}),
|
|
10961
|
-
...await
|
|
10961
|
+
...await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
10962
10962
|
provider: this.providerOptionsName,
|
|
10963
10963
|
providerOptions,
|
|
10964
10964
|
schema: openaiCompletionProviderOptions2
|
|
@@ -11014,15 +11014,15 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
11014
11014
|
responseHeaders,
|
|
11015
11015
|
value: response,
|
|
11016
11016
|
rawValue: rawResponse
|
|
11017
|
-
} = await
|
|
11017
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
11018
11018
|
url: this.config.url({
|
|
11019
11019
|
path: "/completions",
|
|
11020
11020
|
modelId: this.modelId
|
|
11021
11021
|
}),
|
|
11022
|
-
headers:
|
|
11022
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
11023
11023
|
body: args,
|
|
11024
11024
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
11025
|
-
successfulResponseHandler:
|
|
11025
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
11026
11026
|
openaiCompletionResponseSchema2
|
|
11027
11027
|
),
|
|
11028
11028
|
abortSignal: options.abortSignal,
|
|
@@ -11060,15 +11060,15 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
11060
11060
|
include_usage: true
|
|
11061
11061
|
}
|
|
11062
11062
|
};
|
|
11063
|
-
const { responseHeaders, value: response } = await
|
|
11063
|
+
const { responseHeaders, value: response } = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
11064
11064
|
url: this.config.url({
|
|
11065
11065
|
path: "/completions",
|
|
11066
11066
|
modelId: this.modelId
|
|
11067
11067
|
}),
|
|
11068
|
-
headers:
|
|
11068
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
11069
11069
|
body,
|
|
11070
11070
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
11071
|
-
successfulResponseHandler:
|
|
11071
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createEventSourceResponseHandler(
|
|
11072
11072
|
openaiCompletionChunkSchema2
|
|
11073
11073
|
),
|
|
11074
11074
|
abortSignal: options.abortSignal,
|
|
@@ -11149,8 +11149,8 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
11149
11149
|
};
|
|
11150
11150
|
}
|
|
11151
11151
|
};
|
|
11152
|
-
var openaiEmbeddingProviderOptions2 =
|
|
11153
|
-
() =>
|
|
11152
|
+
var openaiEmbeddingProviderOptions2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
11153
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11154
11154
|
z4.z.object({
|
|
11155
11155
|
/**
|
|
11156
11156
|
The number of dimensions the resulting output embeddings should have.
|
|
@@ -11165,8 +11165,8 @@ var openaiEmbeddingProviderOptions2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
11165
11165
|
})
|
|
11166
11166
|
)
|
|
11167
11167
|
);
|
|
11168
|
-
var openaiTextEmbeddingResponseSchema2 =
|
|
11169
|
-
() =>
|
|
11168
|
+
var openaiTextEmbeddingResponseSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
11169
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11170
11170
|
z4.z.object({
|
|
11171
11171
|
data: z4.z.array(z4.z.object({ embedding: z4.z.array(z4.z.number()) })),
|
|
11172
11172
|
usage: z4.z.object({ prompt_tokens: z4.z.number() }).nullish()
|
|
@@ -11192,14 +11192,14 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11192
11192
|
}) {
|
|
11193
11193
|
var _a2;
|
|
11194
11194
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
11195
|
-
throw new
|
|
11195
|
+
throw new chunkL24YAW4G_cjs.TooManyEmbeddingValuesForCallError({
|
|
11196
11196
|
provider: this.provider,
|
|
11197
11197
|
modelId: this.modelId,
|
|
11198
11198
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
11199
11199
|
values
|
|
11200
11200
|
});
|
|
11201
11201
|
}
|
|
11202
|
-
const openaiOptions = (_a2 = await
|
|
11202
|
+
const openaiOptions = (_a2 = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
11203
11203
|
provider: "openai",
|
|
11204
11204
|
providerOptions,
|
|
11205
11205
|
schema: openaiEmbeddingProviderOptions2
|
|
@@ -11208,12 +11208,12 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11208
11208
|
responseHeaders,
|
|
11209
11209
|
value: response,
|
|
11210
11210
|
rawValue
|
|
11211
|
-
} = await
|
|
11211
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
11212
11212
|
url: this.config.url({
|
|
11213
11213
|
path: "/embeddings",
|
|
11214
11214
|
modelId: this.modelId
|
|
11215
11215
|
}),
|
|
11216
|
-
headers:
|
|
11216
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), headers),
|
|
11217
11217
|
body: {
|
|
11218
11218
|
model: this.modelId,
|
|
11219
11219
|
input: values,
|
|
@@ -11222,7 +11222,7 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11222
11222
|
user: openaiOptions.user
|
|
11223
11223
|
},
|
|
11224
11224
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
11225
|
-
successfulResponseHandler:
|
|
11225
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
11226
11226
|
openaiTextEmbeddingResponseSchema2
|
|
11227
11227
|
),
|
|
11228
11228
|
abortSignal,
|
|
@@ -11235,8 +11235,8 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11235
11235
|
};
|
|
11236
11236
|
}
|
|
11237
11237
|
};
|
|
11238
|
-
var openaiImageResponseSchema2 =
|
|
11239
|
-
() =>
|
|
11238
|
+
var openaiImageResponseSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
11239
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11240
11240
|
z4.z.object({
|
|
11241
11241
|
created: z4.z.number().nullish(),
|
|
11242
11242
|
data: z4.z.array(
|
|
@@ -11309,12 +11309,12 @@ var OpenAIImageModel2 = class {
|
|
|
11309
11309
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
11310
11310
|
}
|
|
11311
11311
|
const currentDate = (_c = (_b2 = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b2.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
|
|
11312
|
-
const { value: response, responseHeaders } = await
|
|
11312
|
+
const { value: response, responseHeaders } = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
11313
11313
|
url: this.config.url({
|
|
11314
11314
|
path: "/images/generations",
|
|
11315
11315
|
modelId: this.modelId
|
|
11316
11316
|
}),
|
|
11317
|
-
headers:
|
|
11317
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), headers),
|
|
11318
11318
|
body: {
|
|
11319
11319
|
model: this.modelId,
|
|
11320
11320
|
prompt,
|
|
@@ -11324,7 +11324,7 @@ var OpenAIImageModel2 = class {
|
|
|
11324
11324
|
...!hasDefaultResponseFormat2.has(this.modelId) ? { response_format: "b64_json" } : {}
|
|
11325
11325
|
},
|
|
11326
11326
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
11327
|
-
successfulResponseHandler:
|
|
11327
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
11328
11328
|
openaiImageResponseSchema2
|
|
11329
11329
|
),
|
|
11330
11330
|
abortSignal,
|
|
@@ -11386,16 +11386,16 @@ function distributeTokenDetails2(usage, index, total) {
|
|
|
11386
11386
|
}
|
|
11387
11387
|
return result;
|
|
11388
11388
|
}
|
|
11389
|
-
var codeInterpreterInputSchema2 =
|
|
11390
|
-
() =>
|
|
11389
|
+
var codeInterpreterInputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11390
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11391
11391
|
z4.z.object({
|
|
11392
11392
|
code: z4.z.string().nullish(),
|
|
11393
11393
|
containerId: z4.z.string()
|
|
11394
11394
|
})
|
|
11395
11395
|
)
|
|
11396
11396
|
);
|
|
11397
|
-
var codeInterpreterOutputSchema2 =
|
|
11398
|
-
() =>
|
|
11397
|
+
var codeInterpreterOutputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11398
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11399
11399
|
z4.z.object({
|
|
11400
11400
|
outputs: z4.z.array(
|
|
11401
11401
|
z4.z.discriminatedUnion("type", [
|
|
@@ -11406,8 +11406,8 @@ var codeInterpreterOutputSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11406
11406
|
})
|
|
11407
11407
|
)
|
|
11408
11408
|
);
|
|
11409
|
-
var codeInterpreterArgsSchema2 =
|
|
11410
|
-
() =>
|
|
11409
|
+
var codeInterpreterArgsSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11410
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11411
11411
|
z4.z.object({
|
|
11412
11412
|
container: z4.z.union([
|
|
11413
11413
|
z4.z.string(),
|
|
@@ -11418,7 +11418,7 @@ var codeInterpreterArgsSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11418
11418
|
})
|
|
11419
11419
|
)
|
|
11420
11420
|
);
|
|
11421
|
-
var codeInterpreterToolFactory2 =
|
|
11421
|
+
var codeInterpreterToolFactory2 = chunkL24YAW4G_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11422
11422
|
id: "openai.code_interpreter",
|
|
11423
11423
|
name: "code_interpreter",
|
|
11424
11424
|
inputSchema: codeInterpreterInputSchema2,
|
|
@@ -11438,8 +11438,8 @@ var compoundFilterSchema2 = z4.z.object({
|
|
|
11438
11438
|
z4.z.union([comparisonFilterSchema2, z4.z.lazy(() => compoundFilterSchema2)])
|
|
11439
11439
|
)
|
|
11440
11440
|
});
|
|
11441
|
-
var fileSearchArgsSchema3 =
|
|
11442
|
-
() =>
|
|
11441
|
+
var fileSearchArgsSchema3 = chunkL24YAW4G_cjs.lazySchema(
|
|
11442
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11443
11443
|
z4.z.object({
|
|
11444
11444
|
vectorStoreIds: z4.z.array(z4.z.string()),
|
|
11445
11445
|
maxNumResults: z4.z.number().optional(),
|
|
@@ -11451,8 +11451,8 @@ var fileSearchArgsSchema3 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11451
11451
|
})
|
|
11452
11452
|
)
|
|
11453
11453
|
);
|
|
11454
|
-
var fileSearchOutputSchema2 =
|
|
11455
|
-
() =>
|
|
11454
|
+
var fileSearchOutputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11455
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11456
11456
|
z4.z.object({
|
|
11457
11457
|
queries: z4.z.array(z4.z.string()),
|
|
11458
11458
|
results: z4.z.array(
|
|
@@ -11467,14 +11467,14 @@ var fileSearchOutputSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11467
11467
|
})
|
|
11468
11468
|
)
|
|
11469
11469
|
);
|
|
11470
|
-
var fileSearch3 =
|
|
11470
|
+
var fileSearch3 = chunkL24YAW4G_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11471
11471
|
id: "openai.file_search",
|
|
11472
11472
|
name: "file_search",
|
|
11473
11473
|
inputSchema: z4.z.object({}),
|
|
11474
11474
|
outputSchema: fileSearchOutputSchema2
|
|
11475
11475
|
});
|
|
11476
|
-
var imageGenerationArgsSchema2 =
|
|
11477
|
-
() =>
|
|
11476
|
+
var imageGenerationArgsSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11477
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11478
11478
|
z4.z.object({
|
|
11479
11479
|
background: z4.z.enum(["auto", "opaque", "transparent"]).optional(),
|
|
11480
11480
|
inputFidelity: z4.z.enum(["low", "high"]).optional(),
|
|
@@ -11492,11 +11492,11 @@ var imageGenerationArgsSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11492
11492
|
}).strict()
|
|
11493
11493
|
)
|
|
11494
11494
|
);
|
|
11495
|
-
var imageGenerationInputSchema2 =
|
|
11496
|
-
var imageGenerationOutputSchema2 =
|
|
11497
|
-
() =>
|
|
11495
|
+
var imageGenerationInputSchema2 = chunkL24YAW4G_cjs.lazySchema(() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({})));
|
|
11496
|
+
var imageGenerationOutputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11497
|
+
() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({ result: z4.z.string() }))
|
|
11498
11498
|
);
|
|
11499
|
-
var imageGenerationToolFactory2 =
|
|
11499
|
+
var imageGenerationToolFactory2 = chunkL24YAW4G_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11500
11500
|
id: "openai.image_generation",
|
|
11501
11501
|
name: "image_generation",
|
|
11502
11502
|
inputSchema: imageGenerationInputSchema2,
|
|
@@ -11505,8 +11505,8 @@ var imageGenerationToolFactory2 = chunkQ5JACXBM_cjs.createProviderDefinedToolFac
|
|
|
11505
11505
|
var imageGeneration2 = (args = {}) => {
|
|
11506
11506
|
return imageGenerationToolFactory2(args);
|
|
11507
11507
|
};
|
|
11508
|
-
var localShellInputSchema2 =
|
|
11509
|
-
() =>
|
|
11508
|
+
var localShellInputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11509
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11510
11510
|
z4.z.object({
|
|
11511
11511
|
action: z4.z.object({
|
|
11512
11512
|
type: z4.z.literal("exec"),
|
|
@@ -11519,17 +11519,17 @@ var localShellInputSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11519
11519
|
})
|
|
11520
11520
|
)
|
|
11521
11521
|
);
|
|
11522
|
-
var localShellOutputSchema2 =
|
|
11523
|
-
() =>
|
|
11522
|
+
var localShellOutputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11523
|
+
() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({ output: z4.z.string() }))
|
|
11524
11524
|
);
|
|
11525
|
-
var localShell2 =
|
|
11525
|
+
var localShell2 = chunkL24YAW4G_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11526
11526
|
id: "openai.local_shell",
|
|
11527
11527
|
name: "local_shell",
|
|
11528
11528
|
inputSchema: localShellInputSchema2,
|
|
11529
11529
|
outputSchema: localShellOutputSchema2
|
|
11530
11530
|
});
|
|
11531
|
-
var webSearchArgsSchema2 =
|
|
11532
|
-
() =>
|
|
11531
|
+
var webSearchArgsSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11532
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11533
11533
|
z4.z.object({
|
|
11534
11534
|
externalWebAccess: z4.z.boolean().optional(),
|
|
11535
11535
|
filters: z4.z.object({ allowedDomains: z4.z.array(z4.z.string()).optional() }).optional(),
|
|
@@ -11544,9 +11544,9 @@ var webSearchArgsSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11544
11544
|
})
|
|
11545
11545
|
)
|
|
11546
11546
|
);
|
|
11547
|
-
var webSearchInputSchema2 =
|
|
11548
|
-
var webSearchOutputSchema2 =
|
|
11549
|
-
() =>
|
|
11547
|
+
var webSearchInputSchema2 = chunkL24YAW4G_cjs.lazySchema(() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({})));
|
|
11548
|
+
var webSearchOutputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11549
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11550
11550
|
z4.z.object({
|
|
11551
11551
|
action: z4.z.discriminatedUnion("type", [
|
|
11552
11552
|
z4.z.object({
|
|
@@ -11572,15 +11572,15 @@ var webSearchOutputSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11572
11572
|
})
|
|
11573
11573
|
)
|
|
11574
11574
|
);
|
|
11575
|
-
var webSearchToolFactory2 =
|
|
11575
|
+
var webSearchToolFactory2 = chunkL24YAW4G_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11576
11576
|
id: "openai.web_search",
|
|
11577
11577
|
name: "web_search",
|
|
11578
11578
|
inputSchema: webSearchInputSchema2,
|
|
11579
11579
|
outputSchema: webSearchOutputSchema2
|
|
11580
11580
|
});
|
|
11581
11581
|
var webSearch = (args = {}) => webSearchToolFactory2(args);
|
|
11582
|
-
var webSearchPreviewArgsSchema2 =
|
|
11583
|
-
() =>
|
|
11582
|
+
var webSearchPreviewArgsSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11583
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11584
11584
|
z4.z.object({
|
|
11585
11585
|
searchContextSize: z4.z.enum(["low", "medium", "high"]).optional(),
|
|
11586
11586
|
userLocation: z4.z.object({
|
|
@@ -11593,11 +11593,11 @@ var webSearchPreviewArgsSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11593
11593
|
})
|
|
11594
11594
|
)
|
|
11595
11595
|
);
|
|
11596
|
-
var webSearchPreviewInputSchema2 =
|
|
11597
|
-
() =>
|
|
11596
|
+
var webSearchPreviewInputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11597
|
+
() => chunkL24YAW4G_cjs.zodSchema(z4.z.object({}))
|
|
11598
11598
|
);
|
|
11599
|
-
var webSearchPreviewOutputSchema2 =
|
|
11600
|
-
() =>
|
|
11599
|
+
var webSearchPreviewOutputSchema2 = chunkL24YAW4G_cjs.lazySchema(
|
|
11600
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
11601
11601
|
z4.z.object({
|
|
11602
11602
|
action: z4.z.discriminatedUnion("type", [
|
|
11603
11603
|
z4.z.object({
|
|
@@ -11617,7 +11617,7 @@ var webSearchPreviewOutputSchema2 = chunkQ5JACXBM_cjs.lazySchema(
|
|
|
11617
11617
|
})
|
|
11618
11618
|
)
|
|
11619
11619
|
);
|
|
11620
|
-
var webSearchPreview2 =
|
|
11620
|
+
var webSearchPreview2 = chunkL24YAW4G_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11621
11621
|
id: "openai.web_search_preview",
|
|
11622
11622
|
name: "web_search_preview",
|
|
11623
11623
|
inputSchema: webSearchPreviewInputSchema2,
|
|
@@ -11751,7 +11751,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11751
11751
|
return {
|
|
11752
11752
|
type: "input_image",
|
|
11753
11753
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId2(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
11754
|
-
image_url: `data:${mediaType};base64,${
|
|
11754
|
+
image_url: `data:${mediaType};base64,${chunkL24YAW4G_cjs.convertToBase64(part.data)}`
|
|
11755
11755
|
},
|
|
11756
11756
|
detail: (_b22 = (_a22 = part.providerOptions) == null ? void 0 : _a22.openai) == null ? void 0 : _b22.imageDetail
|
|
11757
11757
|
};
|
|
@@ -11766,11 +11766,11 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11766
11766
|
type: "input_file",
|
|
11767
11767
|
...typeof part.data === "string" && isFileId2(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
11768
11768
|
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
11769
|
-
file_data: `data:application/pdf;base64,${
|
|
11769
|
+
file_data: `data:application/pdf;base64,${chunkL24YAW4G_cjs.convertToBase64(part.data)}`
|
|
11770
11770
|
}
|
|
11771
11771
|
};
|
|
11772
11772
|
} else {
|
|
11773
|
-
throw new
|
|
11773
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
11774
11774
|
functionality: `file part media type ${part.mediaType}`
|
|
11775
11775
|
});
|
|
11776
11776
|
}
|
|
@@ -11809,7 +11809,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11809
11809
|
break;
|
|
11810
11810
|
}
|
|
11811
11811
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
11812
|
-
const parsedInput = await
|
|
11812
|
+
const parsedInput = await chunkL24YAW4G_cjs.validateTypes({
|
|
11813
11813
|
value: part.input,
|
|
11814
11814
|
schema: localShellInputSchema2
|
|
11815
11815
|
});
|
|
@@ -11850,7 +11850,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11850
11850
|
break;
|
|
11851
11851
|
}
|
|
11852
11852
|
case "reasoning": {
|
|
11853
|
-
const providerOptions = await
|
|
11853
|
+
const providerOptions = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
11854
11854
|
provider: "openai",
|
|
11855
11855
|
providerOptions: part.providerOptions,
|
|
11856
11856
|
schema: openaiResponsesReasoningProviderOptionsSchema2
|
|
@@ -11911,7 +11911,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11911
11911
|
for (const part of content) {
|
|
11912
11912
|
const output = part.output;
|
|
11913
11913
|
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
11914
|
-
const parsedOutput = await
|
|
11914
|
+
const parsedOutput = await chunkL24YAW4G_cjs.validateTypes({
|
|
11915
11915
|
value: output.value,
|
|
11916
11916
|
schema: localShellOutputSchema2
|
|
11917
11917
|
});
|
|
@@ -11999,8 +11999,8 @@ function mapOpenAIResponseFinishReason2({
|
|
|
11999
11999
|
return hasFunctionCall ? "tool-calls" : "unknown";
|
|
12000
12000
|
}
|
|
12001
12001
|
}
|
|
12002
|
-
var openaiResponsesChunkSchema2 =
|
|
12003
|
-
() =>
|
|
12002
|
+
var openaiResponsesChunkSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
12003
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
12004
12004
|
z4.z.union([
|
|
12005
12005
|
z4.z.object({
|
|
12006
12006
|
type: z4.z.literal("response.output_text.delta"),
|
|
@@ -12273,8 +12273,8 @@ var openaiResponsesChunkSchema2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
12273
12273
|
])
|
|
12274
12274
|
)
|
|
12275
12275
|
);
|
|
12276
|
-
var openaiResponsesResponseSchema2 =
|
|
12277
|
-
() =>
|
|
12276
|
+
var openaiResponsesResponseSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
12277
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
12278
12278
|
z4.z.object({
|
|
12279
12279
|
id: z4.z.string().optional(),
|
|
12280
12280
|
created_at: z4.z.number().optional(),
|
|
@@ -12458,8 +12458,8 @@ var openaiResponsesResponseSchema2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
12458
12458
|
)
|
|
12459
12459
|
);
|
|
12460
12460
|
var TOP_LOGPROBS_MAX2 = 20;
|
|
12461
|
-
var openaiResponsesProviderOptionsSchema2 =
|
|
12462
|
-
() =>
|
|
12461
|
+
var openaiResponsesProviderOptionsSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
12462
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
12463
12463
|
z4.z.object({
|
|
12464
12464
|
conversation: z4.z.string().nullish(),
|
|
12465
12465
|
include: z4.z.array(
|
|
@@ -12550,7 +12550,7 @@ async function prepareResponsesTools2({
|
|
|
12550
12550
|
case "provider-defined": {
|
|
12551
12551
|
switch (tool2.id) {
|
|
12552
12552
|
case "openai.file_search": {
|
|
12553
|
-
const args = await
|
|
12553
|
+
const args = await chunkL24YAW4G_cjs.validateTypes({
|
|
12554
12554
|
value: tool2.args,
|
|
12555
12555
|
schema: fileSearchArgsSchema3
|
|
12556
12556
|
});
|
|
@@ -12573,7 +12573,7 @@ async function prepareResponsesTools2({
|
|
|
12573
12573
|
break;
|
|
12574
12574
|
}
|
|
12575
12575
|
case "openai.web_search_preview": {
|
|
12576
|
-
const args = await
|
|
12576
|
+
const args = await chunkL24YAW4G_cjs.validateTypes({
|
|
12577
12577
|
value: tool2.args,
|
|
12578
12578
|
schema: webSearchPreviewArgsSchema2
|
|
12579
12579
|
});
|
|
@@ -12585,7 +12585,7 @@ async function prepareResponsesTools2({
|
|
|
12585
12585
|
break;
|
|
12586
12586
|
}
|
|
12587
12587
|
case "openai.web_search": {
|
|
12588
|
-
const args = await
|
|
12588
|
+
const args = await chunkL24YAW4G_cjs.validateTypes({
|
|
12589
12589
|
value: tool2.args,
|
|
12590
12590
|
schema: webSearchArgsSchema2
|
|
12591
12591
|
});
|
|
@@ -12599,7 +12599,7 @@ async function prepareResponsesTools2({
|
|
|
12599
12599
|
break;
|
|
12600
12600
|
}
|
|
12601
12601
|
case "openai.code_interpreter": {
|
|
12602
|
-
const args = await
|
|
12602
|
+
const args = await chunkL24YAW4G_cjs.validateTypes({
|
|
12603
12603
|
value: tool2.args,
|
|
12604
12604
|
schema: codeInterpreterArgsSchema2
|
|
12605
12605
|
});
|
|
@@ -12610,7 +12610,7 @@ async function prepareResponsesTools2({
|
|
|
12610
12610
|
break;
|
|
12611
12611
|
}
|
|
12612
12612
|
case "openai.image_generation": {
|
|
12613
|
-
const args = await
|
|
12613
|
+
const args = await chunkL24YAW4G_cjs.validateTypes({
|
|
12614
12614
|
value: tool2.args,
|
|
12615
12615
|
schema: imageGenerationArgsSchema2
|
|
12616
12616
|
});
|
|
@@ -12656,7 +12656,7 @@ async function prepareResponsesTools2({
|
|
|
12656
12656
|
};
|
|
12657
12657
|
default: {
|
|
12658
12658
|
const _exhaustiveCheck = type;
|
|
12659
|
-
throw new
|
|
12659
|
+
throw new chunkL24YAW4G_cjs.UnsupportedFunctionalityError({
|
|
12660
12660
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
12661
12661
|
});
|
|
12662
12662
|
}
|
|
@@ -12714,7 +12714,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12714
12714
|
if (stopSequences != null) {
|
|
12715
12715
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
12716
12716
|
}
|
|
12717
|
-
const openaiOptions = await
|
|
12717
|
+
const openaiOptions = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
12718
12718
|
provider: "openai",
|
|
12719
12719
|
providerOptions,
|
|
12720
12720
|
schema: openaiResponsesProviderOptionsSchema2
|
|
@@ -12902,19 +12902,19 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12902
12902
|
responseHeaders,
|
|
12903
12903
|
value: response,
|
|
12904
12904
|
rawValue: rawResponse
|
|
12905
|
-
} = await
|
|
12905
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
12906
12906
|
url,
|
|
12907
|
-
headers:
|
|
12907
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
12908
12908
|
body,
|
|
12909
12909
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
12910
|
-
successfulResponseHandler:
|
|
12910
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
12911
12911
|
openaiResponsesResponseSchema2
|
|
12912
12912
|
),
|
|
12913
12913
|
abortSignal: options.abortSignal,
|
|
12914
12914
|
fetch: this.config.fetch
|
|
12915
12915
|
});
|
|
12916
12916
|
if (response.error) {
|
|
12917
|
-
throw new
|
|
12917
|
+
throw new chunkL24YAW4G_cjs.APICallError({
|
|
12918
12918
|
message: response.error.message,
|
|
12919
12919
|
url,
|
|
12920
12920
|
requestBodyValues: body,
|
|
@@ -13002,7 +13002,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13002
13002
|
content.push({
|
|
13003
13003
|
type: "source",
|
|
13004
13004
|
sourceType: "url",
|
|
13005
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f :
|
|
13005
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : chunkL24YAW4G_cjs.generateId(),
|
|
13006
13006
|
url: annotation.url,
|
|
13007
13007
|
title: annotation.title
|
|
13008
13008
|
});
|
|
@@ -13010,7 +13010,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13010
13010
|
content.push({
|
|
13011
13011
|
type: "source",
|
|
13012
13012
|
sourceType: "document",
|
|
13013
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i :
|
|
13013
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : chunkL24YAW4G_cjs.generateId(),
|
|
13014
13014
|
mediaType: "text/plain",
|
|
13015
13015
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
13016
13016
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
@@ -13026,7 +13026,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13026
13026
|
content.push({
|
|
13027
13027
|
type: "source",
|
|
13028
13028
|
sourceType: "document",
|
|
13029
|
-
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o :
|
|
13029
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : chunkL24YAW4G_cjs.generateId(),
|
|
13030
13030
|
mediaType: "text/plain",
|
|
13031
13031
|
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
13032
13032
|
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
@@ -13042,7 +13042,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13042
13042
|
content.push({
|
|
13043
13043
|
type: "source",
|
|
13044
13044
|
sourceType: "document",
|
|
13045
|
-
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u :
|
|
13045
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : chunkL24YAW4G_cjs.generateId(),
|
|
13046
13046
|
mediaType: "application/octet-stream",
|
|
13047
13047
|
title: annotation.file_id,
|
|
13048
13048
|
filename: annotation.file_id,
|
|
@@ -13204,18 +13204,18 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13204
13204
|
webSearchToolName,
|
|
13205
13205
|
store
|
|
13206
13206
|
} = await this.getArgs(options);
|
|
13207
|
-
const { responseHeaders, value: response } = await
|
|
13207
|
+
const { responseHeaders, value: response } = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
13208
13208
|
url: this.config.url({
|
|
13209
13209
|
path: "/responses",
|
|
13210
13210
|
modelId: this.modelId
|
|
13211
13211
|
}),
|
|
13212
|
-
headers:
|
|
13212
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
13213
13213
|
body: {
|
|
13214
13214
|
...body,
|
|
13215
13215
|
stream: true
|
|
13216
13216
|
},
|
|
13217
13217
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
13218
|
-
successfulResponseHandler:
|
|
13218
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createEventSourceResponseHandler(
|
|
13219
13219
|
openaiResponsesChunkSchema2
|
|
13220
13220
|
),
|
|
13221
13221
|
abortSignal: options.abortSignal,
|
|
@@ -13643,7 +13643,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13643
13643
|
controller.enqueue({
|
|
13644
13644
|
type: "source",
|
|
13645
13645
|
sourceType: "url",
|
|
13646
|
-
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r :
|
|
13646
|
+
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : chunkL24YAW4G_cjs.generateId(),
|
|
13647
13647
|
url: value.annotation.url,
|
|
13648
13648
|
title: value.annotation.title
|
|
13649
13649
|
});
|
|
@@ -13651,7 +13651,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13651
13651
|
controller.enqueue({
|
|
13652
13652
|
type: "source",
|
|
13653
13653
|
sourceType: "document",
|
|
13654
|
-
id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u :
|
|
13654
|
+
id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : chunkL24YAW4G_cjs.generateId(),
|
|
13655
13655
|
mediaType: "text/plain",
|
|
13656
13656
|
title: (_w = (_v = value.annotation.quote) != null ? _v : value.annotation.filename) != null ? _w : "Document",
|
|
13657
13657
|
filename: (_x = value.annotation.filename) != null ? _x : value.annotation.file_id,
|
|
@@ -13748,8 +13748,8 @@ function mapWebSearchOutput2(action) {
|
|
|
13748
13748
|
};
|
|
13749
13749
|
}
|
|
13750
13750
|
}
|
|
13751
|
-
var openaiSpeechProviderOptionsSchema2 =
|
|
13752
|
-
() =>
|
|
13751
|
+
var openaiSpeechProviderOptionsSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
13752
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
13753
13753
|
z4.z.object({
|
|
13754
13754
|
instructions: z4.z.string().nullish(),
|
|
13755
13755
|
speed: z4.z.number().min(0.25).max(4).default(1).nullish()
|
|
@@ -13775,7 +13775,7 @@ var OpenAISpeechModel2 = class {
|
|
|
13775
13775
|
providerOptions
|
|
13776
13776
|
}) {
|
|
13777
13777
|
const warnings = [];
|
|
13778
|
-
const openAIOptions = await
|
|
13778
|
+
const openAIOptions = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
13779
13779
|
provider: "openai",
|
|
13780
13780
|
providerOptions,
|
|
13781
13781
|
schema: openaiSpeechProviderOptionsSchema2
|
|
@@ -13828,15 +13828,15 @@ var OpenAISpeechModel2 = class {
|
|
|
13828
13828
|
value: audio,
|
|
13829
13829
|
responseHeaders,
|
|
13830
13830
|
rawValue: rawResponse
|
|
13831
|
-
} = await
|
|
13831
|
+
} = await chunkL24YAW4G_cjs.postJsonToApi({
|
|
13832
13832
|
url: this.config.url({
|
|
13833
13833
|
path: "/audio/speech",
|
|
13834
13834
|
modelId: this.modelId
|
|
13835
13835
|
}),
|
|
13836
|
-
headers:
|
|
13836
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
13837
13837
|
body: requestBody,
|
|
13838
13838
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
13839
|
-
successfulResponseHandler:
|
|
13839
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createBinaryResponseHandler(),
|
|
13840
13840
|
abortSignal: options.abortSignal,
|
|
13841
13841
|
fetch: this.config.fetch
|
|
13842
13842
|
});
|
|
@@ -13855,8 +13855,8 @@ var OpenAISpeechModel2 = class {
|
|
|
13855
13855
|
};
|
|
13856
13856
|
}
|
|
13857
13857
|
};
|
|
13858
|
-
var openaiTranscriptionResponseSchema2 =
|
|
13859
|
-
() =>
|
|
13858
|
+
var openaiTranscriptionResponseSchema2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
13859
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
13860
13860
|
z4.z.object({
|
|
13861
13861
|
text: z4.z.string(),
|
|
13862
13862
|
language: z4.z.string().nullish(),
|
|
@@ -13885,8 +13885,8 @@ var openaiTranscriptionResponseSchema2 = chunkQ5JACXBM_cjs.lazyValidator(
|
|
|
13885
13885
|
})
|
|
13886
13886
|
)
|
|
13887
13887
|
);
|
|
13888
|
-
var openAITranscriptionProviderOptions2 =
|
|
13889
|
-
() =>
|
|
13888
|
+
var openAITranscriptionProviderOptions2 = chunkL24YAW4G_cjs.lazyValidator(
|
|
13889
|
+
() => chunkL24YAW4G_cjs.zodSchema(
|
|
13890
13890
|
z4.z.object({
|
|
13891
13891
|
/**
|
|
13892
13892
|
* Additional information to include in the transcription response.
|
|
@@ -13987,15 +13987,15 @@ var OpenAITranscriptionModel2 = class {
|
|
|
13987
13987
|
providerOptions
|
|
13988
13988
|
}) {
|
|
13989
13989
|
const warnings = [];
|
|
13990
|
-
const openAIOptions = await
|
|
13990
|
+
const openAIOptions = await chunkL24YAW4G_cjs.parseProviderOptions({
|
|
13991
13991
|
provider: "openai",
|
|
13992
13992
|
providerOptions,
|
|
13993
13993
|
schema: openAITranscriptionProviderOptions2
|
|
13994
13994
|
});
|
|
13995
13995
|
const formData = new FormData();
|
|
13996
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([
|
|
13996
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([chunkL24YAW4G_cjs.convertBase64ToUint8Array(audio)]);
|
|
13997
13997
|
formData.append("model", this.modelId);
|
|
13998
|
-
const fileExtension =
|
|
13998
|
+
const fileExtension = chunkL24YAW4G_cjs.mediaTypeToExtension(mediaType);
|
|
13999
13999
|
formData.append(
|
|
14000
14000
|
"file",
|
|
14001
14001
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -14040,15 +14040,15 @@ var OpenAITranscriptionModel2 = class {
|
|
|
14040
14040
|
value: response,
|
|
14041
14041
|
responseHeaders,
|
|
14042
14042
|
rawValue: rawResponse
|
|
14043
|
-
} = await
|
|
14043
|
+
} = await chunkL24YAW4G_cjs.postFormDataToApi({
|
|
14044
14044
|
url: this.config.url({
|
|
14045
14045
|
path: "/audio/transcriptions",
|
|
14046
14046
|
modelId: this.modelId
|
|
14047
14047
|
}),
|
|
14048
|
-
headers:
|
|
14048
|
+
headers: chunkL24YAW4G_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
14049
14049
|
formData,
|
|
14050
14050
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
14051
|
-
successfulResponseHandler:
|
|
14051
|
+
successfulResponseHandler: chunkL24YAW4G_cjs.createJsonResponseHandler(
|
|
14052
14052
|
openaiTranscriptionResponseSchema2
|
|
14053
14053
|
),
|
|
14054
14054
|
abortSignal: options.abortSignal,
|
|
@@ -14081,16 +14081,16 @@ var OpenAITranscriptionModel2 = class {
|
|
|
14081
14081
|
var VERSION4 = "2.0.102" ;
|
|
14082
14082
|
function createOpenAI2(options = {}) {
|
|
14083
14083
|
var _a2, _b2;
|
|
14084
|
-
const baseURL = (_a2 =
|
|
14085
|
-
|
|
14084
|
+
const baseURL = (_a2 = chunkL24YAW4G_cjs.withoutTrailingSlash(
|
|
14085
|
+
chunkL24YAW4G_cjs.loadOptionalSetting({
|
|
14086
14086
|
settingValue: options.baseURL,
|
|
14087
14087
|
environmentVariableName: "OPENAI_BASE_URL"
|
|
14088
14088
|
})
|
|
14089
14089
|
)) != null ? _a2 : "https://api.openai.com/v1";
|
|
14090
14090
|
const providerName = (_b2 = options.name) != null ? _b2 : "openai";
|
|
14091
|
-
const getHeaders = () =>
|
|
14091
|
+
const getHeaders = () => chunkL24YAW4G_cjs.withUserAgentSuffix(
|
|
14092
14092
|
{
|
|
14093
|
-
Authorization: `Bearer ${
|
|
14093
|
+
Authorization: `Bearer ${chunkL24YAW4G_cjs.loadApiKey({
|
|
14094
14094
|
apiKey: options.apiKey,
|
|
14095
14095
|
environmentVariableName: "OPENAI_API_KEY",
|
|
14096
14096
|
description: "OpenAI"
|
|
@@ -14250,14 +14250,14 @@ var ModelRouterEmbeddingModel = class {
|
|
|
14250
14250
|
this.modelId = normalizedConfig.modelId;
|
|
14251
14251
|
if (normalizedConfig.url) {
|
|
14252
14252
|
const apiKey = normalizedConfig.apiKey || "";
|
|
14253
|
-
this.providerModel =
|
|
14253
|
+
this.providerModel = chunkL24YAW4G_cjs.createOpenAICompatible({
|
|
14254
14254
|
name: normalizedConfig.providerId,
|
|
14255
14255
|
apiKey,
|
|
14256
14256
|
baseURL: normalizedConfig.url,
|
|
14257
14257
|
headers: normalizedConfig.headers
|
|
14258
14258
|
}).textEmbeddingModel(normalizedConfig.modelId);
|
|
14259
14259
|
} else {
|
|
14260
|
-
const registry =
|
|
14260
|
+
const registry = chunkIIV77JRY_cjs.GatewayRegistry.getInstance();
|
|
14261
14261
|
const providerConfig = registry.getProviderConfig(normalizedConfig.providerId);
|
|
14262
14262
|
if (!providerConfig) {
|
|
14263
14263
|
throw new Error(`Unknown provider: ${normalizedConfig.providerId}`);
|
|
@@ -14290,7 +14290,7 @@ var ModelRouterEmbeddingModel = class {
|
|
|
14290
14290
|
if (!providerConfig.url) {
|
|
14291
14291
|
throw new Error(`Provider ${normalizedConfig.providerId} does not have a URL configured`);
|
|
14292
14292
|
}
|
|
14293
|
-
this.providerModel =
|
|
14293
|
+
this.providerModel = chunkL24YAW4G_cjs.createOpenAICompatible({
|
|
14294
14294
|
name: normalizedConfig.providerId,
|
|
14295
14295
|
apiKey,
|
|
14296
14296
|
baseURL: providerConfig.url
|
|
@@ -14317,5 +14317,5 @@ exports.ModelRouterEmbeddingModel = ModelRouterEmbeddingModel;
|
|
|
14317
14317
|
exports.ModelRouterLanguageModel = ModelRouterLanguageModel;
|
|
14318
14318
|
exports.defaultGateways = defaultGateways;
|
|
14319
14319
|
exports.resolveModelConfig = resolveModelConfig;
|
|
14320
|
-
//# sourceMappingURL=chunk-
|
|
14321
|
-
//# sourceMappingURL=chunk-
|
|
14320
|
+
//# sourceMappingURL=chunk-BQN2KODN.cjs.map
|
|
14321
|
+
//# sourceMappingURL=chunk-BQN2KODN.cjs.map
|