@mastra/core 1.28.0-alpha.2 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/channels/index.cjs +4 -4
- package/dist/channels/index.js +1 -1
- package/dist/{chunk-FZMZVECM.cjs → chunk-2ZLG55OF.cjs} +9 -9
- package/dist/{chunk-FZMZVECM.cjs.map → chunk-2ZLG55OF.cjs.map} +1 -1
- package/dist/{chunk-UCKYFOS5.js → chunk-5WTJHNP4.js} +4 -4
- package/dist/{chunk-UCKYFOS5.js.map → chunk-5WTJHNP4.js.map} +1 -1
- package/dist/{chunk-I543JILY.cjs → chunk-AVGHSESJ.cjs} +224 -224
- package/dist/{chunk-I543JILY.cjs.map → chunk-AVGHSESJ.cjs.map} +1 -1
- package/dist/{chunk-Y5NA6WRH.js → chunk-BPT3YHUU.js} +5 -5
- package/dist/{chunk-Y5NA6WRH.js.map → chunk-BPT3YHUU.js.map} +1 -1
- package/dist/{chunk-TZSQJYUS.js → chunk-DE3KHHLV.js} +3 -3
- package/dist/{chunk-TZSQJYUS.js.map → chunk-DE3KHHLV.js.map} +1 -1
- package/dist/{chunk-DBFA5FFU.js → chunk-DPYW3FPY.js} +4 -4
- package/dist/{chunk-DBFA5FFU.js.map → chunk-DPYW3FPY.js.map} +1 -1
- package/dist/{chunk-P3NIJCXP.js → chunk-DUQ3D26E.js} +3 -3
- package/dist/chunk-DUQ3D26E.js.map +1 -0
- package/dist/{chunk-N7CW7X7O.cjs → chunk-FFNSDJOJ.cjs} +57 -57
- package/dist/{chunk-N7CW7X7O.cjs.map → chunk-FFNSDJOJ.cjs.map} +1 -1
- package/dist/{chunk-DMW3LDAI.cjs → chunk-FUY6V2GQ.cjs} +14 -14
- package/dist/{chunk-DMW3LDAI.cjs.map → chunk-FUY6V2GQ.cjs.map} +1 -1
- package/dist/{chunk-SQYHPB7J.js → chunk-G4IXPHSC.js} +6 -6
- package/dist/{chunk-SQYHPB7J.js.map → chunk-G4IXPHSC.js.map} +1 -1
- package/dist/{chunk-LEWSZH4C.cjs → chunk-GCKYB7XS.cjs} +292 -292
- package/dist/{chunk-LEWSZH4C.cjs.map → chunk-GCKYB7XS.cjs.map} +1 -1
- package/dist/{chunk-MROYKU4N.cjs → chunk-GGHNXZKH.cjs} +5 -5
- package/dist/{chunk-MROYKU4N.cjs.map → chunk-GGHNXZKH.cjs.map} +1 -1
- package/dist/{chunk-NPZNOCIW.js → chunk-J7DD4SSC.js} +9 -9
- package/dist/{chunk-NPZNOCIW.js.map → chunk-J7DD4SSC.js.map} +1 -1
- package/dist/{chunk-6BLLC4MN.cjs → chunk-JSOPDGXR.cjs} +17 -17
- package/dist/{chunk-6BLLC4MN.cjs.map → chunk-JSOPDGXR.cjs.map} +1 -1
- package/dist/{chunk-FD4ZS5ZQ.cjs → chunk-MMD73TWG.cjs} +7 -7
- package/dist/{chunk-FD4ZS5ZQ.cjs.map → chunk-MMD73TWG.cjs.map} +1 -1
- package/dist/{chunk-E4RRAOSG.js → chunk-N4RYN7C2.js} +3 -3
- package/dist/{chunk-E4RRAOSG.js.map → chunk-N4RYN7C2.js.map} +1 -1
- package/dist/{chunk-VQFQWMV7.js → chunk-NXLAPKWV.js} +3 -3
- package/dist/{chunk-VQFQWMV7.js.map → chunk-NXLAPKWV.js.map} +1 -1
- package/dist/{chunk-KRYM6L4L.cjs → chunk-OCWTM757.cjs} +3 -3
- package/dist/chunk-OCWTM757.cjs.map +1 -0
- package/dist/{chunk-CHT6QEL4.cjs → chunk-OUPTIIQU.cjs} +20 -20
- package/dist/{chunk-CHT6QEL4.cjs.map → chunk-OUPTIIQU.cjs.map} +1 -1
- package/dist/{chunk-3SZVQUBS.js → chunk-RBWKHHP2.js} +3 -3
- package/dist/{chunk-3SZVQUBS.js.map → chunk-RBWKHHP2.js.map} +1 -1
- package/dist/{chunk-MXEZNKLZ.js → chunk-SMTGW6C5.js} +8 -8
- package/dist/{chunk-MXEZNKLZ.js.map → chunk-SMTGW6C5.js.map} +1 -1
- package/dist/{chunk-2AP476XO.cjs → chunk-VNVKVOCW.cjs} +6 -6
- package/dist/{chunk-2AP476XO.cjs.map → chunk-VNVKVOCW.cjs.map} +1 -1
- package/dist/datasets/index.cjs +11 -11
- package/dist/datasets/index.js +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +131 -131
- package/dist/docs/references/docs-agents-structured-output.md +44 -1
- package/dist/docs/references/docs-agents-using-tools.md +72 -0
- package/dist/docs/references/docs-browser-overview.md +1 -0
- package/dist/docs/references/docs-evals-custom-scorers.md +1 -1
- package/dist/docs/references/docs-evals-datasets-overview.md +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +1 -1
- package/dist/docs/references/docs-server-request-context.md +1 -1
- package/dist/docs/references/docs-workflows-agents-and-tools.md +1 -1
- package/dist/docs/references/docs-workflows-overview.md +105 -4
- package/dist/docs/references/reference-agents-agent.md +1 -1
- package/dist/docs/references/reference-agents-generate.md +1 -1
- package/dist/docs/references/reference-browser-mastra-browser.md +2 -1
- package/dist/docs/references/reference-datasets-create.md +4 -4
- package/dist/docs/references/reference-datasets-update.md +4 -4
- package/dist/docs/references/reference-evals-create-scorer.md +3 -3
- package/dist/docs/references/reference-harness-harness-class.md +1 -1
- package/dist/docs/references/reference-tools-create-tool.md +77 -5
- package/dist/docs/references/reference-workflows-step.md +88 -7
- package/dist/docs/references/reference-workflows-workflow.md +72 -4
- 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/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-P52GX7UZ.cjs +12 -0
- package/dist/{mastra-IMLAZTS5.cjs.map → mastra-P52GX7UZ.cjs.map} +1 -1
- package/dist/mastra-XXFWO6KG.js +3 -0
- package/dist/{mastra-EWMYVECQ.js.map → mastra-XXFWO6KG.js.map} +1 -1
- package/dist/memory/index.cjs +19 -19
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-2X5G2DAS.js +3 -0
- package/dist/{models-dev-3WFCNENU.js.map → models-dev-2X5G2DAS.js.map} +1 -1
- package/dist/models-dev-GPPPUPTJ.cjs +12 -0
- package/dist/{models-dev-LKRGA326.cjs.map → models-dev-GPPPUPTJ.cjs.map} +1 -1
- package/dist/netlify-IXWIB5YM.js +3 -0
- package/dist/{netlify-WQY6BKSQ.js.map → netlify-IXWIB5YM.js.map} +1 -1
- package/dist/netlify-XCVMFKJW.cjs +12 -0
- package/dist/{netlify-SUH6DXO2.cjs.map → netlify-XCVMFKJW.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-IEK7YETD.js +3 -0
- package/dist/{provider-registry-JQC6Y3JI.js.map → provider-registry-IEK7YETD.js.map} +1 -1
- package/dist/provider-registry-ZIFHRDXN.cjs +44 -0
- package/dist/{provider-registry-EAGCWXQH.cjs.map → provider-registry-ZIFHRDXN.cjs.map} +1 -1
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-KRYM6L4L.cjs.map +0 -1
- package/dist/chunk-P3NIJCXP.js.map +0 -1
- package/dist/mastra-EWMYVECQ.js +0 -3
- package/dist/mastra-IMLAZTS5.cjs +0 -12
- package/dist/models-dev-3WFCNENU.js +0 -3
- package/dist/models-dev-LKRGA326.cjs +0 -12
- package/dist/netlify-SUH6DXO2.cjs +0 -12
- package/dist/netlify-WQY6BKSQ.js +0 -3
- package/dist/provider-registry-EAGCWXQH.cjs +0 -44
- package/dist/provider-registry-JQC6Y3JI.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOCWTM757_cjs = require('./chunk-OCWTM757.cjs');
|
|
4
4
|
var chunkUVA3ETHJ_cjs = require('./chunk-UVA3ETHJ.cjs');
|
|
5
5
|
var v4 = require('zod/v4');
|
|
6
6
|
|
|
@@ -17,12 +17,12 @@ var cerebrasErrorStructure = {
|
|
|
17
17
|
};
|
|
18
18
|
function createCerebras(options = {}) {
|
|
19
19
|
var _a15;
|
|
20
|
-
const baseURL =
|
|
20
|
+
const baseURL = chunkOCWTM757_cjs.withoutTrailingSlash(
|
|
21
21
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.cerebras.ai/v1"
|
|
22
22
|
);
|
|
23
|
-
const getHeaders = () =>
|
|
23
|
+
const getHeaders = () => chunkOCWTM757_cjs.withUserAgentSuffix(
|
|
24
24
|
{
|
|
25
|
-
Authorization: `Bearer ${
|
|
25
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey({
|
|
26
26
|
apiKey: options.apiKey,
|
|
27
27
|
environmentVariableName: "CEREBRAS_API_KEY",
|
|
28
28
|
description: "Cerebras API key"
|
|
@@ -32,7 +32,7 @@ function createCerebras(options = {}) {
|
|
|
32
32
|
`ai-sdk/cerebras/${VERSION}`
|
|
33
33
|
);
|
|
34
34
|
const createLanguageModel = (modelId) => {
|
|
35
|
-
return new
|
|
35
|
+
return new chunkOCWTM757_cjs.OpenAICompatibleChatLanguageModel(modelId, {
|
|
36
36
|
provider: `cerebras.chat`,
|
|
37
37
|
url: ({ path }) => `${baseURL}${path}`,
|
|
38
38
|
headers: getHeaders,
|
|
@@ -45,10 +45,10 @@ function createCerebras(options = {}) {
|
|
|
45
45
|
provider.languageModel = createLanguageModel;
|
|
46
46
|
provider.chat = createLanguageModel;
|
|
47
47
|
provider.textEmbeddingModel = (modelId) => {
|
|
48
|
-
throw new
|
|
48
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
49
49
|
};
|
|
50
50
|
provider.imageModel = (modelId) => {
|
|
51
|
-
throw new
|
|
51
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
52
52
|
};
|
|
53
53
|
return provider;
|
|
54
54
|
}
|
|
@@ -77,9 +77,9 @@ var DeepInfraImageModel = class {
|
|
|
77
77
|
const warnings = [];
|
|
78
78
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
79
79
|
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
80
|
-
const { value: response, responseHeaders } = await
|
|
80
|
+
const { value: response, responseHeaders } = await chunkOCWTM757_cjs.postJsonToApi({
|
|
81
81
|
url: `${this.config.baseURL}/${this.modelId}`,
|
|
82
|
-
headers:
|
|
82
|
+
headers: chunkOCWTM757_cjs.combineHeaders(this.config.headers(), headers),
|
|
83
83
|
body: {
|
|
84
84
|
prompt,
|
|
85
85
|
num_images: n,
|
|
@@ -88,11 +88,11 @@ var DeepInfraImageModel = class {
|
|
|
88
88
|
...seed != null && { seed },
|
|
89
89
|
...(_d = providerOptions.deepinfra) != null ? _d : {}
|
|
90
90
|
},
|
|
91
|
-
failedResponseHandler:
|
|
91
|
+
failedResponseHandler: chunkOCWTM757_cjs.createJsonErrorResponseHandler({
|
|
92
92
|
errorSchema: deepInfraErrorSchema,
|
|
93
93
|
errorToMessage: (error) => error.detail.error
|
|
94
94
|
}),
|
|
95
|
-
successfulResponseHandler:
|
|
95
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler(
|
|
96
96
|
deepInfraImageResponseSchema
|
|
97
97
|
),
|
|
98
98
|
abortSignal,
|
|
@@ -119,7 +119,7 @@ var deepInfraErrorSchema = v4.z.object({
|
|
|
119
119
|
var deepInfraImageResponseSchema = v4.z.object({
|
|
120
120
|
images: v4.z.array(v4.z.string())
|
|
121
121
|
});
|
|
122
|
-
var DeepInfraChatLanguageModel = class extends
|
|
122
|
+
var DeepInfraChatLanguageModel = class extends chunkOCWTM757_cjs.OpenAICompatibleChatLanguageModel {
|
|
123
123
|
constructor(modelId, config) {
|
|
124
124
|
super(modelId, config);
|
|
125
125
|
}
|
|
@@ -170,12 +170,12 @@ var DeepInfraChatLanguageModel = class extends chunkKRYM6L4L_cjs.OpenAICompatibl
|
|
|
170
170
|
var VERSION2 = "1.0.38" ;
|
|
171
171
|
function createDeepInfra(options = {}) {
|
|
172
172
|
var _a15;
|
|
173
|
-
const baseURL =
|
|
173
|
+
const baseURL = chunkOCWTM757_cjs.withoutTrailingSlash(
|
|
174
174
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.deepinfra.com/v1"
|
|
175
175
|
);
|
|
176
|
-
const getHeaders = () =>
|
|
176
|
+
const getHeaders = () => chunkOCWTM757_cjs.withUserAgentSuffix(
|
|
177
177
|
{
|
|
178
|
-
Authorization: `Bearer ${
|
|
178
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey({
|
|
179
179
|
apiKey: options.apiKey,
|
|
180
180
|
environmentVariableName: "DEEPINFRA_API_KEY",
|
|
181
181
|
description: "DeepInfra's API key"
|
|
@@ -196,11 +196,11 @@ function createDeepInfra(options = {}) {
|
|
|
196
196
|
getCommonModelConfig("chat")
|
|
197
197
|
);
|
|
198
198
|
};
|
|
199
|
-
const createCompletionModel = (modelId) => new
|
|
199
|
+
const createCompletionModel = (modelId) => new chunkOCWTM757_cjs.OpenAICompatibleCompletionLanguageModel(
|
|
200
200
|
modelId,
|
|
201
201
|
getCommonModelConfig("completion")
|
|
202
202
|
);
|
|
203
|
-
const createTextEmbeddingModel = (modelId) => new
|
|
203
|
+
const createTextEmbeddingModel = (modelId) => new chunkOCWTM757_cjs.OpenAICompatibleEmbeddingModel(
|
|
204
204
|
modelId,
|
|
205
205
|
getCommonModelConfig("embedding")
|
|
206
206
|
);
|
|
@@ -389,8 +389,8 @@ var deepseekChatResponseSchema = v4.z.object({
|
|
|
389
389
|
),
|
|
390
390
|
usage: tokenUsageSchema
|
|
391
391
|
});
|
|
392
|
-
var deepseekChatChunkSchema =
|
|
393
|
-
() =>
|
|
392
|
+
var deepseekChatChunkSchema = chunkOCWTM757_cjs.lazySchema(
|
|
393
|
+
() => chunkOCWTM757_cjs.zodSchema(
|
|
394
394
|
v4.z.union([
|
|
395
395
|
v4.z.object({
|
|
396
396
|
id: v4.z.string().nullish(),
|
|
@@ -477,7 +477,7 @@ function prepareTools({
|
|
|
477
477
|
};
|
|
478
478
|
default: {
|
|
479
479
|
const _exhaustiveCheck = type;
|
|
480
|
-
throw new
|
|
480
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError({
|
|
481
481
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
482
482
|
});
|
|
483
483
|
}
|
|
@@ -516,7 +516,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
516
516
|
this.supportedUrls = {};
|
|
517
517
|
this.modelId = modelId;
|
|
518
518
|
this.config = config;
|
|
519
|
-
this.failedResponseHandler =
|
|
519
|
+
this.failedResponseHandler = chunkOCWTM757_cjs.createJsonErrorResponseHandler({
|
|
520
520
|
errorSchema: deepSeekErrorSchema,
|
|
521
521
|
errorToMessage: (error) => error.error.message
|
|
522
522
|
});
|
|
@@ -543,7 +543,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
543
543
|
seed
|
|
544
544
|
}) {
|
|
545
545
|
var _a15, _b;
|
|
546
|
-
const deepseekOptions = (_a15 = await
|
|
546
|
+
const deepseekOptions = (_a15 = await chunkOCWTM757_cjs.parseProviderOptions({
|
|
547
547
|
provider: this.providerOptionsName,
|
|
548
548
|
providerOptions,
|
|
549
549
|
schema: deepseekChatOptions
|
|
@@ -591,15 +591,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
591
591
|
responseHeaders,
|
|
592
592
|
value: responseBody,
|
|
593
593
|
rawValue: rawResponse
|
|
594
|
-
} = await
|
|
594
|
+
} = await chunkOCWTM757_cjs.postJsonToApi({
|
|
595
595
|
url: this.config.url({
|
|
596
596
|
path: "/chat/completions",
|
|
597
597
|
modelId: this.modelId
|
|
598
598
|
}),
|
|
599
|
-
headers:
|
|
599
|
+
headers: chunkOCWTM757_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
600
600
|
body: args,
|
|
601
601
|
failedResponseHandler: this.failedResponseHandler,
|
|
602
|
-
successfulResponseHandler:
|
|
602
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler(
|
|
603
603
|
deepseekChatResponseSchema
|
|
604
604
|
),
|
|
605
605
|
abortSignal: options.abortSignal,
|
|
@@ -618,7 +618,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
618
618
|
for (const toolCall of choice.message.tool_calls) {
|
|
619
619
|
content.push({
|
|
620
620
|
type: "tool-call",
|
|
621
|
-
toolCallId: (_a15 = toolCall.id) != null ? _a15 :
|
|
621
|
+
toolCallId: (_a15 = toolCall.id) != null ? _a15 : chunkOCWTM757_cjs.generateId(),
|
|
622
622
|
toolName: toolCall.function.name,
|
|
623
623
|
input: toolCall.function.arguments
|
|
624
624
|
});
|
|
@@ -660,15 +660,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
660
660
|
stream: true,
|
|
661
661
|
stream_options: { include_usage: true }
|
|
662
662
|
};
|
|
663
|
-
const { responseHeaders, value: response } = await
|
|
663
|
+
const { responseHeaders, value: response } = await chunkOCWTM757_cjs.postJsonToApi({
|
|
664
664
|
url: this.config.url({
|
|
665
665
|
path: "/chat/completions",
|
|
666
666
|
modelId: this.modelId
|
|
667
667
|
}),
|
|
668
|
-
headers:
|
|
668
|
+
headers: chunkOCWTM757_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
669
669
|
body,
|
|
670
670
|
failedResponseHandler: this.failedResponseHandler,
|
|
671
|
-
successfulResponseHandler:
|
|
671
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createEventSourceResponseHandler(
|
|
672
672
|
deepseekChatChunkSchema
|
|
673
673
|
),
|
|
674
674
|
abortSignal: options.abortSignal,
|
|
@@ -766,13 +766,13 @@ var DeepSeekChatLanguageModel = class {
|
|
|
766
766
|
const index = toolCallDelta.index;
|
|
767
767
|
if (toolCalls[index] == null) {
|
|
768
768
|
if (toolCallDelta.id == null) {
|
|
769
|
-
throw new
|
|
769
|
+
throw new chunkOCWTM757_cjs.InvalidResponseDataError({
|
|
770
770
|
data: toolCallDelta,
|
|
771
771
|
message: `Expected 'id' to be a string.`
|
|
772
772
|
});
|
|
773
773
|
}
|
|
774
774
|
if (((_a15 = toolCallDelta.function) == null ? void 0 : _a15.name) == null) {
|
|
775
|
-
throw new
|
|
775
|
+
throw new chunkOCWTM757_cjs.InvalidResponseDataError({
|
|
776
776
|
data: toolCallDelta,
|
|
777
777
|
message: `Expected 'function.name' to be a string.`
|
|
778
778
|
});
|
|
@@ -800,14 +800,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
800
800
|
delta: toolCall2.function.arguments
|
|
801
801
|
});
|
|
802
802
|
}
|
|
803
|
-
if (
|
|
803
|
+
if (chunkOCWTM757_cjs.isParsableJson(toolCall2.function.arguments)) {
|
|
804
804
|
controller.enqueue({
|
|
805
805
|
type: "tool-input-end",
|
|
806
806
|
id: toolCall2.id
|
|
807
807
|
});
|
|
808
808
|
controller.enqueue({
|
|
809
809
|
type: "tool-call",
|
|
810
|
-
toolCallId: (_e = toolCall2.id) != null ? _e :
|
|
810
|
+
toolCallId: (_e = toolCall2.id) != null ? _e : chunkOCWTM757_cjs.generateId(),
|
|
811
811
|
toolName: toolCall2.function.name,
|
|
812
812
|
input: toolCall2.function.arguments
|
|
813
813
|
});
|
|
@@ -828,14 +828,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
828
828
|
id: toolCall.id,
|
|
829
829
|
delta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
|
|
830
830
|
});
|
|
831
|
-
if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null &&
|
|
831
|
+
if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && chunkOCWTM757_cjs.isParsableJson(toolCall.function.arguments)) {
|
|
832
832
|
controller.enqueue({
|
|
833
833
|
type: "tool-input-end",
|
|
834
834
|
id: toolCall.id
|
|
835
835
|
});
|
|
836
836
|
controller.enqueue({
|
|
837
837
|
type: "tool-call",
|
|
838
|
-
toolCallId: (_l = toolCall.id) != null ? _l :
|
|
838
|
+
toolCallId: (_l = toolCall.id) != null ? _l : chunkOCWTM757_cjs.generateId(),
|
|
839
839
|
toolName: toolCall.function.name,
|
|
840
840
|
input: toolCall.function.arguments
|
|
841
841
|
});
|
|
@@ -861,7 +861,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
861
861
|
});
|
|
862
862
|
controller.enqueue({
|
|
863
863
|
type: "tool-call",
|
|
864
|
-
toolCallId: (_a15 = toolCall.id) != null ? _a15 :
|
|
864
|
+
toolCallId: (_a15 = toolCall.id) != null ? _a15 : chunkOCWTM757_cjs.generateId(),
|
|
865
865
|
toolName: toolCall.function.name,
|
|
866
866
|
input: toolCall.function.arguments
|
|
867
867
|
});
|
|
@@ -894,12 +894,12 @@ var DeepSeekChatLanguageModel = class {
|
|
|
894
894
|
var VERSION3 = "1.0.36" ;
|
|
895
895
|
function createDeepSeek(options = {}) {
|
|
896
896
|
var _a15;
|
|
897
|
-
const baseURL =
|
|
897
|
+
const baseURL = chunkOCWTM757_cjs.withoutTrailingSlash(
|
|
898
898
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.deepseek.com"
|
|
899
899
|
);
|
|
900
|
-
const getHeaders = () =>
|
|
900
|
+
const getHeaders = () => chunkOCWTM757_cjs.withUserAgentSuffix(
|
|
901
901
|
{
|
|
902
|
-
Authorization: `Bearer ${
|
|
902
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey({
|
|
903
903
|
apiKey: options.apiKey,
|
|
904
904
|
environmentVariableName: "DEEPSEEK_API_KEY",
|
|
905
905
|
description: "DeepSeek API key"
|
|
@@ -920,10 +920,10 @@ function createDeepSeek(options = {}) {
|
|
|
920
920
|
provider.languageModel = createLanguageModel;
|
|
921
921
|
provider.chat = createLanguageModel;
|
|
922
922
|
provider.textEmbeddingModel = (modelId) => {
|
|
923
|
-
throw new
|
|
923
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
924
924
|
};
|
|
925
925
|
provider.imageModel = (modelId) => {
|
|
926
|
-
throw new
|
|
926
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
927
927
|
};
|
|
928
928
|
return provider;
|
|
929
929
|
}
|
|
@@ -988,7 +988,7 @@ function convertToGroqChatMessages(prompt) {
|
|
|
988
988
|
}
|
|
989
989
|
case "file": {
|
|
990
990
|
if (!part.mediaType.startsWith("image/")) {
|
|
991
|
-
throw new
|
|
991
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
992
992
|
functionality: "Non-image file content parts"
|
|
993
993
|
});
|
|
994
994
|
}
|
|
@@ -996,7 +996,7 @@ function convertToGroqChatMessages(prompt) {
|
|
|
996
996
|
return {
|
|
997
997
|
type: "image_url",
|
|
998
998
|
image_url: {
|
|
999
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
999
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunkOCWTM757_cjs.convertToBase642(part.data)}`
|
|
1000
1000
|
}
|
|
1001
1001
|
};
|
|
1002
1002
|
}
|
|
@@ -1137,7 +1137,7 @@ var groqErrorDataSchema = v4.z.object({
|
|
|
1137
1137
|
type: v4.z.string()
|
|
1138
1138
|
})
|
|
1139
1139
|
});
|
|
1140
|
-
var groqFailedResponseHandler =
|
|
1140
|
+
var groqFailedResponseHandler = chunkOCWTM757_cjs.createJsonErrorResponseHandler2({
|
|
1141
1141
|
errorSchema: groqErrorDataSchema,
|
|
1142
1142
|
errorToMessage: (data) => data.error.message
|
|
1143
1143
|
});
|
|
@@ -1216,7 +1216,7 @@ function prepareTools2({
|
|
|
1216
1216
|
};
|
|
1217
1217
|
default: {
|
|
1218
1218
|
const _exhaustiveCheck = type;
|
|
1219
|
-
throw new
|
|
1219
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
1220
1220
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1221
1221
|
});
|
|
1222
1222
|
}
|
|
@@ -1267,7 +1267,7 @@ var GroqChatLanguageModel = class {
|
|
|
1267
1267
|
}) {
|
|
1268
1268
|
var _a15, _b, _c;
|
|
1269
1269
|
const warnings = [];
|
|
1270
|
-
const groqOptions = await
|
|
1270
|
+
const groqOptions = await chunkOCWTM757_cjs.parseProviderOptions2({
|
|
1271
1271
|
provider: "groq",
|
|
1272
1272
|
providerOptions,
|
|
1273
1273
|
schema: groqLanguageModelOptions
|
|
@@ -1338,15 +1338,15 @@ var GroqChatLanguageModel = class {
|
|
|
1338
1338
|
responseHeaders,
|
|
1339
1339
|
value: response,
|
|
1340
1340
|
rawValue: rawResponse
|
|
1341
|
-
} = await
|
|
1341
|
+
} = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
1342
1342
|
url: this.config.url({
|
|
1343
1343
|
path: "/chat/completions",
|
|
1344
1344
|
modelId: this.modelId
|
|
1345
1345
|
}),
|
|
1346
|
-
headers:
|
|
1346
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
1347
1347
|
body: args,
|
|
1348
1348
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1349
|
-
successfulResponseHandler:
|
|
1349
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
1350
1350
|
groqChatResponseSchema
|
|
1351
1351
|
),
|
|
1352
1352
|
abortSignal: options.abortSignal,
|
|
@@ -1369,7 +1369,7 @@ var GroqChatLanguageModel = class {
|
|
|
1369
1369
|
for (const toolCall of choice.message.tool_calls) {
|
|
1370
1370
|
content.push({
|
|
1371
1371
|
type: "tool-call",
|
|
1372
|
-
toolCallId: (_a15 = toolCall.id) != null ? _a15 :
|
|
1372
|
+
toolCallId: (_a15 = toolCall.id) != null ? _a15 : chunkOCWTM757_cjs.generateId2(),
|
|
1373
1373
|
toolName: toolCall.function.name,
|
|
1374
1374
|
input: toolCall.function.arguments
|
|
1375
1375
|
});
|
|
@@ -1394,18 +1394,18 @@ var GroqChatLanguageModel = class {
|
|
|
1394
1394
|
async doStream(options) {
|
|
1395
1395
|
const { args, warnings } = await this.getArgs({ ...options, stream: true });
|
|
1396
1396
|
const body = JSON.stringify({ ...args, stream: true });
|
|
1397
|
-
const { responseHeaders, value: response } = await
|
|
1397
|
+
const { responseHeaders, value: response } = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
1398
1398
|
url: this.config.url({
|
|
1399
1399
|
path: "/chat/completions",
|
|
1400
1400
|
modelId: this.modelId
|
|
1401
1401
|
}),
|
|
1402
|
-
headers:
|
|
1402
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
1403
1403
|
body: {
|
|
1404
1404
|
...args,
|
|
1405
1405
|
stream: true
|
|
1406
1406
|
},
|
|
1407
1407
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1408
|
-
successfulResponseHandler:
|
|
1408
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createEventSourceResponseHandler2(groqChatChunkSchema),
|
|
1409
1409
|
abortSignal: options.abortSignal,
|
|
1410
1410
|
fetch: this.config.fetch
|
|
1411
1411
|
});
|
|
@@ -1511,19 +1511,19 @@ var GroqChatLanguageModel = class {
|
|
|
1511
1511
|
const index = toolCallDelta.index;
|
|
1512
1512
|
if (toolCalls[index] == null) {
|
|
1513
1513
|
if (toolCallDelta.type !== "function") {
|
|
1514
|
-
throw new
|
|
1514
|
+
throw new chunkOCWTM757_cjs.InvalidResponseDataError2({
|
|
1515
1515
|
data: toolCallDelta,
|
|
1516
1516
|
message: `Expected 'function' type.`
|
|
1517
1517
|
});
|
|
1518
1518
|
}
|
|
1519
1519
|
if (toolCallDelta.id == null) {
|
|
1520
|
-
throw new
|
|
1520
|
+
throw new chunkOCWTM757_cjs.InvalidResponseDataError2({
|
|
1521
1521
|
data: toolCallDelta,
|
|
1522
1522
|
message: `Expected 'id' to be a string.`
|
|
1523
1523
|
});
|
|
1524
1524
|
}
|
|
1525
1525
|
if (((_b = toolCallDelta.function) == null ? void 0 : _b.name) == null) {
|
|
1526
|
-
throw new
|
|
1526
|
+
throw new chunkOCWTM757_cjs.InvalidResponseDataError2({
|
|
1527
1527
|
data: toolCallDelta,
|
|
1528
1528
|
message: `Expected 'function.name' to be a string.`
|
|
1529
1529
|
});
|
|
@@ -1551,14 +1551,14 @@ var GroqChatLanguageModel = class {
|
|
|
1551
1551
|
delta: toolCall2.function.arguments
|
|
1552
1552
|
});
|
|
1553
1553
|
}
|
|
1554
|
-
if (
|
|
1554
|
+
if (chunkOCWTM757_cjs.isParsableJson2(toolCall2.function.arguments)) {
|
|
1555
1555
|
controller.enqueue({
|
|
1556
1556
|
type: "tool-input-end",
|
|
1557
1557
|
id: toolCall2.id
|
|
1558
1558
|
});
|
|
1559
1559
|
controller.enqueue({
|
|
1560
1560
|
type: "tool-call",
|
|
1561
|
-
toolCallId: (_f = toolCall2.id) != null ? _f :
|
|
1561
|
+
toolCallId: (_f = toolCall2.id) != null ? _f : chunkOCWTM757_cjs.generateId2(),
|
|
1562
1562
|
toolName: toolCall2.function.name,
|
|
1563
1563
|
input: toolCall2.function.arguments
|
|
1564
1564
|
});
|
|
@@ -1579,14 +1579,14 @@ var GroqChatLanguageModel = class {
|
|
|
1579
1579
|
id: toolCall.id,
|
|
1580
1580
|
delta: (_j = toolCallDelta.function.arguments) != null ? _j : ""
|
|
1581
1581
|
});
|
|
1582
|
-
if (((_k = toolCall.function) == null ? void 0 : _k.name) != null && ((_l = toolCall.function) == null ? void 0 : _l.arguments) != null &&
|
|
1582
|
+
if (((_k = toolCall.function) == null ? void 0 : _k.name) != null && ((_l = toolCall.function) == null ? void 0 : _l.arguments) != null && chunkOCWTM757_cjs.isParsableJson2(toolCall.function.arguments)) {
|
|
1583
1583
|
controller.enqueue({
|
|
1584
1584
|
type: "tool-input-end",
|
|
1585
1585
|
id: toolCall.id
|
|
1586
1586
|
});
|
|
1587
1587
|
controller.enqueue({
|
|
1588
1588
|
type: "tool-call",
|
|
1589
|
-
toolCallId: (_m = toolCall.id) != null ? _m :
|
|
1589
|
+
toolCallId: (_m = toolCall.id) != null ? _m : chunkOCWTM757_cjs.generateId2(),
|
|
1590
1590
|
toolName: toolCall.function.name,
|
|
1591
1591
|
input: toolCall.function.arguments
|
|
1592
1592
|
});
|
|
@@ -1694,8 +1694,8 @@ var groqChatChunkSchema = v4.z.union([
|
|
|
1694
1694
|
}),
|
|
1695
1695
|
groqErrorDataSchema
|
|
1696
1696
|
]);
|
|
1697
|
-
var groqTranscriptionModelOptions =
|
|
1698
|
-
() =>
|
|
1697
|
+
var groqTranscriptionModelOptions = chunkOCWTM757_cjs.lazySchema2(
|
|
1698
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
1699
1699
|
v4.z.object({
|
|
1700
1700
|
language: v4.z.string().nullish(),
|
|
1701
1701
|
prompt: v4.z.string().nullish(),
|
|
@@ -1721,15 +1721,15 @@ var GroqTranscriptionModel = class {
|
|
|
1721
1721
|
}) {
|
|
1722
1722
|
var _a15, _b, _c, _d, _e;
|
|
1723
1723
|
const warnings = [];
|
|
1724
|
-
const groqOptions = await
|
|
1724
|
+
const groqOptions = await chunkOCWTM757_cjs.parseProviderOptions2({
|
|
1725
1725
|
provider: "groq",
|
|
1726
1726
|
providerOptions,
|
|
1727
1727
|
schema: groqTranscriptionModelOptions
|
|
1728
1728
|
});
|
|
1729
1729
|
const formData = new FormData();
|
|
1730
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([
|
|
1730
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([chunkOCWTM757_cjs.convertBase64ToUint8Array2(audio)]);
|
|
1731
1731
|
formData.append("model", this.modelId);
|
|
1732
|
-
const fileExtension =
|
|
1732
|
+
const fileExtension = chunkOCWTM757_cjs.mediaTypeToExtension2(mediaType);
|
|
1733
1733
|
formData.append(
|
|
1734
1734
|
"file",
|
|
1735
1735
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -1769,15 +1769,15 @@ var GroqTranscriptionModel = class {
|
|
|
1769
1769
|
value: response,
|
|
1770
1770
|
responseHeaders,
|
|
1771
1771
|
rawValue: rawResponse
|
|
1772
|
-
} = await
|
|
1772
|
+
} = await chunkOCWTM757_cjs.postFormDataToApi2({
|
|
1773
1773
|
url: this.config.url({
|
|
1774
1774
|
path: "/audio/transcriptions",
|
|
1775
1775
|
modelId: this.modelId
|
|
1776
1776
|
}),
|
|
1777
|
-
headers:
|
|
1777
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
1778
1778
|
formData,
|
|
1779
1779
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1780
|
-
successfulResponseHandler:
|
|
1780
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
1781
1781
|
groqTranscriptionResponseSchema
|
|
1782
1782
|
),
|
|
1783
1783
|
abortSignal: options.abortSignal,
|
|
@@ -1826,7 +1826,7 @@ var groqTranscriptionResponseSchema = v4.z.object({
|
|
|
1826
1826
|
})
|
|
1827
1827
|
).nullish()
|
|
1828
1828
|
});
|
|
1829
|
-
var browserSearch =
|
|
1829
|
+
var browserSearch = chunkOCWTM757_cjs.createProviderToolFactory({
|
|
1830
1830
|
id: "groq.browser_search",
|
|
1831
1831
|
inputSchema: v4.z.object({})
|
|
1832
1832
|
});
|
|
@@ -1836,10 +1836,10 @@ var groqTools = {
|
|
|
1836
1836
|
var VERSION4 = "3.0.35" ;
|
|
1837
1837
|
function createGroq(options = {}) {
|
|
1838
1838
|
var _a15;
|
|
1839
|
-
const baseURL = (_a15 =
|
|
1840
|
-
const getHeaders = () =>
|
|
1839
|
+
const baseURL = (_a15 = chunkOCWTM757_cjs.withoutTrailingSlash2(options.baseURL)) != null ? _a15 : "https://api.groq.com/openai/v1";
|
|
1840
|
+
const getHeaders = () => chunkOCWTM757_cjs.withUserAgentSuffix2(
|
|
1841
1841
|
{
|
|
1842
|
-
Authorization: `Bearer ${
|
|
1842
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey2({
|
|
1843
1843
|
apiKey: options.apiKey,
|
|
1844
1844
|
environmentVariableName: "GROQ_API_KEY",
|
|
1845
1845
|
description: "Groq"
|
|
@@ -1877,11 +1877,11 @@ function createGroq(options = {}) {
|
|
|
1877
1877
|
provider.languageModel = createLanguageModel;
|
|
1878
1878
|
provider.chat = createChatModel;
|
|
1879
1879
|
provider.embeddingModel = (modelId) => {
|
|
1880
|
-
throw new
|
|
1880
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError2({ modelId, modelType: "embeddingModel" });
|
|
1881
1881
|
};
|
|
1882
1882
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
1883
1883
|
provider.imageModel = (modelId) => {
|
|
1884
|
-
throw new
|
|
1884
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError2({ modelId, modelType: "imageModel" });
|
|
1885
1885
|
};
|
|
1886
1886
|
provider.transcription = createTranscriptionModel;
|
|
1887
1887
|
provider.transcriptionModel = createTranscriptionModel;
|
|
@@ -1927,7 +1927,7 @@ function formatFileUrl({
|
|
|
1927
1927
|
data,
|
|
1928
1928
|
mediaType
|
|
1929
1929
|
}) {
|
|
1930
|
-
return data instanceof URL ? data.toString() : `data:${mediaType};base64,${
|
|
1930
|
+
return data instanceof URL ? data.toString() : `data:${mediaType};base64,${chunkOCWTM757_cjs.convertToBase642(data)}`;
|
|
1931
1931
|
}
|
|
1932
1932
|
function convertToMistralChatMessages(prompt) {
|
|
1933
1933
|
var _a15;
|
|
@@ -1964,7 +1964,7 @@ function convertToMistralChatMessages(prompt) {
|
|
|
1964
1964
|
})
|
|
1965
1965
|
};
|
|
1966
1966
|
} else {
|
|
1967
|
-
throw new
|
|
1967
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
1968
1968
|
functionality: "Only images and PDF file parts are supported"
|
|
1969
1969
|
});
|
|
1970
1970
|
}
|
|
@@ -2118,7 +2118,7 @@ var mistralErrorDataSchema = v4.z.object({
|
|
|
2118
2118
|
param: v4.z.string().nullable(),
|
|
2119
2119
|
code: v4.z.string().nullable()
|
|
2120
2120
|
});
|
|
2121
|
-
var mistralFailedResponseHandler =
|
|
2121
|
+
var mistralFailedResponseHandler = chunkOCWTM757_cjs.createJsonErrorResponseHandler2({
|
|
2122
2122
|
errorSchema: mistralErrorDataSchema,
|
|
2123
2123
|
errorToMessage: (data) => data.message
|
|
2124
2124
|
});
|
|
@@ -2172,7 +2172,7 @@ function prepareTools3({
|
|
|
2172
2172
|
};
|
|
2173
2173
|
default: {
|
|
2174
2174
|
const _exhaustiveCheck = type;
|
|
2175
|
-
throw new
|
|
2175
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
2176
2176
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
2177
2177
|
});
|
|
2178
2178
|
}
|
|
@@ -2187,7 +2187,7 @@ var MistralChatLanguageModel = class {
|
|
|
2187
2187
|
var _a15;
|
|
2188
2188
|
this.modelId = modelId;
|
|
2189
2189
|
this.config = config;
|
|
2190
|
-
this.generateId = (_a15 = config.generateId) != null ? _a15 :
|
|
2190
|
+
this.generateId = (_a15 = config.generateId) != null ? _a15 : chunkOCWTM757_cjs.generateId2;
|
|
2191
2191
|
}
|
|
2192
2192
|
get provider() {
|
|
2193
2193
|
return this.config.provider;
|
|
@@ -2209,7 +2209,7 @@ var MistralChatLanguageModel = class {
|
|
|
2209
2209
|
}) {
|
|
2210
2210
|
var _a15, _b, _c, _d;
|
|
2211
2211
|
const warnings = [];
|
|
2212
|
-
const options = (_a15 = await
|
|
2212
|
+
const options = (_a15 = await chunkOCWTM757_cjs.parseProviderOptions2({
|
|
2213
2213
|
provider: "mistral",
|
|
2214
2214
|
providerOptions,
|
|
2215
2215
|
schema: mistralLanguageModelOptions
|
|
@@ -2229,7 +2229,7 @@ var MistralChatLanguageModel = class {
|
|
|
2229
2229
|
const structuredOutputs = (_b = options.structuredOutputs) != null ? _b : true;
|
|
2230
2230
|
const strictJsonSchema = (_c = options.strictJsonSchema) != null ? _c : false;
|
|
2231
2231
|
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && !(responseFormat == null ? void 0 : responseFormat.schema)) {
|
|
2232
|
-
prompt =
|
|
2232
|
+
prompt = chunkOCWTM757_cjs.injectJsonInstructionIntoMessages({
|
|
2233
2233
|
messages: prompt,
|
|
2234
2234
|
schema: responseFormat.schema
|
|
2235
2235
|
});
|
|
@@ -2286,12 +2286,12 @@ var MistralChatLanguageModel = class {
|
|
|
2286
2286
|
responseHeaders,
|
|
2287
2287
|
value: response,
|
|
2288
2288
|
rawValue: rawResponse
|
|
2289
|
-
} = await
|
|
2289
|
+
} = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
2290
2290
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2291
|
-
headers:
|
|
2291
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
2292
2292
|
body,
|
|
2293
2293
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2294
|
-
successfulResponseHandler:
|
|
2294
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
2295
2295
|
mistralChatResponseSchema
|
|
2296
2296
|
),
|
|
2297
2297
|
abortSignal: options.abortSignal,
|
|
@@ -2347,12 +2347,12 @@ var MistralChatLanguageModel = class {
|
|
|
2347
2347
|
async doStream(options) {
|
|
2348
2348
|
const { args, warnings } = await this.getArgs(options);
|
|
2349
2349
|
const body = { ...args, stream: true };
|
|
2350
|
-
const { responseHeaders, value: response } = await
|
|
2350
|
+
const { responseHeaders, value: response } = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
2351
2351
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2352
|
-
headers:
|
|
2352
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
2353
2353
|
body,
|
|
2354
2354
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2355
|
-
successfulResponseHandler:
|
|
2355
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createEventSourceResponseHandler2(
|
|
2356
2356
|
mistralChatChunkSchema
|
|
2357
2357
|
),
|
|
2358
2358
|
abortSignal: options.abortSignal,
|
|
@@ -2625,7 +2625,7 @@ var MistralEmbeddingModel = class {
|
|
|
2625
2625
|
headers
|
|
2626
2626
|
}) {
|
|
2627
2627
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
2628
|
-
throw new
|
|
2628
|
+
throw new chunkOCWTM757_cjs.TooManyEmbeddingValuesForCallError2({
|
|
2629
2629
|
provider: this.provider,
|
|
2630
2630
|
modelId: this.modelId,
|
|
2631
2631
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -2636,16 +2636,16 @@ var MistralEmbeddingModel = class {
|
|
|
2636
2636
|
responseHeaders,
|
|
2637
2637
|
value: response,
|
|
2638
2638
|
rawValue
|
|
2639
|
-
} = await
|
|
2639
|
+
} = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
2640
2640
|
url: `${this.config.baseURL}/embeddings`,
|
|
2641
|
-
headers:
|
|
2641
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), headers),
|
|
2642
2642
|
body: {
|
|
2643
2643
|
model: this.modelId,
|
|
2644
2644
|
input: values,
|
|
2645
2645
|
encoding_format: "float"
|
|
2646
2646
|
},
|
|
2647
2647
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2648
|
-
successfulResponseHandler:
|
|
2648
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
2649
2649
|
MistralTextEmbeddingResponseSchema
|
|
2650
2650
|
),
|
|
2651
2651
|
abortSignal,
|
|
@@ -2666,10 +2666,10 @@ var MistralTextEmbeddingResponseSchema = v4.z.object({
|
|
|
2666
2666
|
var VERSION5 = "3.0.30" ;
|
|
2667
2667
|
function createMistral(options = {}) {
|
|
2668
2668
|
var _a15;
|
|
2669
|
-
const baseURL = (_a15 =
|
|
2670
|
-
const getHeaders = () =>
|
|
2669
|
+
const baseURL = (_a15 = chunkOCWTM757_cjs.withoutTrailingSlash2(options.baseURL)) != null ? _a15 : "https://api.mistral.ai/v1";
|
|
2670
|
+
const getHeaders = () => chunkOCWTM757_cjs.withUserAgentSuffix2(
|
|
2671
2671
|
{
|
|
2672
|
-
Authorization: `Bearer ${
|
|
2672
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey2({
|
|
2673
2673
|
apiKey: options.apiKey,
|
|
2674
2674
|
environmentVariableName: "MISTRAL_API_KEY",
|
|
2675
2675
|
description: "Mistral"
|
|
@@ -2707,7 +2707,7 @@ function createMistral(options = {}) {
|
|
|
2707
2707
|
provider.textEmbedding = createEmbeddingModel;
|
|
2708
2708
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
2709
2709
|
provider.imageModel = (modelId) => {
|
|
2710
|
-
throw new
|
|
2710
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError2({ modelId, modelType: "imageModel" });
|
|
2711
2711
|
};
|
|
2712
2712
|
return provider;
|
|
2713
2713
|
}
|
|
@@ -2745,7 +2745,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2745
2745
|
} : {
|
|
2746
2746
|
type: "file_url",
|
|
2747
2747
|
file_url: {
|
|
2748
|
-
url: typeof part.data === "string" ? part.data :
|
|
2748
|
+
url: typeof part.data === "string" ? part.data : chunkOCWTM757_cjs.convertUint8ArrayToBase64(part.data)
|
|
2749
2749
|
},
|
|
2750
2750
|
file_name: part.filename || `document-${index}.pdf`
|
|
2751
2751
|
};
|
|
@@ -2758,7 +2758,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2758
2758
|
} : {
|
|
2759
2759
|
type: "image_url",
|
|
2760
2760
|
image_url: {
|
|
2761
|
-
url: `data:${(_a15 = part.mediaType) != null ? _a15 : "image/jpeg"};base64,${typeof part.data === "string" ? part.data :
|
|
2761
|
+
url: `data:${(_a15 = part.mediaType) != null ? _a15 : "image/jpeg"};base64,${typeof part.data === "string" ? part.data : chunkOCWTM757_cjs.convertUint8ArrayToBase64(part.data)}`
|
|
2762
2762
|
}
|
|
2763
2763
|
};
|
|
2764
2764
|
}
|
|
@@ -2772,7 +2772,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2772
2772
|
break;
|
|
2773
2773
|
}
|
|
2774
2774
|
case "tool": {
|
|
2775
|
-
throw new
|
|
2775
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError({
|
|
2776
2776
|
functionality: "Tool messages"
|
|
2777
2777
|
});
|
|
2778
2778
|
}
|
|
@@ -2867,15 +2867,15 @@ var PerplexityLanguageModel = class {
|
|
|
2867
2867
|
responseHeaders,
|
|
2868
2868
|
value: response,
|
|
2869
2869
|
rawValue: rawResponse
|
|
2870
|
-
} = await
|
|
2870
|
+
} = await chunkOCWTM757_cjs.postJsonToApi({
|
|
2871
2871
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2872
|
-
headers:
|
|
2872
|
+
headers: chunkOCWTM757_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2873
2873
|
body,
|
|
2874
|
-
failedResponseHandler:
|
|
2874
|
+
failedResponseHandler: chunkOCWTM757_cjs.createJsonErrorResponseHandler({
|
|
2875
2875
|
errorSchema: perplexityErrorSchema,
|
|
2876
2876
|
errorToMessage
|
|
2877
2877
|
}),
|
|
2878
|
-
successfulResponseHandler:
|
|
2878
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler(
|
|
2879
2879
|
perplexityResponseSchema
|
|
2880
2880
|
),
|
|
2881
2881
|
abortSignal: options.abortSignal,
|
|
@@ -2938,15 +2938,15 @@ var PerplexityLanguageModel = class {
|
|
|
2938
2938
|
async doStream(options) {
|
|
2939
2939
|
const { args, warnings } = this.getArgs(options);
|
|
2940
2940
|
const body = { ...args, stream: true };
|
|
2941
|
-
const { responseHeaders, value: response } = await
|
|
2941
|
+
const { responseHeaders, value: response } = await chunkOCWTM757_cjs.postJsonToApi({
|
|
2942
2942
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2943
|
-
headers:
|
|
2943
|
+
headers: chunkOCWTM757_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2944
2944
|
body,
|
|
2945
|
-
failedResponseHandler:
|
|
2945
|
+
failedResponseHandler: chunkOCWTM757_cjs.createJsonErrorResponseHandler({
|
|
2946
2946
|
errorSchema: perplexityErrorSchema,
|
|
2947
2947
|
errorToMessage
|
|
2948
2948
|
}),
|
|
2949
|
-
successfulResponseHandler:
|
|
2949
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createEventSourceResponseHandler(
|
|
2950
2950
|
perplexityChunkSchema
|
|
2951
2951
|
),
|
|
2952
2952
|
abortSignal: options.abortSignal,
|
|
@@ -3144,9 +3144,9 @@ var errorToMessage = (data) => {
|
|
|
3144
3144
|
};
|
|
3145
3145
|
var VERSION6 = "2.0.27" ;
|
|
3146
3146
|
function createPerplexity(options = {}) {
|
|
3147
|
-
const getHeaders = () =>
|
|
3147
|
+
const getHeaders = () => chunkOCWTM757_cjs.withUserAgentSuffix(
|
|
3148
3148
|
{
|
|
3149
|
-
Authorization: `Bearer ${
|
|
3149
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey({
|
|
3150
3150
|
apiKey: options.apiKey,
|
|
3151
3151
|
environmentVariableName: "PERPLEXITY_API_KEY",
|
|
3152
3152
|
description: "Perplexity"
|
|
@@ -3158,21 +3158,21 @@ function createPerplexity(options = {}) {
|
|
|
3158
3158
|
const createLanguageModel = (modelId) => {
|
|
3159
3159
|
var _a15;
|
|
3160
3160
|
return new PerplexityLanguageModel(modelId, {
|
|
3161
|
-
baseURL:
|
|
3161
|
+
baseURL: chunkOCWTM757_cjs.withoutTrailingSlash(
|
|
3162
3162
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.perplexity.ai"
|
|
3163
3163
|
),
|
|
3164
3164
|
headers: getHeaders,
|
|
3165
|
-
generateId:
|
|
3165
|
+
generateId: chunkOCWTM757_cjs.generateId,
|
|
3166
3166
|
fetch: options.fetch
|
|
3167
3167
|
});
|
|
3168
3168
|
};
|
|
3169
3169
|
const provider = (modelId) => createLanguageModel(modelId);
|
|
3170
3170
|
provider.languageModel = createLanguageModel;
|
|
3171
3171
|
provider.textEmbeddingModel = (modelId) => {
|
|
3172
|
-
throw new
|
|
3172
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
3173
3173
|
};
|
|
3174
3174
|
provider.imageModel = (modelId) => {
|
|
3175
|
-
throw new
|
|
3175
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
3176
3176
|
};
|
|
3177
3177
|
return provider;
|
|
3178
3178
|
}
|
|
@@ -3207,9 +3207,9 @@ var TogetherAIImageModel = class {
|
|
|
3207
3207
|
}
|
|
3208
3208
|
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3209
3209
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
3210
|
-
const { value: response, responseHeaders } = await
|
|
3210
|
+
const { value: response, responseHeaders } = await chunkOCWTM757_cjs.postJsonToApi({
|
|
3211
3211
|
url: `${this.config.baseURL}/images/generations`,
|
|
3212
|
-
headers:
|
|
3212
|
+
headers: chunkOCWTM757_cjs.combineHeaders(this.config.headers(), headers),
|
|
3213
3213
|
body: {
|
|
3214
3214
|
model: this.modelId,
|
|
3215
3215
|
prompt,
|
|
@@ -3222,11 +3222,11 @@ var TogetherAIImageModel = class {
|
|
|
3222
3222
|
response_format: "base64",
|
|
3223
3223
|
...(_d = providerOptions.togetherai) != null ? _d : {}
|
|
3224
3224
|
},
|
|
3225
|
-
failedResponseHandler:
|
|
3225
|
+
failedResponseHandler: chunkOCWTM757_cjs.createJsonErrorResponseHandler({
|
|
3226
3226
|
errorSchema: togetheraiErrorSchema,
|
|
3227
3227
|
errorToMessage: (data) => data.error.message
|
|
3228
3228
|
}),
|
|
3229
|
-
successfulResponseHandler:
|
|
3229
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler(
|
|
3230
3230
|
togetheraiImageResponseSchema
|
|
3231
3231
|
),
|
|
3232
3232
|
abortSignal,
|
|
@@ -3273,14 +3273,14 @@ function loadDeprecatedApiKey() {
|
|
|
3273
3273
|
}
|
|
3274
3274
|
function createTogetherAI(options = {}) {
|
|
3275
3275
|
var _a15;
|
|
3276
|
-
const baseURL =
|
|
3276
|
+
const baseURL = chunkOCWTM757_cjs.withoutTrailingSlash(
|
|
3277
3277
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.together.xyz/v1/"
|
|
3278
3278
|
);
|
|
3279
3279
|
const getHeaders = () => {
|
|
3280
3280
|
var _a22;
|
|
3281
|
-
return
|
|
3281
|
+
return chunkOCWTM757_cjs.withUserAgentSuffix(
|
|
3282
3282
|
{
|
|
3283
|
-
Authorization: `Bearer ${
|
|
3283
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey({
|
|
3284
3284
|
apiKey: (_a22 = options.apiKey) != null ? _a22 : loadDeprecatedApiKey(),
|
|
3285
3285
|
environmentVariableName: "TOGETHER_API_KEY",
|
|
3286
3286
|
description: "TogetherAI"
|
|
@@ -3297,16 +3297,16 @@ function createTogetherAI(options = {}) {
|
|
|
3297
3297
|
fetch: options.fetch
|
|
3298
3298
|
});
|
|
3299
3299
|
const createChatModel = (modelId) => {
|
|
3300
|
-
return new
|
|
3300
|
+
return new chunkOCWTM757_cjs.OpenAICompatibleChatLanguageModel(
|
|
3301
3301
|
modelId,
|
|
3302
3302
|
getCommonModelConfig("chat")
|
|
3303
3303
|
);
|
|
3304
3304
|
};
|
|
3305
|
-
const createCompletionModel = (modelId) => new
|
|
3305
|
+
const createCompletionModel = (modelId) => new chunkOCWTM757_cjs.OpenAICompatibleCompletionLanguageModel(
|
|
3306
3306
|
modelId,
|
|
3307
3307
|
getCommonModelConfig("completion")
|
|
3308
3308
|
);
|
|
3309
|
-
const createTextEmbeddingModel = (modelId) => new
|
|
3309
|
+
const createTextEmbeddingModel = (modelId) => new chunkOCWTM757_cjs.OpenAICompatibleEmbeddingModel(
|
|
3310
3310
|
modelId,
|
|
3311
3311
|
getCommonModelConfig("embedding")
|
|
3312
3312
|
);
|
|
@@ -3352,11 +3352,11 @@ function convertToXaiChatMessages(prompt) {
|
|
|
3352
3352
|
return {
|
|
3353
3353
|
type: "image_url",
|
|
3354
3354
|
image_url: {
|
|
3355
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
3355
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunkOCWTM757_cjs.convertToBase642(part.data)}`
|
|
3356
3356
|
}
|
|
3357
3357
|
};
|
|
3358
3358
|
} else {
|
|
3359
|
-
throw new
|
|
3359
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
3360
3360
|
functionality: `file part media type ${part.mediaType}`
|
|
3361
3361
|
});
|
|
3362
3362
|
}
|
|
@@ -3570,7 +3570,7 @@ var xaiErrorDataSchema = v4.z.object({
|
|
|
3570
3570
|
code: v4.z.union([v4.z.string(), v4.z.number()]).nullish()
|
|
3571
3571
|
})
|
|
3572
3572
|
});
|
|
3573
|
-
var xaiFailedResponseHandler =
|
|
3573
|
+
var xaiFailedResponseHandler = chunkOCWTM757_cjs.createJsonErrorResponseHandler2({
|
|
3574
3574
|
errorSchema: xaiErrorDataSchema,
|
|
3575
3575
|
errorToMessage: (data) => data.error.message
|
|
3576
3576
|
});
|
|
@@ -3623,7 +3623,7 @@ function prepareTools4({
|
|
|
3623
3623
|
};
|
|
3624
3624
|
default: {
|
|
3625
3625
|
const _exhaustiveCheck = type;
|
|
3626
|
-
throw new
|
|
3626
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
3627
3627
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
3628
3628
|
});
|
|
3629
3629
|
}
|
|
@@ -3658,7 +3658,7 @@ var XaiChatLanguageModel = class {
|
|
|
3658
3658
|
}) {
|
|
3659
3659
|
var _a15, _b, _c;
|
|
3660
3660
|
const warnings = [];
|
|
3661
|
-
const options = (_a15 = await
|
|
3661
|
+
const options = (_a15 = await chunkOCWTM757_cjs.parseProviderOptions2({
|
|
3662
3662
|
provider: "xai",
|
|
3663
3663
|
providerOptions,
|
|
3664
3664
|
schema: xaiLanguageModelChatOptions
|
|
@@ -3761,19 +3761,19 @@ var XaiChatLanguageModel = class {
|
|
|
3761
3761
|
responseHeaders,
|
|
3762
3762
|
value: response,
|
|
3763
3763
|
rawValue: rawResponse
|
|
3764
|
-
} = await
|
|
3764
|
+
} = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
3765
3765
|
url,
|
|
3766
|
-
headers:
|
|
3766
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
3767
3767
|
body,
|
|
3768
3768
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3769
|
-
successfulResponseHandler:
|
|
3769
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
3770
3770
|
xaiChatResponseSchema
|
|
3771
3771
|
),
|
|
3772
3772
|
abortSignal: options.abortSignal,
|
|
3773
3773
|
fetch: this.config.fetch
|
|
3774
3774
|
});
|
|
3775
3775
|
if (response.error != null) {
|
|
3776
|
-
throw new
|
|
3776
|
+
throw new chunkOCWTM757_cjs.APICallError2({
|
|
3777
3777
|
message: response.error,
|
|
3778
3778
|
url,
|
|
3779
3779
|
requestBodyValues: body,
|
|
@@ -3851,22 +3851,22 @@ var XaiChatLanguageModel = class {
|
|
|
3851
3851
|
}
|
|
3852
3852
|
};
|
|
3853
3853
|
const url = `${(_a15 = this.config.baseURL) != null ? _a15 : "https://api.x.ai/v1"}/chat/completions`;
|
|
3854
|
-
const { responseHeaders, value: response } = await
|
|
3854
|
+
const { responseHeaders, value: response } = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
3855
3855
|
url,
|
|
3856
|
-
headers:
|
|
3856
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
3857
3857
|
body,
|
|
3858
3858
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3859
3859
|
successfulResponseHandler: async ({ response: response2 }) => {
|
|
3860
|
-
const responseHeaders2 =
|
|
3860
|
+
const responseHeaders2 = chunkOCWTM757_cjs.extractResponseHeaders(response2);
|
|
3861
3861
|
const contentType = response2.headers.get("content-type");
|
|
3862
3862
|
if (contentType == null ? void 0 : contentType.includes("application/json")) {
|
|
3863
3863
|
const responseBody = await response2.text();
|
|
3864
|
-
const parsedError = await
|
|
3864
|
+
const parsedError = await chunkOCWTM757_cjs.safeParseJSON({
|
|
3865
3865
|
text: responseBody,
|
|
3866
3866
|
schema: xaiStreamErrorSchema
|
|
3867
3867
|
});
|
|
3868
3868
|
if (parsedError.success) {
|
|
3869
|
-
throw new
|
|
3869
|
+
throw new chunkOCWTM757_cjs.APICallError2({
|
|
3870
3870
|
message: parsedError.value.error,
|
|
3871
3871
|
url,
|
|
3872
3872
|
requestBodyValues: body,
|
|
@@ -3876,7 +3876,7 @@ var XaiChatLanguageModel = class {
|
|
|
3876
3876
|
isRetryable: parsedError.value.code === "The service is currently unavailable"
|
|
3877
3877
|
});
|
|
3878
3878
|
}
|
|
3879
|
-
throw new
|
|
3879
|
+
throw new chunkOCWTM757_cjs.APICallError2({
|
|
3880
3880
|
message: "Invalid JSON response",
|
|
3881
3881
|
url,
|
|
3882
3882
|
requestBodyValues: body,
|
|
@@ -3885,7 +3885,7 @@ var XaiChatLanguageModel = class {
|
|
|
3885
3885
|
responseBody
|
|
3886
3886
|
});
|
|
3887
3887
|
}
|
|
3888
|
-
return
|
|
3888
|
+
return chunkOCWTM757_cjs.createEventSourceResponseHandler2(xaiChatChunkSchema)({
|
|
3889
3889
|
response: response2,
|
|
3890
3890
|
url,
|
|
3891
3891
|
requestBodyValues: body
|
|
@@ -4194,13 +4194,13 @@ var XaiImageModel = class {
|
|
|
4194
4194
|
feature: "mask"
|
|
4195
4195
|
});
|
|
4196
4196
|
}
|
|
4197
|
-
const xaiOptions = await
|
|
4197
|
+
const xaiOptions = await chunkOCWTM757_cjs.parseProviderOptions2({
|
|
4198
4198
|
provider: "xai",
|
|
4199
4199
|
providerOptions,
|
|
4200
4200
|
schema: xaiImageModelOptions
|
|
4201
4201
|
});
|
|
4202
4202
|
const hasFiles = files != null && files.length > 0;
|
|
4203
|
-
const imageUrls = hasFiles ? files.map((file) =>
|
|
4203
|
+
const imageUrls = hasFiles ? files.map((file) => chunkOCWTM757_cjs.convertImageModelFileToDataUri(file)) : [];
|
|
4204
4204
|
const endpoint = hasFiles ? "/images/edits" : "/images/generations";
|
|
4205
4205
|
const body = {
|
|
4206
4206
|
model: this.modelId,
|
|
@@ -4236,12 +4236,12 @@ var XaiImageModel = class {
|
|
|
4236
4236
|
}
|
|
4237
4237
|
const baseURL = (_a15 = this.config.baseURL) != null ? _a15 : "https://api.x.ai/v1";
|
|
4238
4238
|
const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
|
|
4239
|
-
const { value: response, responseHeaders } = await
|
|
4239
|
+
const { value: response, responseHeaders } = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
4240
4240
|
url: `${baseURL}${endpoint}`,
|
|
4241
|
-
headers:
|
|
4241
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), headers),
|
|
4242
4242
|
body,
|
|
4243
4243
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4244
|
-
successfulResponseHandler:
|
|
4244
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
4245
4245
|
xaiImageResponseSchema
|
|
4246
4246
|
),
|
|
4247
4247
|
abortSignal,
|
|
@@ -4272,11 +4272,11 @@ var XaiImageModel = class {
|
|
|
4272
4272
|
};
|
|
4273
4273
|
}
|
|
4274
4274
|
async downloadImage(url, abortSignal) {
|
|
4275
|
-
const { value } = await
|
|
4275
|
+
const { value } = await chunkOCWTM757_cjs.getFromApi({
|
|
4276
4276
|
url,
|
|
4277
4277
|
abortSignal,
|
|
4278
|
-
failedResponseHandler:
|
|
4279
|
-
successfulResponseHandler:
|
|
4278
|
+
failedResponseHandler: chunkOCWTM757_cjs.createStatusCodeErrorResponseHandler(),
|
|
4279
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createBinaryResponseHandler2(),
|
|
4280
4280
|
fetch: this.config.fetch
|
|
4281
4281
|
});
|
|
4282
4282
|
return value;
|
|
@@ -4320,10 +4320,10 @@ async function convertToXaiResponsesInput({
|
|
|
4320
4320
|
case "file": {
|
|
4321
4321
|
if (block.mediaType.startsWith("image/")) {
|
|
4322
4322
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
4323
|
-
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${
|
|
4323
|
+
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${chunkOCWTM757_cjs.convertToBase642(block.data)}`;
|
|
4324
4324
|
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
4325
4325
|
} else {
|
|
4326
|
-
throw new
|
|
4326
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
4327
4327
|
functionality: `file part media type ${block.mediaType}`
|
|
4328
4328
|
});
|
|
4329
4329
|
}
|
|
@@ -4924,16 +4924,16 @@ var xaiLanguageModelResponsesOptions = v4.z.object({
|
|
|
4924
4924
|
*/
|
|
4925
4925
|
include: v4.z.array(v4.z.enum(["file_search_call.results"])).nullish()
|
|
4926
4926
|
});
|
|
4927
|
-
var fileSearchArgsSchema =
|
|
4928
|
-
() =>
|
|
4927
|
+
var fileSearchArgsSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
4928
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
4929
4929
|
v4.z.object({
|
|
4930
4930
|
vectorStoreIds: v4.z.array(v4.z.string()),
|
|
4931
4931
|
maxNumResults: v4.z.number().optional()
|
|
4932
4932
|
})
|
|
4933
4933
|
)
|
|
4934
4934
|
);
|
|
4935
|
-
var fileSearchOutputSchema =
|
|
4936
|
-
() =>
|
|
4935
|
+
var fileSearchOutputSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
4936
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
4937
4937
|
v4.z.object({
|
|
4938
4938
|
queries: v4.z.array(v4.z.string()),
|
|
4939
4939
|
results: v4.z.array(
|
|
@@ -4947,14 +4947,14 @@ var fileSearchOutputSchema = chunkKRYM6L4L_cjs.lazySchema2(
|
|
|
4947
4947
|
})
|
|
4948
4948
|
)
|
|
4949
4949
|
);
|
|
4950
|
-
var fileSearchToolFactory =
|
|
4950
|
+
var fileSearchToolFactory = chunkOCWTM757_cjs.createProviderToolFactoryWithOutputSchema({
|
|
4951
4951
|
id: "xai.file_search",
|
|
4952
|
-
inputSchema:
|
|
4952
|
+
inputSchema: chunkOCWTM757_cjs.lazySchema2(() => chunkOCWTM757_cjs.zodSchema2(v4.z.object({}))),
|
|
4953
4953
|
outputSchema: fileSearchOutputSchema
|
|
4954
4954
|
});
|
|
4955
4955
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
4956
|
-
var mcpServerArgsSchema =
|
|
4957
|
-
() =>
|
|
4956
|
+
var mcpServerArgsSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
4957
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
4958
4958
|
v4.z.object({
|
|
4959
4959
|
serverUrl: v4.z.string().describe("The URL of the MCP server"),
|
|
4960
4960
|
serverLabel: v4.z.string().optional().describe("A label for the MCP server"),
|
|
@@ -4965,8 +4965,8 @@ var mcpServerArgsSchema = chunkKRYM6L4L_cjs.lazySchema2(
|
|
|
4965
4965
|
})
|
|
4966
4966
|
)
|
|
4967
4967
|
);
|
|
4968
|
-
var mcpServerOutputSchema =
|
|
4969
|
-
() =>
|
|
4968
|
+
var mcpServerOutputSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
4969
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
4970
4970
|
v4.z.object({
|
|
4971
4971
|
name: v4.z.string(),
|
|
4972
4972
|
arguments: v4.z.string(),
|
|
@@ -4974,14 +4974,14 @@ var mcpServerOutputSchema = chunkKRYM6L4L_cjs.lazySchema2(
|
|
|
4974
4974
|
})
|
|
4975
4975
|
)
|
|
4976
4976
|
);
|
|
4977
|
-
var mcpServerToolFactory =
|
|
4977
|
+
var mcpServerToolFactory = chunkOCWTM757_cjs.createProviderToolFactoryWithOutputSchema({
|
|
4978
4978
|
id: "xai.mcp",
|
|
4979
|
-
inputSchema:
|
|
4979
|
+
inputSchema: chunkOCWTM757_cjs.lazySchema2(() => chunkOCWTM757_cjs.zodSchema2(v4.z.object({}))),
|
|
4980
4980
|
outputSchema: mcpServerOutputSchema
|
|
4981
4981
|
});
|
|
4982
4982
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
4983
|
-
var webSearchArgsSchema =
|
|
4984
|
-
() =>
|
|
4983
|
+
var webSearchArgsSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
4984
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
4985
4985
|
v4.z.object({
|
|
4986
4986
|
allowedDomains: v4.z.array(v4.z.string()).max(5).optional(),
|
|
4987
4987
|
excludedDomains: v4.z.array(v4.z.string()).max(5).optional(),
|
|
@@ -4989,8 +4989,8 @@ var webSearchArgsSchema = chunkKRYM6L4L_cjs.lazySchema2(
|
|
|
4989
4989
|
})
|
|
4990
4990
|
)
|
|
4991
4991
|
);
|
|
4992
|
-
var webSearchOutputSchema =
|
|
4993
|
-
() =>
|
|
4992
|
+
var webSearchOutputSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
4993
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
4994
4994
|
v4.z.object({
|
|
4995
4995
|
query: v4.z.string(),
|
|
4996
4996
|
sources: v4.z.array(
|
|
@@ -5003,14 +5003,14 @@ var webSearchOutputSchema = chunkKRYM6L4L_cjs.lazySchema2(
|
|
|
5003
5003
|
})
|
|
5004
5004
|
)
|
|
5005
5005
|
);
|
|
5006
|
-
var webSearchToolFactory =
|
|
5006
|
+
var webSearchToolFactory = chunkOCWTM757_cjs.createProviderToolFactoryWithOutputSchema({
|
|
5007
5007
|
id: "xai.web_search",
|
|
5008
|
-
inputSchema:
|
|
5008
|
+
inputSchema: chunkOCWTM757_cjs.lazySchema2(() => chunkOCWTM757_cjs.zodSchema2(v4.z.object({}))),
|
|
5009
5009
|
outputSchema: webSearchOutputSchema
|
|
5010
5010
|
});
|
|
5011
5011
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
5012
|
-
var xSearchArgsSchema =
|
|
5013
|
-
() =>
|
|
5012
|
+
var xSearchArgsSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
5013
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
5014
5014
|
v4.z.object({
|
|
5015
5015
|
allowedXHandles: v4.z.array(v4.z.string()).max(10).optional(),
|
|
5016
5016
|
excludedXHandles: v4.z.array(v4.z.string()).max(10).optional(),
|
|
@@ -5021,8 +5021,8 @@ var xSearchArgsSchema = chunkKRYM6L4L_cjs.lazySchema2(
|
|
|
5021
5021
|
})
|
|
5022
5022
|
)
|
|
5023
5023
|
);
|
|
5024
|
-
var xSearchOutputSchema =
|
|
5025
|
-
() =>
|
|
5024
|
+
var xSearchOutputSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
5025
|
+
() => chunkOCWTM757_cjs.zodSchema2(
|
|
5026
5026
|
v4.z.object({
|
|
5027
5027
|
query: v4.z.string(),
|
|
5028
5028
|
posts: v4.z.array(
|
|
@@ -5036,9 +5036,9 @@ var xSearchOutputSchema = chunkKRYM6L4L_cjs.lazySchema2(
|
|
|
5036
5036
|
})
|
|
5037
5037
|
)
|
|
5038
5038
|
);
|
|
5039
|
-
var xSearchToolFactory =
|
|
5039
|
+
var xSearchToolFactory = chunkOCWTM757_cjs.createProviderToolFactoryWithOutputSchema({
|
|
5040
5040
|
id: "xai.x_search",
|
|
5041
|
-
inputSchema:
|
|
5041
|
+
inputSchema: chunkOCWTM757_cjs.lazySchema2(() => chunkOCWTM757_cjs.zodSchema2(v4.z.object({}))),
|
|
5042
5042
|
outputSchema: xSearchOutputSchema
|
|
5043
5043
|
});
|
|
5044
5044
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -5058,7 +5058,7 @@ async function prepareResponsesTools({
|
|
|
5058
5058
|
if (tool.type === "provider") {
|
|
5059
5059
|
switch (tool.id) {
|
|
5060
5060
|
case "xai.web_search": {
|
|
5061
|
-
const args = await
|
|
5061
|
+
const args = await chunkOCWTM757_cjs.validateTypes2({
|
|
5062
5062
|
value: tool.args,
|
|
5063
5063
|
schema: webSearchArgsSchema
|
|
5064
5064
|
});
|
|
@@ -5071,7 +5071,7 @@ async function prepareResponsesTools({
|
|
|
5071
5071
|
break;
|
|
5072
5072
|
}
|
|
5073
5073
|
case "xai.x_search": {
|
|
5074
|
-
const args = await
|
|
5074
|
+
const args = await chunkOCWTM757_cjs.validateTypes2({
|
|
5075
5075
|
value: tool.args,
|
|
5076
5076
|
schema: xSearchArgsSchema
|
|
5077
5077
|
});
|
|
@@ -5105,7 +5105,7 @@ async function prepareResponsesTools({
|
|
|
5105
5105
|
break;
|
|
5106
5106
|
}
|
|
5107
5107
|
case "xai.file_search": {
|
|
5108
|
-
const args = await
|
|
5108
|
+
const args = await chunkOCWTM757_cjs.validateTypes2({
|
|
5109
5109
|
value: tool.args,
|
|
5110
5110
|
schema: fileSearchArgsSchema
|
|
5111
5111
|
});
|
|
@@ -5117,7 +5117,7 @@ async function prepareResponsesTools({
|
|
|
5117
5117
|
break;
|
|
5118
5118
|
}
|
|
5119
5119
|
case "xai.mcp": {
|
|
5120
|
-
const args = await
|
|
5120
|
+
const args = await chunkOCWTM757_cjs.validateTypes2({
|
|
5121
5121
|
value: tool.args,
|
|
5122
5122
|
schema: mcpServerArgsSchema
|
|
5123
5123
|
});
|
|
@@ -5184,7 +5184,7 @@ async function prepareResponsesTools({
|
|
|
5184
5184
|
}
|
|
5185
5185
|
default: {
|
|
5186
5186
|
const _exhaustiveCheck = type;
|
|
5187
|
-
throw new
|
|
5187
|
+
throw new chunkOCWTM757_cjs.UnsupportedFunctionalityError2({
|
|
5188
5188
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
5189
5189
|
});
|
|
5190
5190
|
}
|
|
@@ -5216,7 +5216,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
5216
5216
|
}) {
|
|
5217
5217
|
var _a15, _b, _c, _d, _e, _f, _g;
|
|
5218
5218
|
const warnings = [];
|
|
5219
|
-
const options = (_a15 = await
|
|
5219
|
+
const options = (_a15 = await chunkOCWTM757_cjs.parseProviderOptions2({
|
|
5220
5220
|
provider: "xai",
|
|
5221
5221
|
providerOptions,
|
|
5222
5222
|
schema: xaiLanguageModelResponsesOptions
|
|
@@ -5323,12 +5323,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
5323
5323
|
responseHeaders,
|
|
5324
5324
|
value: response,
|
|
5325
5325
|
rawValue: rawResponse
|
|
5326
|
-
} = await
|
|
5326
|
+
} = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
5327
5327
|
url: `${(_a15 = this.config.baseURL) != null ? _a15 : "https://api.x.ai/v1"}/responses`,
|
|
5328
|
-
headers:
|
|
5328
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
5329
5329
|
body,
|
|
5330
5330
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
5331
|
-
successfulResponseHandler:
|
|
5331
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
5332
5332
|
xaiResponsesResponseSchema
|
|
5333
5333
|
),
|
|
5334
5334
|
abortSignal: options.abortSignal,
|
|
@@ -5491,12 +5491,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
5491
5491
|
...args,
|
|
5492
5492
|
stream: true
|
|
5493
5493
|
};
|
|
5494
|
-
const { responseHeaders, value: response } = await
|
|
5494
|
+
const { responseHeaders, value: response } = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
5495
5495
|
url: `${(_a15 = this.config.baseURL) != null ? _a15 : "https://api.x.ai/v1"}/responses`,
|
|
5496
|
-
headers:
|
|
5496
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
5497
5497
|
body,
|
|
5498
5498
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
5499
|
-
successfulResponseHandler:
|
|
5499
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createEventSourceResponseHandler2(
|
|
5500
5500
|
xaiResponsesChunkSchema
|
|
5501
5501
|
),
|
|
5502
5502
|
abortSignal: options.abortSignal,
|
|
@@ -5915,7 +5915,7 @@ var codeExecutionOutputSchema = v4.z.object({
|
|
|
5915
5915
|
output: v4.z.string().describe("the output of the code execution"),
|
|
5916
5916
|
error: v4.z.string().optional().describe("any error that occurred")
|
|
5917
5917
|
});
|
|
5918
|
-
var codeExecutionToolFactory =
|
|
5918
|
+
var codeExecutionToolFactory = chunkOCWTM757_cjs.createProviderToolFactoryWithOutputSchema({
|
|
5919
5919
|
id: "xai.code_execution",
|
|
5920
5920
|
inputSchema: v4.z.object({}).describe("no input parameters"),
|
|
5921
5921
|
outputSchema: codeExecutionOutputSchema
|
|
@@ -5925,7 +5925,7 @@ var viewImageOutputSchema = v4.z.object({
|
|
|
5925
5925
|
description: v4.z.string().describe("description of the image"),
|
|
5926
5926
|
objects: v4.z.array(v4.z.string()).optional().describe("objects detected in the image")
|
|
5927
5927
|
});
|
|
5928
|
-
var viewImageToolFactory =
|
|
5928
|
+
var viewImageToolFactory = chunkOCWTM757_cjs.createProviderToolFactoryWithOutputSchema({
|
|
5929
5929
|
id: "xai.view_image",
|
|
5930
5930
|
inputSchema: v4.z.object({}).describe("no input parameters"),
|
|
5931
5931
|
outputSchema: viewImageOutputSchema
|
|
@@ -5936,7 +5936,7 @@ var viewXVideoOutputSchema = v4.z.object({
|
|
|
5936
5936
|
description: v4.z.string().describe("description of the video content"),
|
|
5937
5937
|
duration: v4.z.number().optional().describe("duration in seconds")
|
|
5938
5938
|
});
|
|
5939
|
-
var viewXVideoToolFactory =
|
|
5939
|
+
var viewXVideoToolFactory = chunkOCWTM757_cjs.createProviderToolFactoryWithOutputSchema({
|
|
5940
5940
|
id: "xai.view_x_video",
|
|
5941
5941
|
inputSchema: v4.z.object({}).describe("no input parameters"),
|
|
5942
5942
|
outputSchema: viewXVideoOutputSchema
|
|
@@ -5996,8 +5996,8 @@ var runtimeSchema = v4.z.object({
|
|
|
5996
5996
|
referenceImageUrls: v4.z.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
5997
5997
|
...baseFields
|
|
5998
5998
|
}).passthrough();
|
|
5999
|
-
var xaiVideoModelOptionsSchema =
|
|
6000
|
-
() =>
|
|
5999
|
+
var xaiVideoModelOptionsSchema = chunkOCWTM757_cjs.lazySchema2(
|
|
6000
|
+
() => chunkOCWTM757_cjs.zodSchema2(runtimeSchema)
|
|
6001
6001
|
);
|
|
6002
6002
|
var RESOLUTION_MAP = {
|
|
6003
6003
|
"1280x720": "720p",
|
|
@@ -6030,7 +6030,7 @@ var XaiVideoModel = class {
|
|
|
6030
6030
|
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
6031
6031
|
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
6032
6032
|
const warnings = [];
|
|
6033
|
-
const xaiOptions = await
|
|
6033
|
+
const xaiOptions = await chunkOCWTM757_cjs.parseProviderOptions2({
|
|
6034
6034
|
provider: "xai",
|
|
6035
6035
|
providerOptions: options.providerOptions,
|
|
6036
6036
|
schema: xaiVideoModelOptionsSchema
|
|
@@ -6132,7 +6132,7 @@ var XaiVideoModel = class {
|
|
|
6132
6132
|
if (options.image.type === "url") {
|
|
6133
6133
|
body.image = { url: options.image.url };
|
|
6134
6134
|
} else {
|
|
6135
|
-
const base64Data = typeof options.image.data === "string" ? options.image.data :
|
|
6135
|
+
const base64Data = typeof options.image.data === "string" ? options.image.data : chunkOCWTM757_cjs.convertUint8ArrayToBase642(options.image.data);
|
|
6136
6136
|
body.image = {
|
|
6137
6137
|
url: `data:${options.image.mediaType};base64,${base64Data}`
|
|
6138
6138
|
};
|
|
@@ -6166,12 +6166,12 @@ var XaiVideoModel = class {
|
|
|
6166
6166
|
} else {
|
|
6167
6167
|
endpoint = `${baseURL}/videos/generations`;
|
|
6168
6168
|
}
|
|
6169
|
-
const { value: createResponse } = await
|
|
6169
|
+
const { value: createResponse } = await chunkOCWTM757_cjs.postJsonToApi2({
|
|
6170
6170
|
url: endpoint,
|
|
6171
|
-
headers:
|
|
6171
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
6172
6172
|
body,
|
|
6173
6173
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
6174
|
-
successfulResponseHandler:
|
|
6174
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
6175
6175
|
xaiCreateVideoResponseSchema
|
|
6176
6176
|
),
|
|
6177
6177
|
abortSignal: options.abortSignal,
|
|
@@ -6179,7 +6179,7 @@ var XaiVideoModel = class {
|
|
|
6179
6179
|
});
|
|
6180
6180
|
const requestId = createResponse.request_id;
|
|
6181
6181
|
if (!requestId) {
|
|
6182
|
-
throw new
|
|
6182
|
+
throw new chunkOCWTM757_cjs.AISDKError2({
|
|
6183
6183
|
name: "XAI_VIDEO_GENERATION_ERROR",
|
|
6184
6184
|
message: `No request_id returned from xAI API. Response: ${JSON.stringify(createResponse)}`
|
|
6185
6185
|
});
|
|
@@ -6189,17 +6189,17 @@ var XaiVideoModel = class {
|
|
|
6189
6189
|
const startTime = Date.now();
|
|
6190
6190
|
let responseHeaders;
|
|
6191
6191
|
while (true) {
|
|
6192
|
-
await
|
|
6192
|
+
await chunkOCWTM757_cjs.delay(pollIntervalMs, { abortSignal: options.abortSignal });
|
|
6193
6193
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
6194
|
-
throw new
|
|
6194
|
+
throw new chunkOCWTM757_cjs.AISDKError2({
|
|
6195
6195
|
name: "XAI_VIDEO_GENERATION_TIMEOUT",
|
|
6196
6196
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
6197
6197
|
});
|
|
6198
6198
|
}
|
|
6199
|
-
const { value: statusResponse, responseHeaders: pollHeaders } = await
|
|
6199
|
+
const { value: statusResponse, responseHeaders: pollHeaders } = await chunkOCWTM757_cjs.getFromApi({
|
|
6200
6200
|
url: `${baseURL}/videos/${requestId}`,
|
|
6201
|
-
headers:
|
|
6202
|
-
successfulResponseHandler:
|
|
6201
|
+
headers: chunkOCWTM757_cjs.combineHeaders2(this.config.headers(), options.headers),
|
|
6202
|
+
successfulResponseHandler: chunkOCWTM757_cjs.createJsonResponseHandler2(
|
|
6203
6203
|
xaiVideoStatusResponseSchema
|
|
6204
6204
|
),
|
|
6205
6205
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
@@ -6209,13 +6209,13 @@ var XaiVideoModel = class {
|
|
|
6209
6209
|
responseHeaders = pollHeaders;
|
|
6210
6210
|
if (statusResponse.status === "done" || statusResponse.status == null && ((_g = statusResponse.video) == null ? void 0 : _g.url)) {
|
|
6211
6211
|
if (((_h = statusResponse.video) == null ? void 0 : _h.respect_moderation) === false) {
|
|
6212
|
-
throw new
|
|
6212
|
+
throw new chunkOCWTM757_cjs.AISDKError2({
|
|
6213
6213
|
name: "XAI_VIDEO_MODERATION_ERROR",
|
|
6214
6214
|
message: "Video generation was blocked due to a content policy violation."
|
|
6215
6215
|
});
|
|
6216
6216
|
}
|
|
6217
6217
|
if (!((_i = statusResponse.video) == null ? void 0 : _i.url)) {
|
|
6218
|
-
throw new
|
|
6218
|
+
throw new chunkOCWTM757_cjs.AISDKError2({
|
|
6219
6219
|
name: "XAI_VIDEO_GENERATION_ERROR",
|
|
6220
6220
|
message: "Video generation completed but no video URL was returned."
|
|
6221
6221
|
});
|
|
@@ -6246,13 +6246,13 @@ var XaiVideoModel = class {
|
|
|
6246
6246
|
};
|
|
6247
6247
|
}
|
|
6248
6248
|
if (statusResponse.status === "expired") {
|
|
6249
|
-
throw new
|
|
6249
|
+
throw new chunkOCWTM757_cjs.AISDKError2({
|
|
6250
6250
|
name: "XAI_VIDEO_GENERATION_EXPIRED",
|
|
6251
6251
|
message: "Video generation request expired."
|
|
6252
6252
|
});
|
|
6253
6253
|
}
|
|
6254
6254
|
if (statusResponse.status === "failed") {
|
|
6255
|
-
throw new
|
|
6255
|
+
throw new chunkOCWTM757_cjs.AISDKError2({
|
|
6256
6256
|
name: "XAI_VIDEO_GENERATION_FAILED",
|
|
6257
6257
|
message: "Video generation failed."
|
|
6258
6258
|
});
|
|
@@ -6282,12 +6282,12 @@ var xaiVideoStatusResponseSchema = v4.z.object({
|
|
|
6282
6282
|
});
|
|
6283
6283
|
function createXai(options = {}) {
|
|
6284
6284
|
var _a15;
|
|
6285
|
-
const baseURL =
|
|
6285
|
+
const baseURL = chunkOCWTM757_cjs.withoutTrailingSlash2(
|
|
6286
6286
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.x.ai/v1"
|
|
6287
6287
|
);
|
|
6288
|
-
const getHeaders = () =>
|
|
6288
|
+
const getHeaders = () => chunkOCWTM757_cjs.withUserAgentSuffix2(
|
|
6289
6289
|
{
|
|
6290
|
-
Authorization: `Bearer ${
|
|
6290
|
+
Authorization: `Bearer ${chunkOCWTM757_cjs.loadApiKey2({
|
|
6291
6291
|
apiKey: options.apiKey,
|
|
6292
6292
|
environmentVariableName: "XAI_API_KEY",
|
|
6293
6293
|
description: "xAI API key"
|
|
@@ -6301,7 +6301,7 @@ function createXai(options = {}) {
|
|
|
6301
6301
|
provider: "xai.chat",
|
|
6302
6302
|
baseURL,
|
|
6303
6303
|
headers: getHeaders,
|
|
6304
|
-
generateId:
|
|
6304
|
+
generateId: chunkOCWTM757_cjs.generateId2,
|
|
6305
6305
|
fetch: options.fetch
|
|
6306
6306
|
});
|
|
6307
6307
|
};
|
|
@@ -6310,7 +6310,7 @@ function createXai(options = {}) {
|
|
|
6310
6310
|
provider: "xai.responses",
|
|
6311
6311
|
baseURL,
|
|
6312
6312
|
headers: getHeaders,
|
|
6313
|
-
generateId:
|
|
6313
|
+
generateId: chunkOCWTM757_cjs.generateId2,
|
|
6314
6314
|
fetch: options.fetch
|
|
6315
6315
|
});
|
|
6316
6316
|
};
|
|
@@ -6336,7 +6336,7 @@ function createXai(options = {}) {
|
|
|
6336
6336
|
provider.chat = createChatLanguageModel;
|
|
6337
6337
|
provider.responses = createResponsesLanguageModel;
|
|
6338
6338
|
provider.embeddingModel = (modelId) => {
|
|
6339
|
-
throw new
|
|
6339
|
+
throw new chunkOCWTM757_cjs.NoSuchModelError2({ modelId, modelType: "embeddingModel" });
|
|
6340
6340
|
};
|
|
6341
6341
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
6342
6342
|
provider.imageModel = createImageModel;
|
|
@@ -8874,7 +8874,7 @@ var PROVIDER_OVERRIDES = {
|
|
|
8874
8874
|
npm: "@ai-sdk/anthropic"
|
|
8875
8875
|
}
|
|
8876
8876
|
};
|
|
8877
|
-
var ModelsDevGateway = class extends
|
|
8877
|
+
var ModelsDevGateway = class extends chunkOCWTM757_cjs.MastraModelGateway {
|
|
8878
8878
|
id = "models.dev";
|
|
8879
8879
|
name = "models.dev";
|
|
8880
8880
|
providerConfigs = {};
|
|
@@ -8890,12 +8890,12 @@ var ModelsDevGateway = class extends chunkKRYM6L4L_cjs.MastraModelGateway {
|
|
|
8890
8890
|
const data = await response.json();
|
|
8891
8891
|
const providerConfigs = {};
|
|
8892
8892
|
for (const [providerId, providerInfo] of Object.entries(data)) {
|
|
8893
|
-
if (
|
|
8893
|
+
if (chunkOCWTM757_cjs.EXCLUDED_PROVIDERS.includes(providerId)) continue;
|
|
8894
8894
|
if (!providerInfo || typeof providerInfo !== "object" || !providerInfo.models) continue;
|
|
8895
8895
|
const normalizedId = providerId;
|
|
8896
8896
|
const isOpenAICompatible = providerInfo.npm === "@ai-sdk/openai-compatible" || providerInfo.npm === "@ai-sdk/gateway" || // Vercel AI Gateway is OpenAI-compatible
|
|
8897
8897
|
normalizedId in PROVIDER_OVERRIDES;
|
|
8898
|
-
const hasInstalledPackage =
|
|
8898
|
+
const hasInstalledPackage = chunkOCWTM757_cjs.PROVIDERS_WITH_INSTALLED_PACKAGES.includes(providerId);
|
|
8899
8899
|
const hasApiAndEnv = providerInfo.api && providerInfo.env && providerInfo.env.length > 0;
|
|
8900
8900
|
if (isOpenAICompatible || hasInstalledPackage || hasApiAndEnv) {
|
|
8901
8901
|
const modelIds = Object.entries(providerInfo.models).filter(([, modelInfo]) => modelInfo?.status !== "deprecated").map(([modelId]) => modelId).sort();
|
|
@@ -8958,15 +8958,15 @@ var ModelsDevGateway = class extends chunkKRYM6L4L_cjs.MastraModelGateway {
|
|
|
8958
8958
|
headers
|
|
8959
8959
|
}) {
|
|
8960
8960
|
const baseURL = this.buildUrl(`${providerId}/${modelId}`);
|
|
8961
|
-
const mastraHeaders = { "User-Agent":
|
|
8961
|
+
const mastraHeaders = { "User-Agent": chunkOCWTM757_cjs.MASTRA_USER_AGENT, ...headers };
|
|
8962
8962
|
switch (providerId) {
|
|
8963
8963
|
case "openai":
|
|
8964
|
-
return
|
|
8964
|
+
return chunkOCWTM757_cjs.createOpenAI({ apiKey, headers: mastraHeaders }).responses(modelId);
|
|
8965
8965
|
case "gemini":
|
|
8966
8966
|
case "google":
|
|
8967
|
-
return
|
|
8967
|
+
return chunkOCWTM757_cjs.createGoogleGenerativeAI({ apiKey, headers: mastraHeaders }).chat(modelId);
|
|
8968
8968
|
case "anthropic":
|
|
8969
|
-
return
|
|
8969
|
+
return chunkOCWTM757_cjs.createAnthropic({ apiKey, headers: mastraHeaders })(modelId);
|
|
8970
8970
|
case "mistral":
|
|
8971
8971
|
return createMistral({ apiKey, headers: mastraHeaders })(modelId);
|
|
8972
8972
|
case "groq":
|
|
@@ -8990,29 +8990,29 @@ var ModelsDevGateway = class extends chunkKRYM6L4L_cjs.MastraModelGateway {
|
|
|
8990
8990
|
case "moonshotai":
|
|
8991
8991
|
case "moonshotai-cn": {
|
|
8992
8992
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
8993
|
-
return
|
|
8993
|
+
return chunkOCWTM757_cjs.createAnthropic({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
8994
8994
|
}
|
|
8995
8995
|
default: {
|
|
8996
8996
|
const config = this.providerConfigs[providerId];
|
|
8997
8997
|
const npm = config?.npm;
|
|
8998
8998
|
if (npm === "@ai-sdk/anthropic") {
|
|
8999
8999
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
9000
|
-
return
|
|
9000
|
+
return chunkOCWTM757_cjs.createAnthropic({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
9001
9001
|
}
|
|
9002
9002
|
if (npm === "@ai-sdk/openai") {
|
|
9003
9003
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
9004
|
-
return
|
|
9004
|
+
return chunkOCWTM757_cjs.createOpenAI({ apiKey, baseURL, headers: mastraHeaders }).chat(modelId);
|
|
9005
9005
|
}
|
|
9006
9006
|
if (npm === "@ai-sdk/google") {
|
|
9007
9007
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
9008
|
-
return
|
|
9008
|
+
return chunkOCWTM757_cjs.createGoogleGenerativeAI({ apiKey, baseURL, headers: mastraHeaders }).chat(modelId);
|
|
9009
9009
|
}
|
|
9010
9010
|
if (npm === "@ai-sdk/mistral") {
|
|
9011
9011
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
9012
9012
|
return createMistral({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
9013
9013
|
}
|
|
9014
9014
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
9015
|
-
return
|
|
9015
|
+
return chunkOCWTM757_cjs.createOpenAICompatible({
|
|
9016
9016
|
name: providerId,
|
|
9017
9017
|
apiKey,
|
|
9018
9018
|
baseURL,
|
|
@@ -9027,5 +9027,5 @@ var ModelsDevGateway = class extends chunkKRYM6L4L_cjs.MastraModelGateway {
|
|
|
9027
9027
|
exports.ModelsDevGateway = ModelsDevGateway;
|
|
9028
9028
|
exports.createOpenRouter = createOpenRouter;
|
|
9029
9029
|
exports.parseModelRouterId = parseModelRouterId;
|
|
9030
|
-
//# sourceMappingURL=chunk-
|
|
9031
|
-
//# sourceMappingURL=chunk-
|
|
9030
|
+
//# sourceMappingURL=chunk-AVGHSESJ.cjs.map
|
|
9031
|
+
//# sourceMappingURL=chunk-AVGHSESJ.cjs.map
|