@mastra/core 1.26.0-alpha.4 → 1.26.0-alpha.5
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 +6 -0
- package/dist/agent/agent.d.ts.map +1 -1
- 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-DMBNRISI.cjs → chunk-2ZA7GO5N.cjs} +9 -9
- package/dist/{chunk-DMBNRISI.cjs.map → chunk-2ZA7GO5N.cjs.map} +1 -1
- package/dist/{chunk-5VOSWZCR.cjs → chunk-3PRW3IRQ.cjs} +5 -5
- package/dist/{chunk-5VOSWZCR.cjs.map → chunk-3PRW3IRQ.cjs.map} +1 -1
- package/dist/{chunk-OQXJBGMN.cjs → chunk-5WHRYMKF.cjs} +6 -6
- package/dist/{chunk-OQXJBGMN.cjs.map → chunk-5WHRYMKF.cjs.map} +1 -1
- package/dist/{chunk-26LM3QQG.js → chunk-AJBH645B.js} +4 -4
- package/dist/{chunk-26LM3QQG.js.map → chunk-AJBH645B.js.map} +1 -1
- package/dist/{chunk-ZYKGDZFW.cjs → chunk-ANNI34X7.cjs} +17 -14
- package/dist/chunk-ANNI34X7.cjs.map +1 -0
- package/dist/{chunk-IDVPZFDE.cjs → chunk-COER2756.cjs} +17 -17
- package/dist/{chunk-IDVPZFDE.cjs.map → chunk-COER2756.cjs.map} +1 -1
- package/dist/{chunk-7G3LGDEP.js → chunk-FCD77VJW.js} +3 -3
- package/dist/{chunk-7G3LGDEP.js.map → chunk-FCD77VJW.js.map} +1 -1
- package/dist/{chunk-QX4DMINV.cjs → chunk-GNOSEGOW.cjs} +292 -292
- package/dist/{chunk-QX4DMINV.cjs.map → chunk-GNOSEGOW.cjs.map} +1 -1
- package/dist/{chunk-5TD3NIQP.cjs → chunk-HDKQ7SH2.cjs} +3 -3
- package/dist/{chunk-5TD3NIQP.cjs.map → chunk-HDKQ7SH2.cjs.map} +1 -1
- package/dist/{chunk-M67X4PZR.js → chunk-HV6FLK65.js} +3 -3
- package/dist/{chunk-M67X4PZR.js.map → chunk-HV6FLK65.js.map} +1 -1
- package/dist/{chunk-4QHKKRIT.js → chunk-IDXQEXTK.js} +12 -8
- package/dist/chunk-IDXQEXTK.js.map +1 -0
- package/dist/{chunk-FTRKVTQN.cjs → chunk-IRVU7UEG.cjs} +224 -224
- package/dist/{chunk-FTRKVTQN.cjs.map → chunk-IRVU7UEG.cjs.map} +1 -1
- package/dist/{chunk-2NLDSYDR.js → chunk-L5FMCXMX.js} +3 -3
- package/dist/{chunk-2NLDSYDR.js.map → chunk-L5FMCXMX.js.map} +1 -1
- package/dist/{chunk-ONVOZCMT.js → chunk-MHZ7JPQO.js} +4 -4
- package/dist/{chunk-ONVOZCMT.js.map → chunk-MHZ7JPQO.js.map} +1 -1
- package/dist/{chunk-3ICKYYBF.cjs → chunk-OLEGQBPJ.cjs} +48 -48
- package/dist/{chunk-3ICKYYBF.cjs.map → chunk-OLEGQBPJ.cjs.map} +1 -1
- package/dist/{chunk-YCEAP2LH.js → chunk-PDZA7CHH.js} +3 -3
- package/dist/{chunk-YCEAP2LH.js.map → chunk-PDZA7CHH.js.map} +1 -1
- package/dist/{chunk-ZEW4LKNA.js → chunk-PMNREZUF.js} +6 -6
- package/dist/{chunk-ZEW4LKNA.js.map → chunk-PMNREZUF.js.map} +1 -1
- package/dist/{chunk-JVWWVGYJ.cjs → chunk-PP3Z4TR3.cjs} +24 -20
- package/dist/chunk-PP3Z4TR3.cjs.map +1 -0
- package/dist/{chunk-7YSXX5LB.js → chunk-QQDA2MGW.js} +9 -9
- package/dist/{chunk-7YSXX5LB.js.map → chunk-QQDA2MGW.js.map} +1 -1
- package/dist/{chunk-44XCLGWT.cjs → chunk-RK7JY24T.cjs} +7 -7
- package/dist/{chunk-44XCLGWT.cjs.map → chunk-RK7JY24T.cjs.map} +1 -1
- package/dist/{chunk-RWXRM5PV.js → chunk-SRBMROTH.js} +3 -3
- package/dist/{chunk-RWXRM5PV.js.map → chunk-SRBMROTH.js.map} +1 -1
- package/dist/{chunk-VGI3XJHQ.js → chunk-TDX45OUR.js} +9 -6
- package/dist/chunk-TDX45OUR.js.map +1 -0
- 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 +163 -163
- 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 -0
- 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-7Y4LYBV5.js +3 -0
- package/dist/{mastra-4WSGHKT3.js.map → mastra-7Y4LYBV5.js.map} +1 -1
- package/dist/mastra-VDOKA4KM.cjs +12 -0
- package/dist/{mastra-JJ4XSFRA.cjs.map → mastra-VDOKA4KM.cjs.map} +1 -1
- package/dist/memory/index.cjs +19 -19
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-NA6SJZMY.js +3 -0
- package/dist/{models-dev-5M6UHKL7.js.map → models-dev-NA6SJZMY.js.map} +1 -1
- package/dist/models-dev-NF7UD62B.cjs +12 -0
- package/dist/{models-dev-6PV6IPEU.cjs.map → models-dev-NF7UD62B.cjs.map} +1 -1
- package/dist/netlify-KHE7KRN5.js +3 -0
- package/dist/{netlify-K5ZLW6FE.js.map → netlify-KHE7KRN5.js.map} +1 -1
- package/dist/netlify-P4EFQMHA.cjs +12 -0
- package/dist/{netlify-MV4MTDH4.cjs.map → netlify-P4EFQMHA.cjs.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-LSYGSSFL.js +3 -0
- package/dist/{provider-registry-JLVRVYJG.js.map → provider-registry-LSYGSSFL.js.map} +1 -1
- package/dist/provider-registry-SFV3WU5J.cjs +44 -0
- package/dist/{provider-registry-5YSRQUGN.cjs.map → provider-registry-SFV3WU5J.cjs.map} +1 -1
- package/dist/provider-registry.json +4 -0
- 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/tools/provider-tool-utils.d.ts +2 -1
- package/dist/tools/provider-tool-utils.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/package.json +5 -5
- package/src/llm/model/provider-types.generated.d.ts +2 -0
- package/dist/chunk-4QHKKRIT.js.map +0 -1
- package/dist/chunk-JVWWVGYJ.cjs.map +0 -1
- package/dist/chunk-VGI3XJHQ.js.map +0 -1
- package/dist/chunk-ZYKGDZFW.cjs.map +0 -1
- package/dist/mastra-4WSGHKT3.js +0 -3
- package/dist/mastra-JJ4XSFRA.cjs +0 -12
- package/dist/models-dev-5M6UHKL7.js +0 -3
- package/dist/models-dev-6PV6IPEU.cjs +0 -12
- package/dist/netlify-K5ZLW6FE.js +0 -3
- package/dist/netlify-MV4MTDH4.cjs +0 -12
- package/dist/provider-registry-5YSRQUGN.cjs +0 -44
- package/dist/provider-registry-JLVRVYJG.js +0 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkPP3Z4TR3_cjs = require('./chunk-PP3Z4TR3.cjs');
|
|
4
|
+
var chunkIRVU7UEG_cjs = require('./chunk-IRVU7UEG.cjs');
|
|
5
|
+
var chunk2ZA7GO5N_cjs = require('./chunk-2ZA7GO5N.cjs');
|
|
6
|
+
var chunkHDKQ7SH2_cjs = require('./chunk-HDKQ7SH2.cjs');
|
|
7
7
|
var chunkT44GAO6N_cjs = require('./chunk-T44GAO6N.cjs');
|
|
8
8
|
var chunkI4YMMVQ3_cjs = require('./chunk-I4YMMVQ3.cjs');
|
|
9
9
|
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
@@ -105,7 +105,7 @@ chunkBVWXTWXP_cjs.__export(dist_exports2, {
|
|
|
105
105
|
DEFAULT_MAX_DOWNLOAD_SIZE: () => DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
106
106
|
DelayedPromise: () => DelayedPromise,
|
|
107
107
|
DownloadError: () => DownloadError,
|
|
108
|
-
EventSourceParserStream: () =>
|
|
108
|
+
EventSourceParserStream: () => chunkHDKQ7SH2_cjs.EventSourceParserStream,
|
|
109
109
|
VERSION: () => VERSION,
|
|
110
110
|
asSchema: () => asSchema,
|
|
111
111
|
asValidator: () => asValidator,
|
|
@@ -291,7 +291,7 @@ var marker = `vercel.ai.error.${name}`;
|
|
|
291
291
|
var symbol = Symbol.for(marker);
|
|
292
292
|
var _a;
|
|
293
293
|
var _b;
|
|
294
|
-
var DownloadError = class extends (_b =
|
|
294
|
+
var DownloadError = class extends (_b = chunkHDKQ7SH2_cjs.AISDKError, _a = symbol, _b) {
|
|
295
295
|
constructor({
|
|
296
296
|
url,
|
|
297
297
|
statusCode,
|
|
@@ -306,7 +306,7 @@ var DownloadError = class extends (_b = chunk5TD3NIQP_cjs.AISDKError, _a = symbo
|
|
|
306
306
|
this.statusText = statusText;
|
|
307
307
|
}
|
|
308
308
|
static isInstance(error) {
|
|
309
|
-
return
|
|
309
|
+
return chunkHDKQ7SH2_cjs.AISDKError.hasMarker(error, marker);
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
312
|
var DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
|
|
@@ -380,7 +380,7 @@ var createIdGenerator = ({
|
|
|
380
380
|
return generator;
|
|
381
381
|
}
|
|
382
382
|
if (alphabet.includes(separator)) {
|
|
383
|
-
throw new
|
|
383
|
+
throw new chunkHDKQ7SH2_cjs.InvalidArgumentError({
|
|
384
384
|
argument: "separator",
|
|
385
385
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
386
386
|
});
|
|
@@ -416,7 +416,7 @@ function handleFetchError({
|
|
|
416
416
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
417
417
|
const cause = error.cause;
|
|
418
418
|
if (cause != null) {
|
|
419
|
-
return new
|
|
419
|
+
return new chunkHDKQ7SH2_cjs.APICallError({
|
|
420
420
|
message: `Cannot connect to API: ${cause.message}`,
|
|
421
421
|
cause,
|
|
422
422
|
url,
|
|
@@ -504,10 +504,10 @@ var getFromApi = async ({
|
|
|
504
504
|
requestBodyValues: {}
|
|
505
505
|
});
|
|
506
506
|
} catch (error) {
|
|
507
|
-
if (isAbortError(error) ||
|
|
507
|
+
if (isAbortError(error) || chunkHDKQ7SH2_cjs.APICallError.isInstance(error)) {
|
|
508
508
|
throw error;
|
|
509
509
|
}
|
|
510
|
-
throw new
|
|
510
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
511
511
|
message: "Failed to process error response",
|
|
512
512
|
cause: error,
|
|
513
513
|
statusCode: response.status,
|
|
@@ -526,11 +526,11 @@ var getFromApi = async ({
|
|
|
526
526
|
});
|
|
527
527
|
} catch (error) {
|
|
528
528
|
if (error instanceof Error) {
|
|
529
|
-
if (isAbortError(error) ||
|
|
529
|
+
if (isAbortError(error) || chunkHDKQ7SH2_cjs.APICallError.isInstance(error)) {
|
|
530
530
|
throw error;
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
throw new
|
|
533
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
534
534
|
message: "Failed to process successful response",
|
|
535
535
|
cause: error,
|
|
536
536
|
statusCode: response.status,
|
|
@@ -602,23 +602,23 @@ function loadApiKey2({
|
|
|
602
602
|
return apiKey;
|
|
603
603
|
}
|
|
604
604
|
if (apiKey != null) {
|
|
605
|
-
throw new
|
|
605
|
+
throw new chunkHDKQ7SH2_cjs.LoadAPIKeyError({
|
|
606
606
|
message: `${description} API key must be a string.`
|
|
607
607
|
});
|
|
608
608
|
}
|
|
609
609
|
if (typeof process === "undefined") {
|
|
610
|
-
throw new
|
|
610
|
+
throw new chunkHDKQ7SH2_cjs.LoadAPIKeyError({
|
|
611
611
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
612
612
|
});
|
|
613
613
|
}
|
|
614
614
|
apiKey = process.env[environmentVariableName];
|
|
615
615
|
if (apiKey == null) {
|
|
616
|
-
throw new
|
|
616
|
+
throw new chunkHDKQ7SH2_cjs.LoadAPIKeyError({
|
|
617
617
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
618
618
|
});
|
|
619
619
|
}
|
|
620
620
|
if (typeof apiKey !== "string") {
|
|
621
|
-
throw new
|
|
621
|
+
throw new chunkHDKQ7SH2_cjs.LoadAPIKeyError({
|
|
622
622
|
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
623
623
|
});
|
|
624
624
|
}
|
|
@@ -650,23 +650,23 @@ function loadSetting({
|
|
|
650
650
|
return settingValue;
|
|
651
651
|
}
|
|
652
652
|
if (settingValue != null) {
|
|
653
|
-
throw new
|
|
653
|
+
throw new chunkHDKQ7SH2_cjs.LoadSettingError({
|
|
654
654
|
message: `${description} setting must be a string.`
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
657
|
if (typeof process === "undefined") {
|
|
658
|
-
throw new
|
|
658
|
+
throw new chunkHDKQ7SH2_cjs.LoadSettingError({
|
|
659
659
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables is not supported in this environment.`
|
|
660
660
|
});
|
|
661
661
|
}
|
|
662
662
|
settingValue = process.env[environmentVariableName];
|
|
663
663
|
if (settingValue == null) {
|
|
664
|
-
throw new
|
|
664
|
+
throw new chunkHDKQ7SH2_cjs.LoadSettingError({
|
|
665
665
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter or the ${environmentVariableName} environment variable.`
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
668
|
if (typeof settingValue !== "string") {
|
|
669
|
-
throw new
|
|
669
|
+
throw new chunkHDKQ7SH2_cjs.LoadSettingError({
|
|
670
670
|
message: `${description} setting must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
671
671
|
});
|
|
672
672
|
}
|
|
@@ -754,7 +754,7 @@ function standardSchemaValidator(standardSchema) {
|
|
|
754
754
|
const result = await standardSchema["~standard"].validate(value);
|
|
755
755
|
return result.issues == null ? { success: true, value: result.value } : {
|
|
756
756
|
success: false,
|
|
757
|
-
error: new
|
|
757
|
+
error: new chunkHDKQ7SH2_cjs.TypeValidationError({
|
|
758
758
|
value,
|
|
759
759
|
cause: result.issues
|
|
760
760
|
})
|
|
@@ -767,7 +767,7 @@ async function validateTypes2({
|
|
|
767
767
|
}) {
|
|
768
768
|
const result = await safeValidateTypes({ value, schema });
|
|
769
769
|
if (!result.success) {
|
|
770
|
-
throw
|
|
770
|
+
throw chunkHDKQ7SH2_cjs.TypeValidationError.wrap({ value, cause: result.error });
|
|
771
771
|
}
|
|
772
772
|
return result.value;
|
|
773
773
|
}
|
|
@@ -786,13 +786,13 @@ async function safeValidateTypes({
|
|
|
786
786
|
}
|
|
787
787
|
return {
|
|
788
788
|
success: false,
|
|
789
|
-
error:
|
|
789
|
+
error: chunkHDKQ7SH2_cjs.TypeValidationError.wrap({ value, cause: result.error }),
|
|
790
790
|
rawValue: value
|
|
791
791
|
};
|
|
792
792
|
} catch (error) {
|
|
793
793
|
return {
|
|
794
794
|
success: false,
|
|
795
|
-
error:
|
|
795
|
+
error: chunkHDKQ7SH2_cjs.TypeValidationError.wrap({ value, cause: error }),
|
|
796
796
|
rawValue: value
|
|
797
797
|
};
|
|
798
798
|
}
|
|
@@ -808,10 +808,10 @@ async function parseJSON({
|
|
|
808
808
|
}
|
|
809
809
|
return validateTypes2({ value, schema });
|
|
810
810
|
} catch (error) {
|
|
811
|
-
if (
|
|
811
|
+
if (chunkHDKQ7SH2_cjs.JSONParseError.isInstance(error) || chunkHDKQ7SH2_cjs.TypeValidationError.isInstance(error)) {
|
|
812
812
|
throw error;
|
|
813
813
|
}
|
|
814
|
-
throw new
|
|
814
|
+
throw new chunkHDKQ7SH2_cjs.JSONParseError({ text, cause: error });
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
async function safeParseJSON({
|
|
@@ -827,7 +827,7 @@ async function safeParseJSON({
|
|
|
827
827
|
} catch (error) {
|
|
828
828
|
return {
|
|
829
829
|
success: false,
|
|
830
|
-
error:
|
|
830
|
+
error: chunkHDKQ7SH2_cjs.JSONParseError.isInstance(error) ? error : new chunkHDKQ7SH2_cjs.JSONParseError({ text, cause: error }),
|
|
831
831
|
rawValue: void 0
|
|
832
832
|
};
|
|
833
833
|
}
|
|
@@ -844,7 +844,7 @@ function parseJsonEventStream({
|
|
|
844
844
|
stream,
|
|
845
845
|
schema
|
|
846
846
|
}) {
|
|
847
|
-
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
847
|
+
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new chunkHDKQ7SH2_cjs.EventSourceParserStream()).pipeThrough(
|
|
848
848
|
new TransformStream({
|
|
849
849
|
async transform({ data }, controller) {
|
|
850
850
|
if (data === "[DONE]") {
|
|
@@ -868,7 +868,7 @@ async function parseProviderOptions2({
|
|
|
868
868
|
schema
|
|
869
869
|
});
|
|
870
870
|
if (!parsedProviderOptions.success) {
|
|
871
|
-
throw new
|
|
871
|
+
throw new chunkHDKQ7SH2_cjs.InvalidArgumentError({
|
|
872
872
|
argument: "providerOptions",
|
|
873
873
|
message: `invalid ${provider} provider options`,
|
|
874
874
|
cause: parsedProviderOptions.error
|
|
@@ -950,10 +950,10 @@ var postToApi = async ({
|
|
|
950
950
|
requestBodyValues: body.values
|
|
951
951
|
});
|
|
952
952
|
} catch (error) {
|
|
953
|
-
if (isAbortError(error) ||
|
|
953
|
+
if (isAbortError(error) || chunkHDKQ7SH2_cjs.APICallError.isInstance(error)) {
|
|
954
954
|
throw error;
|
|
955
955
|
}
|
|
956
|
-
throw new
|
|
956
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
957
957
|
message: "Failed to process error response",
|
|
958
958
|
cause: error,
|
|
959
959
|
statusCode: response.status,
|
|
@@ -972,11 +972,11 @@ var postToApi = async ({
|
|
|
972
972
|
});
|
|
973
973
|
} catch (error) {
|
|
974
974
|
if (error instanceof Error) {
|
|
975
|
-
if (isAbortError(error) ||
|
|
975
|
+
if (isAbortError(error) || chunkHDKQ7SH2_cjs.APICallError.isInstance(error)) {
|
|
976
976
|
throw error;
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
throw new
|
|
979
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
980
980
|
message: "Failed to process successful response",
|
|
981
981
|
cause: error,
|
|
982
982
|
statusCode: response.status,
|
|
@@ -1070,7 +1070,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1070
1070
|
if (responseBody.trim() === "") {
|
|
1071
1071
|
return {
|
|
1072
1072
|
responseHeaders,
|
|
1073
|
-
value: new
|
|
1073
|
+
value: new chunkHDKQ7SH2_cjs.APICallError({
|
|
1074
1074
|
message: response.statusText,
|
|
1075
1075
|
url,
|
|
1076
1076
|
requestBodyValues,
|
|
@@ -1088,7 +1088,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1088
1088
|
});
|
|
1089
1089
|
return {
|
|
1090
1090
|
responseHeaders,
|
|
1091
|
-
value: new
|
|
1091
|
+
value: new chunkHDKQ7SH2_cjs.APICallError({
|
|
1092
1092
|
message: errorToMessage(parsedError),
|
|
1093
1093
|
url,
|
|
1094
1094
|
requestBodyValues,
|
|
@@ -1102,7 +1102,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1102
1102
|
} catch (parseError) {
|
|
1103
1103
|
return {
|
|
1104
1104
|
responseHeaders,
|
|
1105
|
-
value: new
|
|
1105
|
+
value: new chunkHDKQ7SH2_cjs.APICallError({
|
|
1106
1106
|
message: response.statusText,
|
|
1107
1107
|
url,
|
|
1108
1108
|
requestBodyValues,
|
|
@@ -1117,7 +1117,7 @@ var createJsonErrorResponseHandler2 = ({
|
|
|
1117
1117
|
var createEventSourceResponseHandler2 = (chunkSchema2) => async ({ response }) => {
|
|
1118
1118
|
const responseHeaders = extractResponseHeaders(response);
|
|
1119
1119
|
if (response.body == null) {
|
|
1120
|
-
throw new
|
|
1120
|
+
throw new chunkHDKQ7SH2_cjs.EmptyResponseBodyError({});
|
|
1121
1121
|
}
|
|
1122
1122
|
return {
|
|
1123
1123
|
responseHeaders,
|
|
@@ -1130,7 +1130,7 @@ var createEventSourceResponseHandler2 = (chunkSchema2) => async ({ response }) =
|
|
|
1130
1130
|
var createJsonStreamResponseHandler = (chunkSchema2) => async ({ response }) => {
|
|
1131
1131
|
const responseHeaders = extractResponseHeaders(response);
|
|
1132
1132
|
if (response.body == null) {
|
|
1133
|
-
throw new
|
|
1133
|
+
throw new chunkHDKQ7SH2_cjs.EmptyResponseBodyError({});
|
|
1134
1134
|
}
|
|
1135
1135
|
let buffer = "";
|
|
1136
1136
|
return {
|
|
@@ -1162,7 +1162,7 @@ var createJsonResponseHandler2 = (responseSchema2) => async ({ response, url, re
|
|
|
1162
1162
|
});
|
|
1163
1163
|
const responseHeaders = extractResponseHeaders(response);
|
|
1164
1164
|
if (!parsedResult.success) {
|
|
1165
|
-
throw new
|
|
1165
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
1166
1166
|
message: "Invalid JSON response",
|
|
1167
1167
|
cause: parsedResult.error,
|
|
1168
1168
|
statusCode: response.status,
|
|
@@ -1181,7 +1181,7 @@ var createJsonResponseHandler2 = (responseSchema2) => async ({ response, url, re
|
|
|
1181
1181
|
var createBinaryResponseHandler2 = () => async ({ response, url, requestBodyValues }) => {
|
|
1182
1182
|
const responseHeaders = extractResponseHeaders(response);
|
|
1183
1183
|
if (!response.body) {
|
|
1184
|
-
throw new
|
|
1184
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
1185
1185
|
message: "Response body is empty",
|
|
1186
1186
|
url,
|
|
1187
1187
|
requestBodyValues,
|
|
@@ -1197,7 +1197,7 @@ var createBinaryResponseHandler2 = () => async ({ response, url, requestBodyValu
|
|
|
1197
1197
|
value: new Uint8Array(buffer)
|
|
1198
1198
|
};
|
|
1199
1199
|
} catch (error) {
|
|
1200
|
-
throw new
|
|
1200
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
1201
1201
|
message: "Failed to read response as array buffer",
|
|
1202
1202
|
url,
|
|
1203
1203
|
requestBodyValues,
|
|
@@ -1213,7 +1213,7 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
1213
1213
|
const responseBody = await response.text();
|
|
1214
1214
|
return {
|
|
1215
1215
|
responseHeaders,
|
|
1216
|
-
value: new
|
|
1216
|
+
value: new chunkHDKQ7SH2_cjs.APICallError({
|
|
1217
1217
|
message: response.statusText,
|
|
1218
1218
|
url,
|
|
1219
1219
|
requestBodyValues,
|
|
@@ -2635,7 +2635,7 @@ function convertToOpenAIChatMessages({
|
|
|
2635
2635
|
};
|
|
2636
2636
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
2637
2637
|
if (part.data instanceof URL) {
|
|
2638
|
-
throw new
|
|
2638
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
2639
2639
|
functionality: "audio file parts with URLs"
|
|
2640
2640
|
});
|
|
2641
2641
|
}
|
|
@@ -2660,14 +2660,14 @@ function convertToOpenAIChatMessages({
|
|
|
2660
2660
|
};
|
|
2661
2661
|
}
|
|
2662
2662
|
default: {
|
|
2663
|
-
throw new
|
|
2663
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
2664
2664
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
2665
2665
|
});
|
|
2666
2666
|
}
|
|
2667
2667
|
}
|
|
2668
2668
|
} else if (part.mediaType === "application/pdf") {
|
|
2669
2669
|
if (part.data instanceof URL) {
|
|
2670
|
-
throw new
|
|
2670
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
2671
2671
|
functionality: "PDF file parts with URLs"
|
|
2672
2672
|
});
|
|
2673
2673
|
}
|
|
@@ -2679,7 +2679,7 @@ function convertToOpenAIChatMessages({
|
|
|
2679
2679
|
}
|
|
2680
2680
|
};
|
|
2681
2681
|
} else {
|
|
2682
|
-
throw new
|
|
2682
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
2683
2683
|
functionality: `file part media type ${part.mediaType}`
|
|
2684
2684
|
});
|
|
2685
2685
|
}
|
|
@@ -3067,7 +3067,7 @@ function prepareChatTools({
|
|
|
3067
3067
|
};
|
|
3068
3068
|
default: {
|
|
3069
3069
|
const _exhaustiveCheck = type;
|
|
3070
|
-
throw new
|
|
3070
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
3071
3071
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
3072
3072
|
});
|
|
3073
3073
|
}
|
|
@@ -3459,19 +3459,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
3459
3459
|
const index = toolCallDelta.index;
|
|
3460
3460
|
if (toolCalls[index] == null) {
|
|
3461
3461
|
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
3462
|
-
throw new
|
|
3462
|
+
throw new chunkHDKQ7SH2_cjs.InvalidResponseDataError({
|
|
3463
3463
|
data: toolCallDelta,
|
|
3464
3464
|
message: `Expected 'function' type.`
|
|
3465
3465
|
});
|
|
3466
3466
|
}
|
|
3467
3467
|
if (toolCallDelta.id == null) {
|
|
3468
|
-
throw new
|
|
3468
|
+
throw new chunkHDKQ7SH2_cjs.InvalidResponseDataError({
|
|
3469
3469
|
data: toolCallDelta,
|
|
3470
3470
|
message: `Expected 'id' to be a string.`
|
|
3471
3471
|
});
|
|
3472
3472
|
}
|
|
3473
3473
|
if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
|
|
3474
|
-
throw new
|
|
3474
|
+
throw new chunkHDKQ7SH2_cjs.InvalidResponseDataError({
|
|
3475
3475
|
data: toolCallDelta,
|
|
3476
3476
|
message: `Expected 'function.name' to be a string.`
|
|
3477
3477
|
});
|
|
@@ -3587,7 +3587,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
3587
3587
|
for (const { role, content } of prompt) {
|
|
3588
3588
|
switch (role) {
|
|
3589
3589
|
case "system": {
|
|
3590
|
-
throw new
|
|
3590
|
+
throw new chunkHDKQ7SH2_cjs.InvalidPromptError({
|
|
3591
3591
|
message: "Unexpected system message in prompt: ${content}",
|
|
3592
3592
|
prompt
|
|
3593
3593
|
});
|
|
@@ -3613,7 +3613,7 @@ ${userMessage}
|
|
|
3613
3613
|
return part.text;
|
|
3614
3614
|
}
|
|
3615
3615
|
case "tool-call": {
|
|
3616
|
-
throw new
|
|
3616
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
3617
3617
|
functionality: "tool-call messages"
|
|
3618
3618
|
});
|
|
3619
3619
|
}
|
|
@@ -3626,7 +3626,7 @@ ${assistantMessage}
|
|
|
3626
3626
|
break;
|
|
3627
3627
|
}
|
|
3628
3628
|
case "tool": {
|
|
3629
|
-
throw new
|
|
3629
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
3630
3630
|
functionality: "tool messages"
|
|
3631
3631
|
});
|
|
3632
3632
|
}
|
|
@@ -4039,7 +4039,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
4039
4039
|
}) {
|
|
4040
4040
|
var _a2;
|
|
4041
4041
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
4042
|
-
throw new
|
|
4042
|
+
throw new chunkHDKQ7SH2_cjs.TooManyEmbeddingValuesForCallError({
|
|
4043
4043
|
provider: this.provider,
|
|
4044
4044
|
modelId: this.modelId,
|
|
4045
4045
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -4656,7 +4656,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4656
4656
|
}
|
|
4657
4657
|
};
|
|
4658
4658
|
} else {
|
|
4659
|
-
throw new
|
|
4659
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
4660
4660
|
functionality: `file part media type ${part.mediaType}`
|
|
4661
4661
|
});
|
|
4662
4662
|
}
|
|
@@ -5721,7 +5721,7 @@ async function prepareResponsesTools({
|
|
|
5721
5721
|
};
|
|
5722
5722
|
default: {
|
|
5723
5723
|
const _exhaustiveCheck = type;
|
|
5724
|
-
throw new
|
|
5724
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
5725
5725
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
5726
5726
|
});
|
|
5727
5727
|
}
|
|
@@ -5979,7 +5979,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5979
5979
|
fetch: this.config.fetch
|
|
5980
5980
|
});
|
|
5981
5981
|
if (response.error) {
|
|
5982
|
-
throw new
|
|
5982
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
5983
5983
|
message: response.error.message,
|
|
5984
5984
|
url,
|
|
5985
5985
|
requestBodyValues: body,
|
|
@@ -6922,7 +6922,7 @@ function createAzure(options = {}) {
|
|
|
6922
6922
|
createAzure();
|
|
6923
6923
|
|
|
6924
6924
|
// src/llm/model/gateways/azure.ts
|
|
6925
|
-
var AzureOpenAIGateway = class extends
|
|
6925
|
+
var AzureOpenAIGateway = class extends chunkHDKQ7SH2_cjs.MastraModelGateway {
|
|
6926
6926
|
constructor(config) {
|
|
6927
6927
|
super();
|
|
6928
6928
|
this.config = config;
|
|
@@ -7131,7 +7131,7 @@ var AzureOpenAIGateway = class extends chunk5TD3NIQP_cjs.MastraModelGateway {
|
|
|
7131
7131
|
apiKey,
|
|
7132
7132
|
apiVersion,
|
|
7133
7133
|
useDeploymentBasedUrls: true,
|
|
7134
|
-
headers: { "User-Agent":
|
|
7134
|
+
headers: { "User-Agent": chunkHDKQ7SH2_cjs.MASTRA_USER_AGENT, ...headers }
|
|
7135
7135
|
})(modelId);
|
|
7136
7136
|
}
|
|
7137
7137
|
};
|
|
@@ -7367,12 +7367,12 @@ function stableHeaderKey(headers) {
|
|
|
7367
7367
|
return JSON.stringify(entries.sort(([a], [b]) => a.localeCompare(b)));
|
|
7368
7368
|
}
|
|
7369
7369
|
function getStaticProvidersByGateway(name2) {
|
|
7370
|
-
return Object.fromEntries(Object.entries(
|
|
7370
|
+
return Object.fromEntries(Object.entries(chunkPP3Z4TR3_cjs.PROVIDER_REGISTRY).filter(([_provider, config]) => config.gateway === name2));
|
|
7371
7371
|
}
|
|
7372
7372
|
var defaultGateways = [
|
|
7373
|
-
new
|
|
7374
|
-
new
|
|
7375
|
-
new
|
|
7373
|
+
new chunk2ZA7GO5N_cjs.NetlifyGateway(),
|
|
7374
|
+
new chunkPP3Z4TR3_cjs.MastraGateway(),
|
|
7375
|
+
new chunkIRVU7UEG_cjs.ModelsDevGateway(getStaticProvidersByGateway(`models.dev`))
|
|
7376
7376
|
];
|
|
7377
7377
|
var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
7378
7378
|
specificationVersion = "v2";
|
|
@@ -7421,7 +7421,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7421
7421
|
this.gateway = findGatewayForModel(normalizedConfig.id, allGateways);
|
|
7422
7422
|
this.gatewayId = this.gateway.id;
|
|
7423
7423
|
const gatewayPrefix = this.gateway.id === "models.dev" ? void 0 : this.gateway.id;
|
|
7424
|
-
const parsed =
|
|
7424
|
+
const parsed = chunkIRVU7UEG_cjs.parseModelRouterId(normalizedConfig.id, gatewayPrefix);
|
|
7425
7425
|
this.provider = parsed.providerId || "openai-compatible";
|
|
7426
7426
|
if (parsed.providerId && parsed.modelId !== normalizedConfig.id) {
|
|
7427
7427
|
parsedConfig.id = parsed.modelId;
|
|
@@ -7467,7 +7467,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7467
7467
|
const model = await this.resolveLanguageModel({
|
|
7468
7468
|
apiKey,
|
|
7469
7469
|
headers: this.config.headers,
|
|
7470
|
-
...
|
|
7470
|
+
...chunkIRVU7UEG_cjs.parseModelRouterId(this.config.routerId, gatewayPrefix)
|
|
7471
7471
|
});
|
|
7472
7472
|
const modelSupportedUrls = model.supportedUrls;
|
|
7473
7473
|
if (!modelSupportedUrls) {
|
|
@@ -7531,7 +7531,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7531
7531
|
const model = await this.resolveLanguageModel({
|
|
7532
7532
|
apiKey,
|
|
7533
7533
|
headers: this.config.headers,
|
|
7534
|
-
...
|
|
7534
|
+
...chunkIRVU7UEG_cjs.parseModelRouterId(this.config.routerId, gatewayPrefix)
|
|
7535
7535
|
});
|
|
7536
7536
|
if (isLanguageModelV3(model)) {
|
|
7537
7537
|
const aiSDKV6Model = new AISDKV6LanguageModel(model);
|
|
@@ -7571,7 +7571,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7571
7571
|
headers: this.config.headers,
|
|
7572
7572
|
transport: resolvedTransport,
|
|
7573
7573
|
openaiWebSocket: websocket,
|
|
7574
|
-
...
|
|
7574
|
+
...chunkIRVU7UEG_cjs.parseModelRouterId(this.config.routerId, gatewayPrefix)
|
|
7575
7575
|
});
|
|
7576
7576
|
if (isLanguageModelV3(model)) {
|
|
7577
7577
|
const aiSDKV6Model = new AISDKV6LanguageModel(model);
|
|
@@ -7598,7 +7598,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7598
7598
|
return _ModelRouterLanguageModel.modelInstances.get(key);
|
|
7599
7599
|
}
|
|
7600
7600
|
if (this.config.url) {
|
|
7601
|
-
const modelInstance2 =
|
|
7601
|
+
const modelInstance2 = chunkHDKQ7SH2_cjs.createOpenAICompatible({
|
|
7602
7602
|
name: providerId,
|
|
7603
7603
|
apiKey,
|
|
7604
7604
|
baseURL: this.config.url,
|
|
@@ -7641,7 +7641,7 @@ var ModelRouterLanguageModel = class _ModelRouterLanguageModel {
|
|
|
7641
7641
|
url: openaiWebSocket?.url,
|
|
7642
7642
|
headers: openaiWebSocket?.headers
|
|
7643
7643
|
});
|
|
7644
|
-
const modelInstance =
|
|
7644
|
+
const modelInstance = chunkHDKQ7SH2_cjs.createOpenAI({
|
|
7645
7645
|
apiKey,
|
|
7646
7646
|
baseURL,
|
|
7647
7647
|
headers,
|
|
@@ -7692,8 +7692,8 @@ async function resolveModelConfig(modelConfig, requestContext = new chunk5WBEMKE
|
|
|
7692
7692
|
throw new Error("Invalid model configuration provided");
|
|
7693
7693
|
}
|
|
7694
7694
|
var VERSION3 = "2.0.68" ;
|
|
7695
|
-
var googleErrorDataSchema =
|
|
7696
|
-
() =>
|
|
7695
|
+
var googleErrorDataSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
7696
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
7697
7697
|
z4.z.object({
|
|
7698
7698
|
error: z4.z.object({
|
|
7699
7699
|
code: z4.z.number().nullable(),
|
|
@@ -7703,7 +7703,7 @@ var googleErrorDataSchema = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
7703
7703
|
})
|
|
7704
7704
|
)
|
|
7705
7705
|
);
|
|
7706
|
-
var googleFailedResponseHandler =
|
|
7706
|
+
var googleFailedResponseHandler = chunkHDKQ7SH2_cjs.createJsonErrorResponseHandler({
|
|
7707
7707
|
errorSchema: googleErrorDataSchema,
|
|
7708
7708
|
errorToMessage: (data) => data.error.message
|
|
7709
7709
|
});
|
|
@@ -7716,8 +7716,8 @@ var googleEmbeddingContentPartSchema = z4.z.union([
|
|
|
7716
7716
|
})
|
|
7717
7717
|
})
|
|
7718
7718
|
]);
|
|
7719
|
-
var googleGenerativeAIEmbeddingProviderOptions =
|
|
7720
|
-
() =>
|
|
7719
|
+
var googleGenerativeAIEmbeddingProviderOptions = chunkHDKQ7SH2_cjs.lazySchema(
|
|
7720
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
7721
7721
|
z4.z.object({
|
|
7722
7722
|
/**
|
|
7723
7723
|
* Optional. Optional reduced dimension for the output embedding.
|
|
@@ -7776,21 +7776,21 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7776
7776
|
abortSignal,
|
|
7777
7777
|
providerOptions
|
|
7778
7778
|
}) {
|
|
7779
|
-
const googleOptions = await
|
|
7779
|
+
const googleOptions = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
7780
7780
|
provider: "google",
|
|
7781
7781
|
providerOptions,
|
|
7782
7782
|
schema: googleGenerativeAIEmbeddingProviderOptions
|
|
7783
7783
|
});
|
|
7784
7784
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
7785
|
-
throw new
|
|
7785
|
+
throw new chunkHDKQ7SH2_cjs.TooManyEmbeddingValuesForCallError({
|
|
7786
7786
|
provider: this.provider,
|
|
7787
7787
|
modelId: this.modelId,
|
|
7788
7788
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
7789
7789
|
values
|
|
7790
7790
|
});
|
|
7791
7791
|
}
|
|
7792
|
-
const mergedHeaders =
|
|
7793
|
-
await
|
|
7792
|
+
const mergedHeaders = chunkHDKQ7SH2_cjs.combineHeaders(
|
|
7793
|
+
await chunkHDKQ7SH2_cjs.resolve(this.config.headers),
|
|
7794
7794
|
headers
|
|
7795
7795
|
);
|
|
7796
7796
|
const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
|
|
@@ -7807,7 +7807,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7807
7807
|
responseHeaders: responseHeaders2,
|
|
7808
7808
|
value: response2,
|
|
7809
7809
|
rawValue: rawValue2
|
|
7810
|
-
} = await
|
|
7810
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
7811
7811
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
7812
7812
|
headers: mergedHeaders,
|
|
7813
7813
|
body: {
|
|
@@ -7819,7 +7819,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7819
7819
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
7820
7820
|
},
|
|
7821
7821
|
failedResponseHandler: googleFailedResponseHandler,
|
|
7822
|
-
successfulResponseHandler:
|
|
7822
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
7823
7823
|
googleGenerativeAISingleEmbeddingResponseSchema
|
|
7824
7824
|
),
|
|
7825
7825
|
abortSignal,
|
|
@@ -7835,7 +7835,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7835
7835
|
responseHeaders,
|
|
7836
7836
|
value: response,
|
|
7837
7837
|
rawValue
|
|
7838
|
-
} = await
|
|
7838
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
7839
7839
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
7840
7840
|
headers: mergedHeaders,
|
|
7841
7841
|
body: {
|
|
@@ -7854,7 +7854,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7854
7854
|
})
|
|
7855
7855
|
},
|
|
7856
7856
|
failedResponseHandler: googleFailedResponseHandler,
|
|
7857
|
-
successfulResponseHandler:
|
|
7857
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
7858
7858
|
googleGenerativeAITextEmbeddingResponseSchema
|
|
7859
7859
|
),
|
|
7860
7860
|
abortSignal,
|
|
@@ -7867,15 +7867,15 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
7867
7867
|
};
|
|
7868
7868
|
}
|
|
7869
7869
|
};
|
|
7870
|
-
var googleGenerativeAITextEmbeddingResponseSchema =
|
|
7871
|
-
() =>
|
|
7870
|
+
var googleGenerativeAITextEmbeddingResponseSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
7871
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
7872
7872
|
z4.z.object({
|
|
7873
7873
|
embeddings: z4.z.array(z4.z.object({ values: z4.z.array(z4.z.number()) }))
|
|
7874
7874
|
})
|
|
7875
7875
|
)
|
|
7876
7876
|
);
|
|
7877
|
-
var googleGenerativeAISingleEmbeddingResponseSchema =
|
|
7878
|
-
() =>
|
|
7877
|
+
var googleGenerativeAISingleEmbeddingResponseSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
7878
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
7879
7879
|
z4.z.object({
|
|
7880
7880
|
embedding: z4.z.object({ values: z4.z.array(z4.z.number()) })
|
|
7881
7881
|
})
|
|
@@ -8006,7 +8006,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
8006
8006
|
switch (role) {
|
|
8007
8007
|
case "system": {
|
|
8008
8008
|
if (!systemMessagesAllowed) {
|
|
8009
|
-
throw new
|
|
8009
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
8010
8010
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
8011
8011
|
});
|
|
8012
8012
|
}
|
|
@@ -8033,7 +8033,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
8033
8033
|
} : {
|
|
8034
8034
|
inlineData: {
|
|
8035
8035
|
mimeType: mediaType,
|
|
8036
|
-
data:
|
|
8036
|
+
data: chunkHDKQ7SH2_cjs.convertToBase64(part.data)
|
|
8037
8037
|
}
|
|
8038
8038
|
}
|
|
8039
8039
|
);
|
|
@@ -8067,19 +8067,19 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
8067
8067
|
}
|
|
8068
8068
|
case "file": {
|
|
8069
8069
|
if (part.mediaType !== "image/png") {
|
|
8070
|
-
throw new
|
|
8070
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
8071
8071
|
functionality: "Only PNG images are supported in assistant messages"
|
|
8072
8072
|
});
|
|
8073
8073
|
}
|
|
8074
8074
|
if (part.data instanceof URL) {
|
|
8075
|
-
throw new
|
|
8075
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
8076
8076
|
functionality: "File data URLs in assistant messages are not supported"
|
|
8077
8077
|
});
|
|
8078
8078
|
}
|
|
8079
8079
|
return {
|
|
8080
8080
|
inlineData: {
|
|
8081
8081
|
mimeType: part.mediaType,
|
|
8082
|
-
data:
|
|
8082
|
+
data: chunkHDKQ7SH2_cjs.convertToBase64(part.data)
|
|
8083
8083
|
}
|
|
8084
8084
|
};
|
|
8085
8085
|
}
|
|
@@ -8211,8 +8211,8 @@ function appendLegacyToolResultParts({
|
|
|
8211
8211
|
function getModelPath(modelId) {
|
|
8212
8212
|
return modelId.includes("/") ? modelId : `models/${modelId}`;
|
|
8213
8213
|
}
|
|
8214
|
-
var googleGenerativeAIProviderOptions =
|
|
8215
|
-
() =>
|
|
8214
|
+
var googleGenerativeAIProviderOptions = chunkHDKQ7SH2_cjs.lazySchema(
|
|
8215
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
8216
8216
|
z4.z.object({
|
|
8217
8217
|
responseModalities: z4.z.array(z4.z.enum(["TEXT", "IMAGE"])).optional(),
|
|
8218
8218
|
thinkingConfig: z4.z.object({
|
|
@@ -8527,7 +8527,7 @@ function prepareTools({
|
|
|
8527
8527
|
};
|
|
8528
8528
|
default: {
|
|
8529
8529
|
const _exhaustiveCheck = type;
|
|
8530
|
-
throw new
|
|
8530
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
8531
8531
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
8532
8532
|
});
|
|
8533
8533
|
}
|
|
@@ -8564,7 +8564,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8564
8564
|
var _a2;
|
|
8565
8565
|
this.modelId = modelId;
|
|
8566
8566
|
this.config = config;
|
|
8567
|
-
this.generateId = (_a2 = config.generateId) != null ? _a2 :
|
|
8567
|
+
this.generateId = (_a2 = config.generateId) != null ? _a2 : chunkHDKQ7SH2_cjs.generateId;
|
|
8568
8568
|
}
|
|
8569
8569
|
get provider() {
|
|
8570
8570
|
return this.config.provider;
|
|
@@ -8590,7 +8590,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8590
8590
|
}) {
|
|
8591
8591
|
var _a2;
|
|
8592
8592
|
const warnings = [];
|
|
8593
|
-
const googleOptions = await
|
|
8593
|
+
const googleOptions = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
8594
8594
|
provider: "google",
|
|
8595
8595
|
providerOptions,
|
|
8596
8596
|
schema: googleGenerativeAIProviderOptions
|
|
@@ -8673,22 +8673,22 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8673
8673
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8674
8674
|
const { args, warnings } = await this.getArgs(options);
|
|
8675
8675
|
const body = JSON.stringify(args);
|
|
8676
|
-
const mergedHeaders =
|
|
8677
|
-
await
|
|
8676
|
+
const mergedHeaders = chunkHDKQ7SH2_cjs.combineHeaders(
|
|
8677
|
+
await chunkHDKQ7SH2_cjs.resolve(this.config.headers),
|
|
8678
8678
|
options.headers
|
|
8679
8679
|
);
|
|
8680
8680
|
const {
|
|
8681
8681
|
responseHeaders,
|
|
8682
8682
|
value: response,
|
|
8683
8683
|
rawValue: rawResponse
|
|
8684
|
-
} = await
|
|
8684
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
8685
8685
|
url: `${this.config.baseURL}/${getModelPath(
|
|
8686
8686
|
this.modelId
|
|
8687
8687
|
)}:generateContent`,
|
|
8688
8688
|
headers: mergedHeaders,
|
|
8689
8689
|
body: args,
|
|
8690
8690
|
failedResponseHandler: googleFailedResponseHandler,
|
|
8691
|
-
successfulResponseHandler:
|
|
8691
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(responseSchema),
|
|
8692
8692
|
abortSignal: options.abortSignal,
|
|
8693
8693
|
fetch: this.config.fetch
|
|
8694
8694
|
});
|
|
@@ -8794,18 +8794,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
8794
8794
|
async doStream(options) {
|
|
8795
8795
|
const { args, warnings } = await this.getArgs(options);
|
|
8796
8796
|
const body = JSON.stringify(args);
|
|
8797
|
-
const headers =
|
|
8798
|
-
await
|
|
8797
|
+
const headers = chunkHDKQ7SH2_cjs.combineHeaders(
|
|
8798
|
+
await chunkHDKQ7SH2_cjs.resolve(this.config.headers),
|
|
8799
8799
|
options.headers
|
|
8800
8800
|
);
|
|
8801
|
-
const { responseHeaders, value: response } = await
|
|
8801
|
+
const { responseHeaders, value: response } = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
8802
8802
|
url: `${this.config.baseURL}/${getModelPath(
|
|
8803
8803
|
this.modelId
|
|
8804
8804
|
)}:streamGenerateContent?alt=sse`,
|
|
8805
8805
|
headers,
|
|
8806
8806
|
body: args,
|
|
8807
8807
|
failedResponseHandler: googleFailedResponseHandler,
|
|
8808
|
-
successfulResponseHandler:
|
|
8808
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createEventSourceResponseHandler(chunkSchema),
|
|
8809
8809
|
abortSignal: options.abortSignal,
|
|
8810
8810
|
fetch: this.config.fetch
|
|
8811
8811
|
});
|
|
@@ -9278,8 +9278,8 @@ var getUrlContextMetadataSchema = () => z4.z.object({
|
|
|
9278
9278
|
})
|
|
9279
9279
|
)
|
|
9280
9280
|
});
|
|
9281
|
-
var responseSchema =
|
|
9282
|
-
() =>
|
|
9281
|
+
var responseSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
9282
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
9283
9283
|
z4.z.object({
|
|
9284
9284
|
candidates: z4.z.array(
|
|
9285
9285
|
z4.z.object({
|
|
@@ -9299,8 +9299,8 @@ var responseSchema = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
9299
9299
|
})
|
|
9300
9300
|
)
|
|
9301
9301
|
);
|
|
9302
|
-
var chunkSchema =
|
|
9303
|
-
() =>
|
|
9302
|
+
var chunkSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
9303
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
9304
9304
|
z4.z.object({
|
|
9305
9305
|
candidates: z4.z.array(
|
|
9306
9306
|
z4.z.object({
|
|
@@ -9320,7 +9320,7 @@ var chunkSchema = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
9320
9320
|
})
|
|
9321
9321
|
)
|
|
9322
9322
|
);
|
|
9323
|
-
var codeExecution =
|
|
9323
|
+
var codeExecution = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
9324
9324
|
id: "google.code_execution",
|
|
9325
9325
|
name: "code_execution",
|
|
9326
9326
|
inputSchema: z4.z.object({
|
|
@@ -9332,10 +9332,10 @@ var codeExecution = chunk5TD3NIQP_cjs.createProviderDefinedToolFactoryWithOutput
|
|
|
9332
9332
|
output: z4.z.string().describe("The output from the code execution.")
|
|
9333
9333
|
})
|
|
9334
9334
|
});
|
|
9335
|
-
var enterpriseWebSearch =
|
|
9335
|
+
var enterpriseWebSearch = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactory({
|
|
9336
9336
|
id: "google.enterprise_web_search",
|
|
9337
9337
|
name: "enterprise_web_search",
|
|
9338
|
-
inputSchema:
|
|
9338
|
+
inputSchema: chunkHDKQ7SH2_cjs.lazySchema(() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({})))
|
|
9339
9339
|
});
|
|
9340
9340
|
var fileSearchArgsBaseSchema = z4.z.object({
|
|
9341
9341
|
/** The names of the file_search_stores to retrieve from.
|
|
@@ -9353,18 +9353,18 @@ var fileSearchArgsBaseSchema = z4.z.object({
|
|
|
9353
9353
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
9354
9354
|
).optional()
|
|
9355
9355
|
}).passthrough();
|
|
9356
|
-
var fileSearchArgsSchema2 =
|
|
9357
|
-
() =>
|
|
9356
|
+
var fileSearchArgsSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
9357
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(fileSearchArgsBaseSchema)
|
|
9358
9358
|
);
|
|
9359
|
-
var fileSearch2 =
|
|
9359
|
+
var fileSearch2 = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactory({
|
|
9360
9360
|
id: "google.file_search",
|
|
9361
9361
|
name: "file_search",
|
|
9362
9362
|
inputSchema: fileSearchArgsSchema2
|
|
9363
9363
|
});
|
|
9364
|
-
var googleMaps =
|
|
9364
|
+
var googleMaps = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactory({
|
|
9365
9365
|
id: "google.google_maps",
|
|
9366
9366
|
name: "google_maps",
|
|
9367
|
-
inputSchema:
|
|
9367
|
+
inputSchema: chunkHDKQ7SH2_cjs.lazySchema(() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({})))
|
|
9368
9368
|
});
|
|
9369
9369
|
var googleSearchToolArgsBaseSchema = z4.z.object({
|
|
9370
9370
|
searchTypes: z4.z.object({
|
|
@@ -9376,20 +9376,20 @@ var googleSearchToolArgsBaseSchema = z4.z.object({
|
|
|
9376
9376
|
endTime: z4.z.string()
|
|
9377
9377
|
}).optional()
|
|
9378
9378
|
}).passthrough();
|
|
9379
|
-
var googleSearchToolArgsSchema =
|
|
9380
|
-
() =>
|
|
9379
|
+
var googleSearchToolArgsSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
9380
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(googleSearchToolArgsBaseSchema)
|
|
9381
9381
|
);
|
|
9382
|
-
var googleSearch =
|
|
9382
|
+
var googleSearch = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactory({
|
|
9383
9383
|
id: "google.google_search",
|
|
9384
9384
|
name: "google_search",
|
|
9385
9385
|
inputSchema: googleSearchToolArgsSchema
|
|
9386
9386
|
});
|
|
9387
|
-
var urlContext =
|
|
9387
|
+
var urlContext = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactory({
|
|
9388
9388
|
id: "google.url_context",
|
|
9389
9389
|
name: "url_context",
|
|
9390
|
-
inputSchema:
|
|
9390
|
+
inputSchema: chunkHDKQ7SH2_cjs.lazySchema(() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({})))
|
|
9391
9391
|
});
|
|
9392
|
-
var vertexRagStore =
|
|
9392
|
+
var vertexRagStore = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactory({
|
|
9393
9393
|
id: "google.vertex_rag_store",
|
|
9394
9394
|
name: "vertex_rag_store",
|
|
9395
9395
|
inputSchema: z4.z.object({
|
|
@@ -9496,7 +9496,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
9496
9496
|
details: "This model does not support the `seed` option through this provider."
|
|
9497
9497
|
});
|
|
9498
9498
|
}
|
|
9499
|
-
const googleOptions = await
|
|
9499
|
+
const googleOptions = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
9500
9500
|
provider: "google",
|
|
9501
9501
|
providerOptions,
|
|
9502
9502
|
schema: googleImageProviderOptionsSchema
|
|
@@ -9515,12 +9515,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
9515
9515
|
instances: [{ prompt }],
|
|
9516
9516
|
parameters
|
|
9517
9517
|
};
|
|
9518
|
-
const { responseHeaders, value: response } = await
|
|
9518
|
+
const { responseHeaders, value: response } = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
9519
9519
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
9520
|
-
headers:
|
|
9520
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(await chunkHDKQ7SH2_cjs.resolve(this.config.headers), headers),
|
|
9521
9521
|
body,
|
|
9522
9522
|
failedResponseHandler: googleFailedResponseHandler,
|
|
9523
|
-
successfulResponseHandler:
|
|
9523
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
9524
9524
|
googleImageResponseSchema
|
|
9525
9525
|
),
|
|
9526
9526
|
abortSignal,
|
|
@@ -9546,15 +9546,15 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
9546
9546
|
};
|
|
9547
9547
|
}
|
|
9548
9548
|
};
|
|
9549
|
-
var googleImageResponseSchema =
|
|
9550
|
-
() =>
|
|
9549
|
+
var googleImageResponseSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
9550
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
9551
9551
|
z4.z.object({
|
|
9552
9552
|
predictions: z4.z.array(z4.z.object({ bytesBase64Encoded: z4.z.string() })).default([])
|
|
9553
9553
|
})
|
|
9554
9554
|
)
|
|
9555
9555
|
);
|
|
9556
|
-
var googleImageProviderOptionsSchema =
|
|
9557
|
-
() =>
|
|
9556
|
+
var googleImageProviderOptionsSchema = chunkHDKQ7SH2_cjs.lazySchema(
|
|
9557
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
9558
9558
|
z4.z.object({
|
|
9559
9559
|
personGeneration: z4.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
9560
9560
|
aspectRatio: z4.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
@@ -9563,11 +9563,11 @@ var googleImageProviderOptionsSchema = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
9563
9563
|
);
|
|
9564
9564
|
function createGoogleGenerativeAI(options = {}) {
|
|
9565
9565
|
var _a2, _b2;
|
|
9566
|
-
const baseURL = (_a2 =
|
|
9566
|
+
const baseURL = (_a2 = chunkHDKQ7SH2_cjs.withoutTrailingSlash(options.baseURL)) != null ? _a2 : "https://generativelanguage.googleapis.com/v1beta";
|
|
9567
9567
|
const providerName = (_b2 = options.name) != null ? _b2 : "google.generative-ai";
|
|
9568
|
-
const getHeaders = () =>
|
|
9568
|
+
const getHeaders = () => chunkHDKQ7SH2_cjs.withUserAgentSuffix(
|
|
9569
9569
|
{
|
|
9570
|
-
"x-goog-api-key":
|
|
9570
|
+
"x-goog-api-key": chunkHDKQ7SH2_cjs.loadApiKey({
|
|
9571
9571
|
apiKey: options.apiKey,
|
|
9572
9572
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
9573
9573
|
description: "Google Generative AI"
|
|
@@ -9582,7 +9582,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
9582
9582
|
provider: providerName,
|
|
9583
9583
|
baseURL,
|
|
9584
9584
|
headers: getHeaders,
|
|
9585
|
-
generateId: (_a22 = options.generateId) != null ? _a22 :
|
|
9585
|
+
generateId: (_a22 = options.generateId) != null ? _a22 : chunkHDKQ7SH2_cjs.generateId,
|
|
9586
9586
|
supportedUrls: () => ({
|
|
9587
9587
|
"*": [
|
|
9588
9588
|
// Google Generative Language "files" endpoint
|
|
@@ -9641,7 +9641,7 @@ var openaiErrorDataSchema2 = z4.z.object({
|
|
|
9641
9641
|
code: z4.z.union([z4.z.string(), z4.z.number()]).nullish()
|
|
9642
9642
|
})
|
|
9643
9643
|
});
|
|
9644
|
-
var openaiFailedResponseHandler2 =
|
|
9644
|
+
var openaiFailedResponseHandler2 = chunkHDKQ7SH2_cjs.createJsonErrorResponseHandler({
|
|
9645
9645
|
errorSchema: openaiErrorDataSchema2,
|
|
9646
9646
|
errorToMessage: (data) => data.error.message
|
|
9647
9647
|
});
|
|
@@ -9712,14 +9712,14 @@ function convertToOpenAIChatMessages2({
|
|
|
9712
9712
|
return {
|
|
9713
9713
|
type: "image_url",
|
|
9714
9714
|
image_url: {
|
|
9715
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
9715
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunkHDKQ7SH2_cjs.convertToBase64(part.data)}`,
|
|
9716
9716
|
// OpenAI specific extension: image detail
|
|
9717
9717
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
9718
9718
|
}
|
|
9719
9719
|
};
|
|
9720
9720
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
9721
9721
|
if (part.data instanceof URL) {
|
|
9722
|
-
throw new
|
|
9722
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
9723
9723
|
functionality: "audio file parts with URLs"
|
|
9724
9724
|
});
|
|
9725
9725
|
}
|
|
@@ -9728,7 +9728,7 @@ function convertToOpenAIChatMessages2({
|
|
|
9728
9728
|
return {
|
|
9729
9729
|
type: "input_audio",
|
|
9730
9730
|
input_audio: {
|
|
9731
|
-
data:
|
|
9731
|
+
data: chunkHDKQ7SH2_cjs.convertToBase64(part.data),
|
|
9732
9732
|
format: "wav"
|
|
9733
9733
|
}
|
|
9734
9734
|
};
|
|
@@ -9738,20 +9738,20 @@ function convertToOpenAIChatMessages2({
|
|
|
9738
9738
|
return {
|
|
9739
9739
|
type: "input_audio",
|
|
9740
9740
|
input_audio: {
|
|
9741
|
-
data:
|
|
9741
|
+
data: chunkHDKQ7SH2_cjs.convertToBase64(part.data),
|
|
9742
9742
|
format: "mp3"
|
|
9743
9743
|
}
|
|
9744
9744
|
};
|
|
9745
9745
|
}
|
|
9746
9746
|
default: {
|
|
9747
|
-
throw new
|
|
9747
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
9748
9748
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
9749
9749
|
});
|
|
9750
9750
|
}
|
|
9751
9751
|
}
|
|
9752
9752
|
} else if (part.mediaType === "application/pdf") {
|
|
9753
9753
|
if (part.data instanceof URL) {
|
|
9754
|
-
throw new
|
|
9754
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
9755
9755
|
functionality: "PDF file parts with URLs"
|
|
9756
9756
|
});
|
|
9757
9757
|
}
|
|
@@ -9759,11 +9759,11 @@ function convertToOpenAIChatMessages2({
|
|
|
9759
9759
|
type: "file",
|
|
9760
9760
|
file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
9761
9761
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
9762
|
-
file_data: `data:application/pdf;base64,${
|
|
9762
|
+
file_data: `data:application/pdf;base64,${chunkHDKQ7SH2_cjs.convertToBase64(part.data)}`
|
|
9763
9763
|
}
|
|
9764
9764
|
};
|
|
9765
9765
|
} else {
|
|
9766
|
-
throw new
|
|
9766
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
9767
9767
|
functionality: `file part media type ${part.mediaType}`
|
|
9768
9768
|
});
|
|
9769
9769
|
}
|
|
@@ -9859,8 +9859,8 @@ function mapOpenAIFinishReason3(finishReason) {
|
|
|
9859
9859
|
return "unknown";
|
|
9860
9860
|
}
|
|
9861
9861
|
}
|
|
9862
|
-
var openaiChatResponseSchema2 =
|
|
9863
|
-
() =>
|
|
9862
|
+
var openaiChatResponseSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
9863
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
9864
9864
|
z4.z.object({
|
|
9865
9865
|
id: z4.z.string().nullish(),
|
|
9866
9866
|
created: z4.z.number().nullish(),
|
|
@@ -9926,8 +9926,8 @@ var openaiChatResponseSchema2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
9926
9926
|
})
|
|
9927
9927
|
)
|
|
9928
9928
|
);
|
|
9929
|
-
var openaiChatChunkSchema2 =
|
|
9930
|
-
() =>
|
|
9929
|
+
var openaiChatChunkSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
9930
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
9931
9931
|
z4.z.union([
|
|
9932
9932
|
z4.z.object({
|
|
9933
9933
|
id: z4.z.string().nullish(),
|
|
@@ -9997,8 +9997,8 @@ var openaiChatChunkSchema2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
9997
9997
|
])
|
|
9998
9998
|
)
|
|
9999
9999
|
);
|
|
10000
|
-
var openaiChatLanguageModelOptions2 =
|
|
10001
|
-
() =>
|
|
10000
|
+
var openaiChatLanguageModelOptions2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
10001
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
10002
10002
|
z4.z.object({
|
|
10003
10003
|
/**
|
|
10004
10004
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
@@ -10151,7 +10151,7 @@ function prepareChatTools2({
|
|
|
10151
10151
|
};
|
|
10152
10152
|
default: {
|
|
10153
10153
|
const _exhaustiveCheck = type;
|
|
10154
|
-
throw new
|
|
10154
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
10155
10155
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
10156
10156
|
});
|
|
10157
10157
|
}
|
|
@@ -10186,7 +10186,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10186
10186
|
}) {
|
|
10187
10187
|
var _a2, _b2, _c, _d;
|
|
10188
10188
|
const warnings = [];
|
|
10189
|
-
const openaiOptions = (_a2 = await
|
|
10189
|
+
const openaiOptions = (_a2 = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
10190
10190
|
provider: "openai",
|
|
10191
10191
|
providerOptions,
|
|
10192
10192
|
schema: openaiChatLanguageModelOptions2
|
|
@@ -10369,15 +10369,15 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10369
10369
|
responseHeaders,
|
|
10370
10370
|
value: response,
|
|
10371
10371
|
rawValue: rawResponse
|
|
10372
|
-
} = await
|
|
10372
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
10373
10373
|
url: this.config.url({
|
|
10374
10374
|
path: "/chat/completions",
|
|
10375
10375
|
modelId: this.modelId
|
|
10376
10376
|
}),
|
|
10377
|
-
headers:
|
|
10377
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
10378
10378
|
body,
|
|
10379
10379
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
10380
|
-
successfulResponseHandler:
|
|
10380
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
10381
10381
|
openaiChatResponseSchema2
|
|
10382
10382
|
),
|
|
10383
10383
|
abortSignal: options.abortSignal,
|
|
@@ -10392,7 +10392,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10392
10392
|
for (const toolCall of (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
|
|
10393
10393
|
content.push({
|
|
10394
10394
|
type: "tool-call",
|
|
10395
|
-
toolCallId: (_b2 = toolCall.id) != null ? _b2 :
|
|
10395
|
+
toolCallId: (_b2 = toolCall.id) != null ? _b2 : chunkHDKQ7SH2_cjs.generateId(),
|
|
10396
10396
|
toolName: toolCall.function.name,
|
|
10397
10397
|
input: toolCall.function.arguments
|
|
10398
10398
|
});
|
|
@@ -10401,7 +10401,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10401
10401
|
content.push({
|
|
10402
10402
|
type: "source",
|
|
10403
10403
|
sourceType: "url",
|
|
10404
|
-
id:
|
|
10404
|
+
id: chunkHDKQ7SH2_cjs.generateId(),
|
|
10405
10405
|
url: annotation.url_citation.url,
|
|
10406
10406
|
title: annotation.url_citation.title
|
|
10407
10407
|
});
|
|
@@ -10447,15 +10447,15 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10447
10447
|
include_usage: true
|
|
10448
10448
|
}
|
|
10449
10449
|
};
|
|
10450
|
-
const { responseHeaders, value: response } = await
|
|
10450
|
+
const { responseHeaders, value: response } = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
10451
10451
|
url: this.config.url({
|
|
10452
10452
|
path: "/chat/completions",
|
|
10453
10453
|
modelId: this.modelId
|
|
10454
10454
|
}),
|
|
10455
|
-
headers:
|
|
10455
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
10456
10456
|
body,
|
|
10457
10457
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
10458
|
-
successfulResponseHandler:
|
|
10458
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createEventSourceResponseHandler(
|
|
10459
10459
|
openaiChatChunkSchema2
|
|
10460
10460
|
),
|
|
10461
10461
|
abortSignal: options.abortSignal,
|
|
@@ -10543,19 +10543,19 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10543
10543
|
const index = toolCallDelta.index;
|
|
10544
10544
|
if (toolCalls[index] == null) {
|
|
10545
10545
|
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
10546
|
-
throw new
|
|
10546
|
+
throw new chunkHDKQ7SH2_cjs.InvalidResponseDataError({
|
|
10547
10547
|
data: toolCallDelta,
|
|
10548
10548
|
message: `Expected 'function' type.`
|
|
10549
10549
|
});
|
|
10550
10550
|
}
|
|
10551
10551
|
if (toolCallDelta.id == null) {
|
|
10552
|
-
throw new
|
|
10552
|
+
throw new chunkHDKQ7SH2_cjs.InvalidResponseDataError({
|
|
10553
10553
|
data: toolCallDelta,
|
|
10554
10554
|
message: `Expected 'id' to be a string.`
|
|
10555
10555
|
});
|
|
10556
10556
|
}
|
|
10557
10557
|
if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
|
|
10558
|
-
throw new
|
|
10558
|
+
throw new chunkHDKQ7SH2_cjs.InvalidResponseDataError({
|
|
10559
10559
|
data: toolCallDelta,
|
|
10560
10560
|
message: `Expected 'function.name' to be a string.`
|
|
10561
10561
|
});
|
|
@@ -10583,14 +10583,14 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10583
10583
|
delta: toolCall2.function.arguments
|
|
10584
10584
|
});
|
|
10585
10585
|
}
|
|
10586
|
-
if (
|
|
10586
|
+
if (chunkHDKQ7SH2_cjs.isParsableJson(toolCall2.function.arguments)) {
|
|
10587
10587
|
controller.enqueue({
|
|
10588
10588
|
type: "tool-input-end",
|
|
10589
10589
|
id: toolCall2.id
|
|
10590
10590
|
});
|
|
10591
10591
|
controller.enqueue({
|
|
10592
10592
|
type: "tool-call",
|
|
10593
|
-
toolCallId: (_q = toolCall2.id) != null ? _q :
|
|
10593
|
+
toolCallId: (_q = toolCall2.id) != null ? _q : chunkHDKQ7SH2_cjs.generateId(),
|
|
10594
10594
|
toolName: toolCall2.function.name,
|
|
10595
10595
|
input: toolCall2.function.arguments
|
|
10596
10596
|
});
|
|
@@ -10611,14 +10611,14 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10611
10611
|
id: toolCall.id,
|
|
10612
10612
|
delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
|
|
10613
10613
|
});
|
|
10614
|
-
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null &&
|
|
10614
|
+
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && chunkHDKQ7SH2_cjs.isParsableJson(toolCall.function.arguments)) {
|
|
10615
10615
|
controller.enqueue({
|
|
10616
10616
|
type: "tool-input-end",
|
|
10617
10617
|
id: toolCall.id
|
|
10618
10618
|
});
|
|
10619
10619
|
controller.enqueue({
|
|
10620
10620
|
type: "tool-call",
|
|
10621
|
-
toolCallId: (_x = toolCall.id) != null ? _x :
|
|
10621
|
+
toolCallId: (_x = toolCall.id) != null ? _x : chunkHDKQ7SH2_cjs.generateId(),
|
|
10622
10622
|
toolName: toolCall.function.name,
|
|
10623
10623
|
input: toolCall.function.arguments
|
|
10624
10624
|
});
|
|
@@ -10631,7 +10631,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
10631
10631
|
controller.enqueue({
|
|
10632
10632
|
type: "source",
|
|
10633
10633
|
sourceType: "url",
|
|
10634
|
-
id:
|
|
10634
|
+
id: chunkHDKQ7SH2_cjs.generateId(),
|
|
10635
10635
|
url: annotation.url_citation.url,
|
|
10636
10636
|
title: annotation.url_citation.title
|
|
10637
10637
|
});
|
|
@@ -10671,7 +10671,7 @@ function convertToOpenAICompletionPrompt2({
|
|
|
10671
10671
|
for (const { role, content } of prompt) {
|
|
10672
10672
|
switch (role) {
|
|
10673
10673
|
case "system": {
|
|
10674
|
-
throw new
|
|
10674
|
+
throw new chunkHDKQ7SH2_cjs.InvalidPromptError({
|
|
10675
10675
|
message: "Unexpected system message in prompt: ${content}",
|
|
10676
10676
|
prompt
|
|
10677
10677
|
});
|
|
@@ -10697,7 +10697,7 @@ ${userMessage}
|
|
|
10697
10697
|
return part.text;
|
|
10698
10698
|
}
|
|
10699
10699
|
case "tool-call": {
|
|
10700
|
-
throw new
|
|
10700
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
10701
10701
|
functionality: "tool-call messages"
|
|
10702
10702
|
});
|
|
10703
10703
|
}
|
|
@@ -10710,7 +10710,7 @@ ${assistantMessage}
|
|
|
10710
10710
|
break;
|
|
10711
10711
|
}
|
|
10712
10712
|
case "tool": {
|
|
10713
|
-
throw new
|
|
10713
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
10714
10714
|
functionality: "tool messages"
|
|
10715
10715
|
});
|
|
10716
10716
|
}
|
|
@@ -10754,8 +10754,8 @@ function mapOpenAIFinishReason22(finishReason) {
|
|
|
10754
10754
|
return "unknown";
|
|
10755
10755
|
}
|
|
10756
10756
|
}
|
|
10757
|
-
var openaiCompletionResponseSchema2 =
|
|
10758
|
-
() =>
|
|
10757
|
+
var openaiCompletionResponseSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
10758
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
10759
10759
|
z4.z.object({
|
|
10760
10760
|
id: z4.z.string().nullish(),
|
|
10761
10761
|
created: z4.z.number().nullish(),
|
|
@@ -10779,8 +10779,8 @@ var openaiCompletionResponseSchema2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
10779
10779
|
})
|
|
10780
10780
|
)
|
|
10781
10781
|
);
|
|
10782
|
-
var openaiCompletionChunkSchema2 =
|
|
10783
|
-
() =>
|
|
10782
|
+
var openaiCompletionChunkSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
10783
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
10784
10784
|
z4.z.union([
|
|
10785
10785
|
z4.z.object({
|
|
10786
10786
|
id: z4.z.string().nullish(),
|
|
@@ -10808,8 +10808,8 @@ var openaiCompletionChunkSchema2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
10808
10808
|
])
|
|
10809
10809
|
)
|
|
10810
10810
|
);
|
|
10811
|
-
var openaiCompletionProviderOptions2 =
|
|
10812
|
-
() =>
|
|
10811
|
+
var openaiCompletionProviderOptions2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
10812
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
10813
10813
|
z4.z.object({
|
|
10814
10814
|
/**
|
|
10815
10815
|
Echo back the prompt in addition to the completion.
|
|
@@ -10884,12 +10884,12 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
10884
10884
|
}) {
|
|
10885
10885
|
const warnings = [];
|
|
10886
10886
|
const openaiOptions = {
|
|
10887
|
-
...await
|
|
10887
|
+
...await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
10888
10888
|
provider: "openai",
|
|
10889
10889
|
providerOptions,
|
|
10890
10890
|
schema: openaiCompletionProviderOptions2
|
|
10891
10891
|
}),
|
|
10892
|
-
...await
|
|
10892
|
+
...await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
10893
10893
|
provider: this.providerOptionsName,
|
|
10894
10894
|
providerOptions,
|
|
10895
10895
|
schema: openaiCompletionProviderOptions2
|
|
@@ -10945,15 +10945,15 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
10945
10945
|
responseHeaders,
|
|
10946
10946
|
value: response,
|
|
10947
10947
|
rawValue: rawResponse
|
|
10948
|
-
} = await
|
|
10948
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
10949
10949
|
url: this.config.url({
|
|
10950
10950
|
path: "/completions",
|
|
10951
10951
|
modelId: this.modelId
|
|
10952
10952
|
}),
|
|
10953
|
-
headers:
|
|
10953
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
10954
10954
|
body: args,
|
|
10955
10955
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
10956
|
-
successfulResponseHandler:
|
|
10956
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
10957
10957
|
openaiCompletionResponseSchema2
|
|
10958
10958
|
),
|
|
10959
10959
|
abortSignal: options.abortSignal,
|
|
@@ -10991,15 +10991,15 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
10991
10991
|
include_usage: true
|
|
10992
10992
|
}
|
|
10993
10993
|
};
|
|
10994
|
-
const { responseHeaders, value: response } = await
|
|
10994
|
+
const { responseHeaders, value: response } = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
10995
10995
|
url: this.config.url({
|
|
10996
10996
|
path: "/completions",
|
|
10997
10997
|
modelId: this.modelId
|
|
10998
10998
|
}),
|
|
10999
|
-
headers:
|
|
10999
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
11000
11000
|
body,
|
|
11001
11001
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
11002
|
-
successfulResponseHandler:
|
|
11002
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createEventSourceResponseHandler(
|
|
11003
11003
|
openaiCompletionChunkSchema2
|
|
11004
11004
|
),
|
|
11005
11005
|
abortSignal: options.abortSignal,
|
|
@@ -11080,8 +11080,8 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
11080
11080
|
};
|
|
11081
11081
|
}
|
|
11082
11082
|
};
|
|
11083
|
-
var openaiEmbeddingProviderOptions2 =
|
|
11084
|
-
() =>
|
|
11083
|
+
var openaiEmbeddingProviderOptions2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
11084
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11085
11085
|
z4.z.object({
|
|
11086
11086
|
/**
|
|
11087
11087
|
The number of dimensions the resulting output embeddings should have.
|
|
@@ -11096,8 +11096,8 @@ var openaiEmbeddingProviderOptions2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
11096
11096
|
})
|
|
11097
11097
|
)
|
|
11098
11098
|
);
|
|
11099
|
-
var openaiTextEmbeddingResponseSchema2 =
|
|
11100
|
-
() =>
|
|
11099
|
+
var openaiTextEmbeddingResponseSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
11100
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11101
11101
|
z4.z.object({
|
|
11102
11102
|
data: z4.z.array(z4.z.object({ embedding: z4.z.array(z4.z.number()) })),
|
|
11103
11103
|
usage: z4.z.object({ prompt_tokens: z4.z.number() }).nullish()
|
|
@@ -11123,14 +11123,14 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11123
11123
|
}) {
|
|
11124
11124
|
var _a2;
|
|
11125
11125
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
11126
|
-
throw new
|
|
11126
|
+
throw new chunkHDKQ7SH2_cjs.TooManyEmbeddingValuesForCallError({
|
|
11127
11127
|
provider: this.provider,
|
|
11128
11128
|
modelId: this.modelId,
|
|
11129
11129
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
11130
11130
|
values
|
|
11131
11131
|
});
|
|
11132
11132
|
}
|
|
11133
|
-
const openaiOptions = (_a2 = await
|
|
11133
|
+
const openaiOptions = (_a2 = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
11134
11134
|
provider: "openai",
|
|
11135
11135
|
providerOptions,
|
|
11136
11136
|
schema: openaiEmbeddingProviderOptions2
|
|
@@ -11139,12 +11139,12 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11139
11139
|
responseHeaders,
|
|
11140
11140
|
value: response,
|
|
11141
11141
|
rawValue
|
|
11142
|
-
} = await
|
|
11142
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
11143
11143
|
url: this.config.url({
|
|
11144
11144
|
path: "/embeddings",
|
|
11145
11145
|
modelId: this.modelId
|
|
11146
11146
|
}),
|
|
11147
|
-
headers:
|
|
11147
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), headers),
|
|
11148
11148
|
body: {
|
|
11149
11149
|
model: this.modelId,
|
|
11150
11150
|
input: values,
|
|
@@ -11153,7 +11153,7 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11153
11153
|
user: openaiOptions.user
|
|
11154
11154
|
},
|
|
11155
11155
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
11156
|
-
successfulResponseHandler:
|
|
11156
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
11157
11157
|
openaiTextEmbeddingResponseSchema2
|
|
11158
11158
|
),
|
|
11159
11159
|
abortSignal,
|
|
@@ -11166,8 +11166,8 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
11166
11166
|
};
|
|
11167
11167
|
}
|
|
11168
11168
|
};
|
|
11169
|
-
var openaiImageResponseSchema2 =
|
|
11170
|
-
() =>
|
|
11169
|
+
var openaiImageResponseSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
11170
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11171
11171
|
z4.z.object({
|
|
11172
11172
|
created: z4.z.number().nullish(),
|
|
11173
11173
|
data: z4.z.array(
|
|
@@ -11240,12 +11240,12 @@ var OpenAIImageModel2 = class {
|
|
|
11240
11240
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
11241
11241
|
}
|
|
11242
11242
|
const currentDate = (_c = (_b2 = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b2.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
|
|
11243
|
-
const { value: response, responseHeaders } = await
|
|
11243
|
+
const { value: response, responseHeaders } = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
11244
11244
|
url: this.config.url({
|
|
11245
11245
|
path: "/images/generations",
|
|
11246
11246
|
modelId: this.modelId
|
|
11247
11247
|
}),
|
|
11248
|
-
headers:
|
|
11248
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), headers),
|
|
11249
11249
|
body: {
|
|
11250
11250
|
model: this.modelId,
|
|
11251
11251
|
prompt,
|
|
@@ -11255,7 +11255,7 @@ var OpenAIImageModel2 = class {
|
|
|
11255
11255
|
...!hasDefaultResponseFormat2.has(this.modelId) ? { response_format: "b64_json" } : {}
|
|
11256
11256
|
},
|
|
11257
11257
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
11258
|
-
successfulResponseHandler:
|
|
11258
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
11259
11259
|
openaiImageResponseSchema2
|
|
11260
11260
|
),
|
|
11261
11261
|
abortSignal,
|
|
@@ -11317,16 +11317,16 @@ function distributeTokenDetails2(usage, index, total) {
|
|
|
11317
11317
|
}
|
|
11318
11318
|
return result;
|
|
11319
11319
|
}
|
|
11320
|
-
var codeInterpreterInputSchema2 =
|
|
11321
|
-
() =>
|
|
11320
|
+
var codeInterpreterInputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11321
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11322
11322
|
z4.z.object({
|
|
11323
11323
|
code: z4.z.string().nullish(),
|
|
11324
11324
|
containerId: z4.z.string()
|
|
11325
11325
|
})
|
|
11326
11326
|
)
|
|
11327
11327
|
);
|
|
11328
|
-
var codeInterpreterOutputSchema2 =
|
|
11329
|
-
() =>
|
|
11328
|
+
var codeInterpreterOutputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11329
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11330
11330
|
z4.z.object({
|
|
11331
11331
|
outputs: z4.z.array(
|
|
11332
11332
|
z4.z.discriminatedUnion("type", [
|
|
@@ -11337,8 +11337,8 @@ var codeInterpreterOutputSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11337
11337
|
})
|
|
11338
11338
|
)
|
|
11339
11339
|
);
|
|
11340
|
-
var codeInterpreterArgsSchema2 =
|
|
11341
|
-
() =>
|
|
11340
|
+
var codeInterpreterArgsSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11341
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11342
11342
|
z4.z.object({
|
|
11343
11343
|
container: z4.z.union([
|
|
11344
11344
|
z4.z.string(),
|
|
@@ -11349,7 +11349,7 @@ var codeInterpreterArgsSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11349
11349
|
})
|
|
11350
11350
|
)
|
|
11351
11351
|
);
|
|
11352
|
-
var codeInterpreterToolFactory2 =
|
|
11352
|
+
var codeInterpreterToolFactory2 = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11353
11353
|
id: "openai.code_interpreter",
|
|
11354
11354
|
name: "code_interpreter",
|
|
11355
11355
|
inputSchema: codeInterpreterInputSchema2,
|
|
@@ -11369,8 +11369,8 @@ var compoundFilterSchema2 = z4.z.object({
|
|
|
11369
11369
|
z4.z.union([comparisonFilterSchema2, z4.z.lazy(() => compoundFilterSchema2)])
|
|
11370
11370
|
)
|
|
11371
11371
|
});
|
|
11372
|
-
var fileSearchArgsSchema3 =
|
|
11373
|
-
() =>
|
|
11372
|
+
var fileSearchArgsSchema3 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11373
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11374
11374
|
z4.z.object({
|
|
11375
11375
|
vectorStoreIds: z4.z.array(z4.z.string()),
|
|
11376
11376
|
maxNumResults: z4.z.number().optional(),
|
|
@@ -11382,8 +11382,8 @@ var fileSearchArgsSchema3 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11382
11382
|
})
|
|
11383
11383
|
)
|
|
11384
11384
|
);
|
|
11385
|
-
var fileSearchOutputSchema2 =
|
|
11386
|
-
() =>
|
|
11385
|
+
var fileSearchOutputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11386
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11387
11387
|
z4.z.object({
|
|
11388
11388
|
queries: z4.z.array(z4.z.string()),
|
|
11389
11389
|
results: z4.z.array(
|
|
@@ -11398,14 +11398,14 @@ var fileSearchOutputSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11398
11398
|
})
|
|
11399
11399
|
)
|
|
11400
11400
|
);
|
|
11401
|
-
var fileSearch3 =
|
|
11401
|
+
var fileSearch3 = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11402
11402
|
id: "openai.file_search",
|
|
11403
11403
|
name: "file_search",
|
|
11404
11404
|
inputSchema: z4.z.object({}),
|
|
11405
11405
|
outputSchema: fileSearchOutputSchema2
|
|
11406
11406
|
});
|
|
11407
|
-
var imageGenerationArgsSchema2 =
|
|
11408
|
-
() =>
|
|
11407
|
+
var imageGenerationArgsSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11408
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11409
11409
|
z4.z.object({
|
|
11410
11410
|
background: z4.z.enum(["auto", "opaque", "transparent"]).optional(),
|
|
11411
11411
|
inputFidelity: z4.z.enum(["low", "high"]).optional(),
|
|
@@ -11423,11 +11423,11 @@ var imageGenerationArgsSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11423
11423
|
}).strict()
|
|
11424
11424
|
)
|
|
11425
11425
|
);
|
|
11426
|
-
var imageGenerationInputSchema2 =
|
|
11427
|
-
var imageGenerationOutputSchema2 =
|
|
11428
|
-
() =>
|
|
11426
|
+
var imageGenerationInputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({})));
|
|
11427
|
+
var imageGenerationOutputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11428
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({ result: z4.z.string() }))
|
|
11429
11429
|
);
|
|
11430
|
-
var imageGenerationToolFactory2 =
|
|
11430
|
+
var imageGenerationToolFactory2 = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11431
11431
|
id: "openai.image_generation",
|
|
11432
11432
|
name: "image_generation",
|
|
11433
11433
|
inputSchema: imageGenerationInputSchema2,
|
|
@@ -11436,8 +11436,8 @@ var imageGenerationToolFactory2 = chunk5TD3NIQP_cjs.createProviderDefinedToolFac
|
|
|
11436
11436
|
var imageGeneration2 = (args = {}) => {
|
|
11437
11437
|
return imageGenerationToolFactory2(args);
|
|
11438
11438
|
};
|
|
11439
|
-
var localShellInputSchema2 =
|
|
11440
|
-
() =>
|
|
11439
|
+
var localShellInputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11440
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11441
11441
|
z4.z.object({
|
|
11442
11442
|
action: z4.z.object({
|
|
11443
11443
|
type: z4.z.literal("exec"),
|
|
@@ -11450,17 +11450,17 @@ var localShellInputSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11450
11450
|
})
|
|
11451
11451
|
)
|
|
11452
11452
|
);
|
|
11453
|
-
var localShellOutputSchema2 =
|
|
11454
|
-
() =>
|
|
11453
|
+
var localShellOutputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11454
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({ output: z4.z.string() }))
|
|
11455
11455
|
);
|
|
11456
|
-
var localShell2 =
|
|
11456
|
+
var localShell2 = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11457
11457
|
id: "openai.local_shell",
|
|
11458
11458
|
name: "local_shell",
|
|
11459
11459
|
inputSchema: localShellInputSchema2,
|
|
11460
11460
|
outputSchema: localShellOutputSchema2
|
|
11461
11461
|
});
|
|
11462
|
-
var webSearchArgsSchema2 =
|
|
11463
|
-
() =>
|
|
11462
|
+
var webSearchArgsSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11463
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11464
11464
|
z4.z.object({
|
|
11465
11465
|
externalWebAccess: z4.z.boolean().optional(),
|
|
11466
11466
|
filters: z4.z.object({ allowedDomains: z4.z.array(z4.z.string()).optional() }).optional(),
|
|
@@ -11475,9 +11475,9 @@ var webSearchArgsSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11475
11475
|
})
|
|
11476
11476
|
)
|
|
11477
11477
|
);
|
|
11478
|
-
var webSearchInputSchema2 =
|
|
11479
|
-
var webSearchOutputSchema2 =
|
|
11480
|
-
() =>
|
|
11478
|
+
var webSearchInputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({})));
|
|
11479
|
+
var webSearchOutputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11480
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11481
11481
|
z4.z.object({
|
|
11482
11482
|
action: z4.z.discriminatedUnion("type", [
|
|
11483
11483
|
z4.z.object({
|
|
@@ -11503,15 +11503,15 @@ var webSearchOutputSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11503
11503
|
})
|
|
11504
11504
|
)
|
|
11505
11505
|
);
|
|
11506
|
-
var webSearchToolFactory2 =
|
|
11506
|
+
var webSearchToolFactory2 = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11507
11507
|
id: "openai.web_search",
|
|
11508
11508
|
name: "web_search",
|
|
11509
11509
|
inputSchema: webSearchInputSchema2,
|
|
11510
11510
|
outputSchema: webSearchOutputSchema2
|
|
11511
11511
|
});
|
|
11512
11512
|
var webSearch = (args = {}) => webSearchToolFactory2(args);
|
|
11513
|
-
var webSearchPreviewArgsSchema2 =
|
|
11514
|
-
() =>
|
|
11513
|
+
var webSearchPreviewArgsSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11514
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11515
11515
|
z4.z.object({
|
|
11516
11516
|
searchContextSize: z4.z.enum(["low", "medium", "high"]).optional(),
|
|
11517
11517
|
userLocation: z4.z.object({
|
|
@@ -11524,11 +11524,11 @@ var webSearchPreviewArgsSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11524
11524
|
})
|
|
11525
11525
|
)
|
|
11526
11526
|
);
|
|
11527
|
-
var webSearchPreviewInputSchema2 =
|
|
11528
|
-
() =>
|
|
11527
|
+
var webSearchPreviewInputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11528
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(z4.z.object({}))
|
|
11529
11529
|
);
|
|
11530
|
-
var webSearchPreviewOutputSchema2 =
|
|
11531
|
-
() =>
|
|
11530
|
+
var webSearchPreviewOutputSchema2 = chunkHDKQ7SH2_cjs.lazySchema(
|
|
11531
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11532
11532
|
z4.z.object({
|
|
11533
11533
|
action: z4.z.discriminatedUnion("type", [
|
|
11534
11534
|
z4.z.object({
|
|
@@ -11548,7 +11548,7 @@ var webSearchPreviewOutputSchema2 = chunk5TD3NIQP_cjs.lazySchema(
|
|
|
11548
11548
|
})
|
|
11549
11549
|
)
|
|
11550
11550
|
);
|
|
11551
|
-
var webSearchPreview2 =
|
|
11551
|
+
var webSearchPreview2 = chunkHDKQ7SH2_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
11552
11552
|
id: "openai.web_search_preview",
|
|
11553
11553
|
name: "web_search_preview",
|
|
11554
11554
|
inputSchema: webSearchPreviewInputSchema2,
|
|
@@ -11682,7 +11682,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11682
11682
|
return {
|
|
11683
11683
|
type: "input_image",
|
|
11684
11684
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId2(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
11685
|
-
image_url: `data:${mediaType};base64,${
|
|
11685
|
+
image_url: `data:${mediaType};base64,${chunkHDKQ7SH2_cjs.convertToBase64(part.data)}`
|
|
11686
11686
|
},
|
|
11687
11687
|
detail: (_b22 = (_a22 = part.providerOptions) == null ? void 0 : _a22.openai) == null ? void 0 : _b22.imageDetail
|
|
11688
11688
|
};
|
|
@@ -11697,11 +11697,11 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11697
11697
|
type: "input_file",
|
|
11698
11698
|
...typeof part.data === "string" && isFileId2(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
11699
11699
|
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
11700
|
-
file_data: `data:application/pdf;base64,${
|
|
11700
|
+
file_data: `data:application/pdf;base64,${chunkHDKQ7SH2_cjs.convertToBase64(part.data)}`
|
|
11701
11701
|
}
|
|
11702
11702
|
};
|
|
11703
11703
|
} else {
|
|
11704
|
-
throw new
|
|
11704
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
11705
11705
|
functionality: `file part media type ${part.mediaType}`
|
|
11706
11706
|
});
|
|
11707
11707
|
}
|
|
@@ -11740,7 +11740,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11740
11740
|
break;
|
|
11741
11741
|
}
|
|
11742
11742
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
11743
|
-
const parsedInput = await
|
|
11743
|
+
const parsedInput = await chunkHDKQ7SH2_cjs.validateTypes({
|
|
11744
11744
|
value: part.input,
|
|
11745
11745
|
schema: localShellInputSchema2
|
|
11746
11746
|
});
|
|
@@ -11781,7 +11781,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11781
11781
|
break;
|
|
11782
11782
|
}
|
|
11783
11783
|
case "reasoning": {
|
|
11784
|
-
const providerOptions = await
|
|
11784
|
+
const providerOptions = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
11785
11785
|
provider: "openai",
|
|
11786
11786
|
providerOptions: part.providerOptions,
|
|
11787
11787
|
schema: openaiResponsesReasoningProviderOptionsSchema2
|
|
@@ -11842,7 +11842,7 @@ async function convertToOpenAIResponsesInput2({
|
|
|
11842
11842
|
for (const part of content) {
|
|
11843
11843
|
const output = part.output;
|
|
11844
11844
|
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
11845
|
-
const parsedOutput = await
|
|
11845
|
+
const parsedOutput = await chunkHDKQ7SH2_cjs.validateTypes({
|
|
11846
11846
|
value: output.value,
|
|
11847
11847
|
schema: localShellOutputSchema2
|
|
11848
11848
|
});
|
|
@@ -11930,8 +11930,8 @@ function mapOpenAIResponseFinishReason2({
|
|
|
11930
11930
|
return hasFunctionCall ? "tool-calls" : "unknown";
|
|
11931
11931
|
}
|
|
11932
11932
|
}
|
|
11933
|
-
var openaiResponsesChunkSchema2 =
|
|
11934
|
-
() =>
|
|
11933
|
+
var openaiResponsesChunkSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
11934
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
11935
11935
|
z4.z.union([
|
|
11936
11936
|
z4.z.object({
|
|
11937
11937
|
type: z4.z.literal("response.output_text.delta"),
|
|
@@ -12204,8 +12204,8 @@ var openaiResponsesChunkSchema2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
12204
12204
|
])
|
|
12205
12205
|
)
|
|
12206
12206
|
);
|
|
12207
|
-
var openaiResponsesResponseSchema2 =
|
|
12208
|
-
() =>
|
|
12207
|
+
var openaiResponsesResponseSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
12208
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
12209
12209
|
z4.z.object({
|
|
12210
12210
|
id: z4.z.string().optional(),
|
|
12211
12211
|
created_at: z4.z.number().optional(),
|
|
@@ -12389,8 +12389,8 @@ var openaiResponsesResponseSchema2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
12389
12389
|
)
|
|
12390
12390
|
);
|
|
12391
12391
|
var TOP_LOGPROBS_MAX2 = 20;
|
|
12392
|
-
var openaiResponsesProviderOptionsSchema2 =
|
|
12393
|
-
() =>
|
|
12392
|
+
var openaiResponsesProviderOptionsSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
12393
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
12394
12394
|
z4.z.object({
|
|
12395
12395
|
conversation: z4.z.string().nullish(),
|
|
12396
12396
|
include: z4.z.array(
|
|
@@ -12481,7 +12481,7 @@ async function prepareResponsesTools2({
|
|
|
12481
12481
|
case "provider-defined": {
|
|
12482
12482
|
switch (tool2.id) {
|
|
12483
12483
|
case "openai.file_search": {
|
|
12484
|
-
const args = await
|
|
12484
|
+
const args = await chunkHDKQ7SH2_cjs.validateTypes({
|
|
12485
12485
|
value: tool2.args,
|
|
12486
12486
|
schema: fileSearchArgsSchema3
|
|
12487
12487
|
});
|
|
@@ -12504,7 +12504,7 @@ async function prepareResponsesTools2({
|
|
|
12504
12504
|
break;
|
|
12505
12505
|
}
|
|
12506
12506
|
case "openai.web_search_preview": {
|
|
12507
|
-
const args = await
|
|
12507
|
+
const args = await chunkHDKQ7SH2_cjs.validateTypes({
|
|
12508
12508
|
value: tool2.args,
|
|
12509
12509
|
schema: webSearchPreviewArgsSchema2
|
|
12510
12510
|
});
|
|
@@ -12516,7 +12516,7 @@ async function prepareResponsesTools2({
|
|
|
12516
12516
|
break;
|
|
12517
12517
|
}
|
|
12518
12518
|
case "openai.web_search": {
|
|
12519
|
-
const args = await
|
|
12519
|
+
const args = await chunkHDKQ7SH2_cjs.validateTypes({
|
|
12520
12520
|
value: tool2.args,
|
|
12521
12521
|
schema: webSearchArgsSchema2
|
|
12522
12522
|
});
|
|
@@ -12530,7 +12530,7 @@ async function prepareResponsesTools2({
|
|
|
12530
12530
|
break;
|
|
12531
12531
|
}
|
|
12532
12532
|
case "openai.code_interpreter": {
|
|
12533
|
-
const args = await
|
|
12533
|
+
const args = await chunkHDKQ7SH2_cjs.validateTypes({
|
|
12534
12534
|
value: tool2.args,
|
|
12535
12535
|
schema: codeInterpreterArgsSchema2
|
|
12536
12536
|
});
|
|
@@ -12541,7 +12541,7 @@ async function prepareResponsesTools2({
|
|
|
12541
12541
|
break;
|
|
12542
12542
|
}
|
|
12543
12543
|
case "openai.image_generation": {
|
|
12544
|
-
const args = await
|
|
12544
|
+
const args = await chunkHDKQ7SH2_cjs.validateTypes({
|
|
12545
12545
|
value: tool2.args,
|
|
12546
12546
|
schema: imageGenerationArgsSchema2
|
|
12547
12547
|
});
|
|
@@ -12587,7 +12587,7 @@ async function prepareResponsesTools2({
|
|
|
12587
12587
|
};
|
|
12588
12588
|
default: {
|
|
12589
12589
|
const _exhaustiveCheck = type;
|
|
12590
|
-
throw new
|
|
12590
|
+
throw new chunkHDKQ7SH2_cjs.UnsupportedFunctionalityError({
|
|
12591
12591
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
12592
12592
|
});
|
|
12593
12593
|
}
|
|
@@ -12645,7 +12645,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12645
12645
|
if (stopSequences != null) {
|
|
12646
12646
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
12647
12647
|
}
|
|
12648
|
-
const openaiOptions = await
|
|
12648
|
+
const openaiOptions = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
12649
12649
|
provider: "openai",
|
|
12650
12650
|
providerOptions,
|
|
12651
12651
|
schema: openaiResponsesProviderOptionsSchema2
|
|
@@ -12833,19 +12833,19 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12833
12833
|
responseHeaders,
|
|
12834
12834
|
value: response,
|
|
12835
12835
|
rawValue: rawResponse
|
|
12836
|
-
} = await
|
|
12836
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
12837
12837
|
url,
|
|
12838
|
-
headers:
|
|
12838
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
12839
12839
|
body,
|
|
12840
12840
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
12841
|
-
successfulResponseHandler:
|
|
12841
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
12842
12842
|
openaiResponsesResponseSchema2
|
|
12843
12843
|
),
|
|
12844
12844
|
abortSignal: options.abortSignal,
|
|
12845
12845
|
fetch: this.config.fetch
|
|
12846
12846
|
});
|
|
12847
12847
|
if (response.error) {
|
|
12848
|
-
throw new
|
|
12848
|
+
throw new chunkHDKQ7SH2_cjs.APICallError({
|
|
12849
12849
|
message: response.error.message,
|
|
12850
12850
|
url,
|
|
12851
12851
|
requestBodyValues: body,
|
|
@@ -12933,7 +12933,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12933
12933
|
content.push({
|
|
12934
12934
|
type: "source",
|
|
12935
12935
|
sourceType: "url",
|
|
12936
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f :
|
|
12936
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : chunkHDKQ7SH2_cjs.generateId(),
|
|
12937
12937
|
url: annotation.url,
|
|
12938
12938
|
title: annotation.title
|
|
12939
12939
|
});
|
|
@@ -12941,7 +12941,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12941
12941
|
content.push({
|
|
12942
12942
|
type: "source",
|
|
12943
12943
|
sourceType: "document",
|
|
12944
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i :
|
|
12944
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : chunkHDKQ7SH2_cjs.generateId(),
|
|
12945
12945
|
mediaType: "text/plain",
|
|
12946
12946
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
12947
12947
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
@@ -12957,7 +12957,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12957
12957
|
content.push({
|
|
12958
12958
|
type: "source",
|
|
12959
12959
|
sourceType: "document",
|
|
12960
|
-
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o :
|
|
12960
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : chunkHDKQ7SH2_cjs.generateId(),
|
|
12961
12961
|
mediaType: "text/plain",
|
|
12962
12962
|
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
12963
12963
|
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
@@ -12973,7 +12973,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
12973
12973
|
content.push({
|
|
12974
12974
|
type: "source",
|
|
12975
12975
|
sourceType: "document",
|
|
12976
|
-
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u :
|
|
12976
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : chunkHDKQ7SH2_cjs.generateId(),
|
|
12977
12977
|
mediaType: "application/octet-stream",
|
|
12978
12978
|
title: annotation.file_id,
|
|
12979
12979
|
filename: annotation.file_id,
|
|
@@ -13135,18 +13135,18 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13135
13135
|
webSearchToolName,
|
|
13136
13136
|
store
|
|
13137
13137
|
} = await this.getArgs(options);
|
|
13138
|
-
const { responseHeaders, value: response } = await
|
|
13138
|
+
const { responseHeaders, value: response } = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
13139
13139
|
url: this.config.url({
|
|
13140
13140
|
path: "/responses",
|
|
13141
13141
|
modelId: this.modelId
|
|
13142
13142
|
}),
|
|
13143
|
-
headers:
|
|
13143
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
13144
13144
|
body: {
|
|
13145
13145
|
...body,
|
|
13146
13146
|
stream: true
|
|
13147
13147
|
},
|
|
13148
13148
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
13149
|
-
successfulResponseHandler:
|
|
13149
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createEventSourceResponseHandler(
|
|
13150
13150
|
openaiResponsesChunkSchema2
|
|
13151
13151
|
),
|
|
13152
13152
|
abortSignal: options.abortSignal,
|
|
@@ -13574,7 +13574,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13574
13574
|
controller.enqueue({
|
|
13575
13575
|
type: "source",
|
|
13576
13576
|
sourceType: "url",
|
|
13577
|
-
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r :
|
|
13577
|
+
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : chunkHDKQ7SH2_cjs.generateId(),
|
|
13578
13578
|
url: value.annotation.url,
|
|
13579
13579
|
title: value.annotation.title
|
|
13580
13580
|
});
|
|
@@ -13582,7 +13582,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13582
13582
|
controller.enqueue({
|
|
13583
13583
|
type: "source",
|
|
13584
13584
|
sourceType: "document",
|
|
13585
|
-
id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u :
|
|
13585
|
+
id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : chunkHDKQ7SH2_cjs.generateId(),
|
|
13586
13586
|
mediaType: "text/plain",
|
|
13587
13587
|
title: (_w = (_v = value.annotation.quote) != null ? _v : value.annotation.filename) != null ? _w : "Document",
|
|
13588
13588
|
filename: (_x = value.annotation.filename) != null ? _x : value.annotation.file_id,
|
|
@@ -13679,8 +13679,8 @@ function mapWebSearchOutput2(action) {
|
|
|
13679
13679
|
};
|
|
13680
13680
|
}
|
|
13681
13681
|
}
|
|
13682
|
-
var openaiSpeechProviderOptionsSchema2 =
|
|
13683
|
-
() =>
|
|
13682
|
+
var openaiSpeechProviderOptionsSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
13683
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
13684
13684
|
z4.z.object({
|
|
13685
13685
|
instructions: z4.z.string().nullish(),
|
|
13686
13686
|
speed: z4.z.number().min(0.25).max(4).default(1).nullish()
|
|
@@ -13706,7 +13706,7 @@ var OpenAISpeechModel2 = class {
|
|
|
13706
13706
|
providerOptions
|
|
13707
13707
|
}) {
|
|
13708
13708
|
const warnings = [];
|
|
13709
|
-
const openAIOptions = await
|
|
13709
|
+
const openAIOptions = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
13710
13710
|
provider: "openai",
|
|
13711
13711
|
providerOptions,
|
|
13712
13712
|
schema: openaiSpeechProviderOptionsSchema2
|
|
@@ -13759,15 +13759,15 @@ var OpenAISpeechModel2 = class {
|
|
|
13759
13759
|
value: audio,
|
|
13760
13760
|
responseHeaders,
|
|
13761
13761
|
rawValue: rawResponse
|
|
13762
|
-
} = await
|
|
13762
|
+
} = await chunkHDKQ7SH2_cjs.postJsonToApi({
|
|
13763
13763
|
url: this.config.url({
|
|
13764
13764
|
path: "/audio/speech",
|
|
13765
13765
|
modelId: this.modelId
|
|
13766
13766
|
}),
|
|
13767
|
-
headers:
|
|
13767
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
13768
13768
|
body: requestBody,
|
|
13769
13769
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
13770
|
-
successfulResponseHandler:
|
|
13770
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createBinaryResponseHandler(),
|
|
13771
13771
|
abortSignal: options.abortSignal,
|
|
13772
13772
|
fetch: this.config.fetch
|
|
13773
13773
|
});
|
|
@@ -13786,8 +13786,8 @@ var OpenAISpeechModel2 = class {
|
|
|
13786
13786
|
};
|
|
13787
13787
|
}
|
|
13788
13788
|
};
|
|
13789
|
-
var openaiTranscriptionResponseSchema2 =
|
|
13790
|
-
() =>
|
|
13789
|
+
var openaiTranscriptionResponseSchema2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
13790
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
13791
13791
|
z4.z.object({
|
|
13792
13792
|
text: z4.z.string(),
|
|
13793
13793
|
language: z4.z.string().nullish(),
|
|
@@ -13816,8 +13816,8 @@ var openaiTranscriptionResponseSchema2 = chunk5TD3NIQP_cjs.lazyValidator(
|
|
|
13816
13816
|
})
|
|
13817
13817
|
)
|
|
13818
13818
|
);
|
|
13819
|
-
var openAITranscriptionProviderOptions2 =
|
|
13820
|
-
() =>
|
|
13819
|
+
var openAITranscriptionProviderOptions2 = chunkHDKQ7SH2_cjs.lazyValidator(
|
|
13820
|
+
() => chunkHDKQ7SH2_cjs.zodSchema(
|
|
13821
13821
|
z4.z.object({
|
|
13822
13822
|
/**
|
|
13823
13823
|
* Additional information to include in the transcription response.
|
|
@@ -13918,15 +13918,15 @@ var OpenAITranscriptionModel2 = class {
|
|
|
13918
13918
|
providerOptions
|
|
13919
13919
|
}) {
|
|
13920
13920
|
const warnings = [];
|
|
13921
|
-
const openAIOptions = await
|
|
13921
|
+
const openAIOptions = await chunkHDKQ7SH2_cjs.parseProviderOptions({
|
|
13922
13922
|
provider: "openai",
|
|
13923
13923
|
providerOptions,
|
|
13924
13924
|
schema: openAITranscriptionProviderOptions2
|
|
13925
13925
|
});
|
|
13926
13926
|
const formData = new FormData();
|
|
13927
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([
|
|
13927
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([chunkHDKQ7SH2_cjs.convertBase64ToUint8Array(audio)]);
|
|
13928
13928
|
formData.append("model", this.modelId);
|
|
13929
|
-
const fileExtension =
|
|
13929
|
+
const fileExtension = chunkHDKQ7SH2_cjs.mediaTypeToExtension(mediaType);
|
|
13930
13930
|
formData.append(
|
|
13931
13931
|
"file",
|
|
13932
13932
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -13971,15 +13971,15 @@ var OpenAITranscriptionModel2 = class {
|
|
|
13971
13971
|
value: response,
|
|
13972
13972
|
responseHeaders,
|
|
13973
13973
|
rawValue: rawResponse
|
|
13974
|
-
} = await
|
|
13974
|
+
} = await chunkHDKQ7SH2_cjs.postFormDataToApi({
|
|
13975
13975
|
url: this.config.url({
|
|
13976
13976
|
path: "/audio/transcriptions",
|
|
13977
13977
|
modelId: this.modelId
|
|
13978
13978
|
}),
|
|
13979
|
-
headers:
|
|
13979
|
+
headers: chunkHDKQ7SH2_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
13980
13980
|
formData,
|
|
13981
13981
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
13982
|
-
successfulResponseHandler:
|
|
13982
|
+
successfulResponseHandler: chunkHDKQ7SH2_cjs.createJsonResponseHandler(
|
|
13983
13983
|
openaiTranscriptionResponseSchema2
|
|
13984
13984
|
),
|
|
13985
13985
|
abortSignal: options.abortSignal,
|
|
@@ -14012,16 +14012,16 @@ var OpenAITranscriptionModel2 = class {
|
|
|
14012
14012
|
var VERSION4 = "2.0.102" ;
|
|
14013
14013
|
function createOpenAI2(options = {}) {
|
|
14014
14014
|
var _a2, _b2;
|
|
14015
|
-
const baseURL = (_a2 =
|
|
14016
|
-
|
|
14015
|
+
const baseURL = (_a2 = chunkHDKQ7SH2_cjs.withoutTrailingSlash(
|
|
14016
|
+
chunkHDKQ7SH2_cjs.loadOptionalSetting({
|
|
14017
14017
|
settingValue: options.baseURL,
|
|
14018
14018
|
environmentVariableName: "OPENAI_BASE_URL"
|
|
14019
14019
|
})
|
|
14020
14020
|
)) != null ? _a2 : "https://api.openai.com/v1";
|
|
14021
14021
|
const providerName = (_b2 = options.name) != null ? _b2 : "openai";
|
|
14022
|
-
const getHeaders = () =>
|
|
14022
|
+
const getHeaders = () => chunkHDKQ7SH2_cjs.withUserAgentSuffix(
|
|
14023
14023
|
{
|
|
14024
|
-
Authorization: `Bearer ${
|
|
14024
|
+
Authorization: `Bearer ${chunkHDKQ7SH2_cjs.loadApiKey({
|
|
14025
14025
|
apiKey: options.apiKey,
|
|
14026
14026
|
environmentVariableName: "OPENAI_API_KEY",
|
|
14027
14027
|
description: "OpenAI"
|
|
@@ -14181,14 +14181,14 @@ var ModelRouterEmbeddingModel = class {
|
|
|
14181
14181
|
this.modelId = normalizedConfig.modelId;
|
|
14182
14182
|
if (normalizedConfig.url) {
|
|
14183
14183
|
const apiKey = normalizedConfig.apiKey || "";
|
|
14184
|
-
this.providerModel =
|
|
14184
|
+
this.providerModel = chunkHDKQ7SH2_cjs.createOpenAICompatible({
|
|
14185
14185
|
name: normalizedConfig.providerId,
|
|
14186
14186
|
apiKey,
|
|
14187
14187
|
baseURL: normalizedConfig.url,
|
|
14188
14188
|
headers: normalizedConfig.headers
|
|
14189
14189
|
}).textEmbeddingModel(normalizedConfig.modelId);
|
|
14190
14190
|
} else {
|
|
14191
|
-
const registry =
|
|
14191
|
+
const registry = chunkPP3Z4TR3_cjs.GatewayRegistry.getInstance();
|
|
14192
14192
|
const providerConfig = registry.getProviderConfig(normalizedConfig.providerId);
|
|
14193
14193
|
if (!providerConfig) {
|
|
14194
14194
|
throw new Error(`Unknown provider: ${normalizedConfig.providerId}`);
|
|
@@ -14221,7 +14221,7 @@ var ModelRouterEmbeddingModel = class {
|
|
|
14221
14221
|
if (!providerConfig.url) {
|
|
14222
14222
|
throw new Error(`Provider ${normalizedConfig.providerId} does not have a URL configured`);
|
|
14223
14223
|
}
|
|
14224
|
-
this.providerModel =
|
|
14224
|
+
this.providerModel = chunkHDKQ7SH2_cjs.createOpenAICompatible({
|
|
14225
14225
|
name: normalizedConfig.providerId,
|
|
14226
14226
|
apiKey,
|
|
14227
14227
|
baseURL: providerConfig.url
|
|
@@ -14248,5 +14248,5 @@ exports.ModelRouterEmbeddingModel = ModelRouterEmbeddingModel;
|
|
|
14248
14248
|
exports.ModelRouterLanguageModel = ModelRouterLanguageModel;
|
|
14249
14249
|
exports.defaultGateways = defaultGateways;
|
|
14250
14250
|
exports.resolveModelConfig = resolveModelConfig;
|
|
14251
|
-
//# sourceMappingURL=chunk-
|
|
14252
|
-
//# sourceMappingURL=chunk-
|
|
14251
|
+
//# sourceMappingURL=chunk-GNOSEGOW.cjs.map
|
|
14252
|
+
//# sourceMappingURL=chunk-GNOSEGOW.cjs.map
|