@mastra/core 1.13.1 → 1.13.2
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 +18 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-334VHLAR.cjs → chunk-2AWGYDG4.cjs} +23 -23
- package/dist/{chunk-334VHLAR.cjs.map → chunk-2AWGYDG4.cjs.map} +1 -1
- package/dist/{chunk-YWZ4XNJQ.js → chunk-2FTBI54H.js} +4 -4
- package/dist/{chunk-YWZ4XNJQ.js.map → chunk-2FTBI54H.js.map} +1 -1
- package/dist/{chunk-B3GKSY42.js → chunk-2PJMYJB2.js} +3 -3
- package/dist/{chunk-B3GKSY42.js.map → chunk-2PJMYJB2.js.map} +1 -1
- package/dist/{chunk-6Q3ZFEII.cjs → chunk-4MKCST44.cjs} +3 -3
- package/dist/{chunk-6Q3ZFEII.cjs.map → chunk-4MKCST44.cjs.map} +1 -1
- package/dist/{chunk-RGG5FM37.js → chunk-6GUJEQ3U.js} +4 -4
- package/dist/{chunk-RGG5FM37.js.map → chunk-6GUJEQ3U.js.map} +1 -1
- package/dist/{chunk-GP4MO5B6.js → chunk-6OYGEMV6.js} +3 -3
- package/dist/chunk-6OYGEMV6.js.map +1 -0
- package/dist/{chunk-IBB623FC.js → chunk-7DGI2TU4.js} +6 -6
- package/dist/{chunk-IBB623FC.js.map → chunk-7DGI2TU4.js.map} +1 -1
- package/dist/{chunk-7XDXDITO.cjs → chunk-7ZYGR5WJ.cjs} +7 -7
- package/dist/{chunk-7XDXDITO.cjs.map → chunk-7ZYGR5WJ.cjs.map} +1 -1
- package/dist/{chunk-Z7DIN6EF.cjs → chunk-CFRWCOK6.cjs} +6 -6
- package/dist/{chunk-Z7DIN6EF.cjs.map → chunk-CFRWCOK6.cjs.map} +1 -1
- package/dist/{chunk-DE2ZO3EV.cjs → chunk-EMB234CP.cjs} +47 -47
- package/dist/{chunk-DE2ZO3EV.cjs.map → chunk-EMB234CP.cjs.map} +1 -1
- package/dist/{chunk-S255NXHH.cjs → chunk-F5254W6E.cjs} +11 -11
- package/dist/chunk-F5254W6E.cjs.map +1 -0
- package/dist/{chunk-J333Z653.cjs → chunk-FVP6VEKR.cjs} +9 -9
- package/dist/{chunk-J333Z653.cjs.map → chunk-FVP6VEKR.cjs.map} +1 -1
- package/dist/{chunk-FERHLP5X.js → chunk-IXI5TASW.js} +4 -4
- package/dist/{chunk-FERHLP5X.js.map → chunk-IXI5TASW.js.map} +1 -1
- package/dist/{chunk-UAVVTLHL.cjs → chunk-LJMYIOTZ.cjs} +5 -5
- package/dist/{chunk-UAVVTLHL.cjs.map → chunk-LJMYIOTZ.cjs.map} +1 -1
- package/dist/{chunk-CVHX5NQY.cjs → chunk-MRNTJIUP.cjs} +15 -15
- package/dist/{chunk-CVHX5NQY.cjs.map → chunk-MRNTJIUP.cjs.map} +1 -1
- package/dist/{chunk-5QTS4EAT.js → chunk-PQAOVJLU.js} +3 -3
- package/dist/{chunk-5QTS4EAT.js.map → chunk-PQAOVJLU.js.map} +1 -1
- package/dist/{chunk-V2NCW7QL.cjs → chunk-QXQMTR5Q.cjs} +5 -5
- package/dist/{chunk-V2NCW7QL.cjs.map → chunk-QXQMTR5Q.cjs.map} +1 -1
- package/dist/{chunk-ZX4VFWA4.js → chunk-SE67K6Q3.js} +3 -3
- package/dist/{chunk-ZX4VFWA4.js.map → chunk-SE67K6Q3.js.map} +1 -1
- package/dist/{chunk-AMNS5DF2.js → chunk-V5ZXOW33.js} +8 -8
- package/dist/{chunk-AMNS5DF2.js.map → chunk-V5ZXOW33.js.map} +1 -1
- package/dist/{chunk-LYABHLZT.js → chunk-VHLXGAED.js} +3 -3
- package/dist/{chunk-LYABHLZT.js.map → chunk-VHLXGAED.js.map} +1 -1
- package/dist/{chunk-P2F6NZPK.cjs → chunk-VX2T4M3C.cjs} +185 -185
- package/dist/{chunk-P2F6NZPK.cjs.map → chunk-VX2T4M3C.cjs.map} +1 -1
- package/dist/{chunk-R5GYOR52.js → chunk-ZPAAZIHS.js} +3 -3
- package/dist/{chunk-R5GYOR52.js.map → chunk-ZPAAZIHS.js.map} +1 -1
- package/dist/datasets/index.cjs +11 -11
- package/dist/datasets/index.js +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +119 -119
- 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 +16 -16
- 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/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/memory/types.d.ts +1 -1
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-KUN5WMTQ.cjs +12 -0
- package/dist/{models-dev-NNNX6HMQ.cjs.map → models-dev-KUN5WMTQ.cjs.map} +1 -1
- package/dist/models-dev-NHSW7E3D.js +3 -0
- package/dist/{models-dev-J6H4MDDS.js.map → models-dev-NHSW7E3D.js.map} +1 -1
- package/dist/netlify-TVVX7BMC.cjs +12 -0
- package/dist/{netlify-3DEYXRVR.cjs.map → netlify-TVVX7BMC.cjs.map} +1 -1
- package/dist/netlify-YDYR2QSI.js +3 -0
- package/dist/{netlify-45XINYG6.js.map → netlify-YDYR2QSI.js.map} +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +42 -42
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-2REK4G5M.js +3 -0
- package/dist/{provider-registry-YCFZ6HTH.js.map → provider-registry-2REK4G5M.js.map} +1 -1
- package/dist/provider-registry-73GVT5AT.cjs +40 -0
- package/dist/{provider-registry-LSMHTOLE.cjs.map → provider-registry-73GVT5AT.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 +10 -10
- package/dist/chunk-GP4MO5B6.js.map +0 -1
- package/dist/chunk-S255NXHH.cjs.map +0 -1
- package/dist/models-dev-J6H4MDDS.js +0 -3
- package/dist/models-dev-NNNX6HMQ.cjs +0 -12
- package/dist/netlify-3DEYXRVR.cjs +0 -12
- package/dist/netlify-45XINYG6.js +0 -3
- package/dist/provider-registry-LSMHTOLE.cjs +0 -40
- package/dist/provider-registry-YCFZ6HTH.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4MKCST44_cjs = require('./chunk-4MKCST44.cjs');
|
|
4
4
|
var chunk3UVEHZM4_cjs = require('./chunk-3UVEHZM4.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 = chunk4MKCST44_cjs.withoutTrailingSlash(
|
|
21
21
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.cerebras.ai/v1"
|
|
22
22
|
);
|
|
23
|
-
const getHeaders = () =>
|
|
23
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
24
24
|
{
|
|
25
|
-
Authorization: `Bearer ${
|
|
25
|
+
Authorization: `Bearer ${chunk4MKCST44_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 chunk4MKCST44_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 chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
49
49
|
};
|
|
50
50
|
provider.imageModel = (modelId) => {
|
|
51
|
-
throw new
|
|
51
|
+
throw new chunk4MKCST44_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 chunk4MKCST44_cjs.postJsonToApi({
|
|
81
81
|
url: `${this.config.baseURL}/${this.modelId}`,
|
|
82
|
-
headers:
|
|
82
|
+
headers: chunk4MKCST44_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: chunk4MKCST44_cjs.createJsonErrorResponseHandler({
|
|
92
92
|
errorSchema: deepInfraErrorSchema,
|
|
93
93
|
errorToMessage: (error) => error.detail.error
|
|
94
94
|
}),
|
|
95
|
-
successfulResponseHandler:
|
|
95
|
+
successfulResponseHandler: chunk4MKCST44_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 chunk4MKCST44_cjs.OpenAICompatibleChatLanguageModel {
|
|
123
123
|
constructor(modelId, config) {
|
|
124
124
|
super(modelId, config);
|
|
125
125
|
}
|
|
@@ -170,12 +170,12 @@ var DeepInfraChatLanguageModel = class extends chunk6Q3ZFEII_cjs.OpenAICompatibl
|
|
|
170
170
|
var VERSION2 = "1.0.35" ;
|
|
171
171
|
function createDeepInfra(options = {}) {
|
|
172
172
|
var _a15;
|
|
173
|
-
const baseURL =
|
|
173
|
+
const baseURL = chunk4MKCST44_cjs.withoutTrailingSlash(
|
|
174
174
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.deepinfra.com/v1"
|
|
175
175
|
);
|
|
176
|
-
const getHeaders = () =>
|
|
176
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
177
177
|
{
|
|
178
|
-
Authorization: `Bearer ${
|
|
178
|
+
Authorization: `Bearer ${chunk4MKCST44_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 chunk4MKCST44_cjs.OpenAICompatibleCompletionLanguageModel(
|
|
200
200
|
modelId,
|
|
201
201
|
getCommonModelConfig("completion")
|
|
202
202
|
);
|
|
203
|
-
const createTextEmbeddingModel = (modelId) => new
|
|
203
|
+
const createTextEmbeddingModel = (modelId) => new chunk4MKCST44_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 = chunk4MKCST44_cjs.lazySchema(
|
|
393
|
+
() => chunk4MKCST44_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 chunk4MKCST44_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 = chunk4MKCST44_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 chunk4MKCST44_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 chunk4MKCST44_cjs.postJsonToApi({
|
|
595
595
|
url: this.config.url({
|
|
596
596
|
path: "/chat/completions",
|
|
597
597
|
modelId: this.modelId
|
|
598
598
|
}),
|
|
599
|
-
headers:
|
|
599
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
600
600
|
body: args,
|
|
601
601
|
failedResponseHandler: this.failedResponseHandler,
|
|
602
|
-
successfulResponseHandler:
|
|
602
|
+
successfulResponseHandler: chunk4MKCST44_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 : chunk4MKCST44_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 chunk4MKCST44_cjs.postJsonToApi({
|
|
664
664
|
url: this.config.url({
|
|
665
665
|
path: "/chat/completions",
|
|
666
666
|
modelId: this.modelId
|
|
667
667
|
}),
|
|
668
|
-
headers:
|
|
668
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
669
669
|
body,
|
|
670
670
|
failedResponseHandler: this.failedResponseHandler,
|
|
671
|
-
successfulResponseHandler:
|
|
671
|
+
successfulResponseHandler: chunk4MKCST44_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 chunk4MKCST44_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 chunk4MKCST44_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 (chunk4MKCST44_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 : chunk4MKCST44_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 && chunk4MKCST44_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 : chunk4MKCST44_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 : chunk4MKCST44_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.33" ;
|
|
895
895
|
function createDeepSeek(options = {}) {
|
|
896
896
|
var _a15;
|
|
897
|
-
const baseURL =
|
|
897
|
+
const baseURL = chunk4MKCST44_cjs.withoutTrailingSlash(
|
|
898
898
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.deepseek.com"
|
|
899
899
|
);
|
|
900
|
-
const getHeaders = () =>
|
|
900
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
901
901
|
{
|
|
902
|
-
Authorization: `Bearer ${
|
|
902
|
+
Authorization: `Bearer ${chunk4MKCST44_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 chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
924
924
|
};
|
|
925
925
|
provider.imageModel = (modelId) => {
|
|
926
|
-
throw new
|
|
926
|
+
throw new chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
927
927
|
};
|
|
928
928
|
return provider;
|
|
929
929
|
}
|
|
@@ -950,7 +950,7 @@ function convertToGroqChatMessages(prompt) {
|
|
|
950
950
|
}
|
|
951
951
|
case "file": {
|
|
952
952
|
if (!part.mediaType.startsWith("image/")) {
|
|
953
|
-
throw new
|
|
953
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
954
954
|
functionality: "Non-image file content parts"
|
|
955
955
|
});
|
|
956
956
|
}
|
|
@@ -958,7 +958,7 @@ function convertToGroqChatMessages(prompt) {
|
|
|
958
958
|
return {
|
|
959
959
|
type: "image_url",
|
|
960
960
|
image_url: {
|
|
961
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
961
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunk4MKCST44_cjs.convertToBase64(part.data)}`
|
|
962
962
|
}
|
|
963
963
|
};
|
|
964
964
|
}
|
|
@@ -1084,7 +1084,7 @@ var groqErrorDataSchema = v4.z.object({
|
|
|
1084
1084
|
type: v4.z.string()
|
|
1085
1085
|
})
|
|
1086
1086
|
});
|
|
1087
|
-
var groqFailedResponseHandler =
|
|
1087
|
+
var groqFailedResponseHandler = chunk4MKCST44_cjs.createJsonErrorResponseHandler({
|
|
1088
1088
|
errorSchema: groqErrorDataSchema,
|
|
1089
1089
|
errorToMessage: (data) => data.error.message
|
|
1090
1090
|
});
|
|
@@ -1159,7 +1159,7 @@ function prepareTools2({
|
|
|
1159
1159
|
};
|
|
1160
1160
|
default: {
|
|
1161
1161
|
const _exhaustiveCheck = type;
|
|
1162
|
-
throw new
|
|
1162
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
1163
1163
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1164
1164
|
});
|
|
1165
1165
|
}
|
|
@@ -1210,7 +1210,7 @@ var GroqChatLanguageModel = class {
|
|
|
1210
1210
|
}) {
|
|
1211
1211
|
var _a15, _b;
|
|
1212
1212
|
const warnings = [];
|
|
1213
|
-
const groqOptions = await
|
|
1213
|
+
const groqOptions = await chunk4MKCST44_cjs.parseProviderOptions({
|
|
1214
1214
|
provider: "groq",
|
|
1215
1215
|
providerOptions,
|
|
1216
1216
|
schema: groqProviderOptions
|
|
@@ -1282,15 +1282,15 @@ var GroqChatLanguageModel = class {
|
|
|
1282
1282
|
responseHeaders,
|
|
1283
1283
|
value: response,
|
|
1284
1284
|
rawValue: rawResponse
|
|
1285
|
-
} = await
|
|
1285
|
+
} = await chunk4MKCST44_cjs.postJsonToApi({
|
|
1286
1286
|
url: this.config.url({
|
|
1287
1287
|
path: "/chat/completions",
|
|
1288
1288
|
modelId: this.modelId
|
|
1289
1289
|
}),
|
|
1290
|
-
headers:
|
|
1290
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
1291
1291
|
body: args,
|
|
1292
1292
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1293
|
-
successfulResponseHandler:
|
|
1293
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
1294
1294
|
groqChatResponseSchema
|
|
1295
1295
|
),
|
|
1296
1296
|
abortSignal: options.abortSignal,
|
|
@@ -1313,7 +1313,7 @@ var GroqChatLanguageModel = class {
|
|
|
1313
1313
|
for (const toolCall of choice.message.tool_calls) {
|
|
1314
1314
|
content.push({
|
|
1315
1315
|
type: "tool-call",
|
|
1316
|
-
toolCallId: (_a15 = toolCall.id) != null ? _a15 :
|
|
1316
|
+
toolCallId: (_a15 = toolCall.id) != null ? _a15 : chunk4MKCST44_cjs.generateId(),
|
|
1317
1317
|
toolName: toolCall.function.name,
|
|
1318
1318
|
input: toolCall.function.arguments
|
|
1319
1319
|
});
|
|
@@ -1340,18 +1340,18 @@ var GroqChatLanguageModel = class {
|
|
|
1340
1340
|
async doStream(options) {
|
|
1341
1341
|
const { args, warnings } = await this.getArgs({ ...options, stream: true });
|
|
1342
1342
|
const body = JSON.stringify({ ...args, stream: true });
|
|
1343
|
-
const { responseHeaders, value: response } = await
|
|
1343
|
+
const { responseHeaders, value: response } = await chunk4MKCST44_cjs.postJsonToApi({
|
|
1344
1344
|
url: this.config.url({
|
|
1345
1345
|
path: "/chat/completions",
|
|
1346
1346
|
modelId: this.modelId
|
|
1347
1347
|
}),
|
|
1348
|
-
headers:
|
|
1348
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
1349
1349
|
body: {
|
|
1350
1350
|
...args,
|
|
1351
1351
|
stream: true
|
|
1352
1352
|
},
|
|
1353
1353
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1354
|
-
successfulResponseHandler:
|
|
1354
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createEventSourceResponseHandler(groqChatChunkSchema),
|
|
1355
1355
|
abortSignal: options.abortSignal,
|
|
1356
1356
|
fetch: this.config.fetch
|
|
1357
1357
|
});
|
|
@@ -1439,19 +1439,19 @@ var GroqChatLanguageModel = class {
|
|
|
1439
1439
|
const index = toolCallDelta.index;
|
|
1440
1440
|
if (toolCalls[index] == null) {
|
|
1441
1441
|
if (toolCallDelta.type !== "function") {
|
|
1442
|
-
throw new
|
|
1442
|
+
throw new chunk4MKCST44_cjs.InvalidResponseDataError({
|
|
1443
1443
|
data: toolCallDelta,
|
|
1444
1444
|
message: `Expected 'function' type.`
|
|
1445
1445
|
});
|
|
1446
1446
|
}
|
|
1447
1447
|
if (toolCallDelta.id == null) {
|
|
1448
|
-
throw new
|
|
1448
|
+
throw new chunk4MKCST44_cjs.InvalidResponseDataError({
|
|
1449
1449
|
data: toolCallDelta,
|
|
1450
1450
|
message: `Expected 'id' to be a string.`
|
|
1451
1451
|
});
|
|
1452
1452
|
}
|
|
1453
1453
|
if (((_g = toolCallDelta.function) == null ? void 0 : _g.name) == null) {
|
|
1454
|
-
throw new
|
|
1454
|
+
throw new chunk4MKCST44_cjs.InvalidResponseDataError({
|
|
1455
1455
|
data: toolCallDelta,
|
|
1456
1456
|
message: `Expected 'function.name' to be a string.`
|
|
1457
1457
|
});
|
|
@@ -1479,14 +1479,14 @@ var GroqChatLanguageModel = class {
|
|
|
1479
1479
|
delta: toolCall2.function.arguments
|
|
1480
1480
|
});
|
|
1481
1481
|
}
|
|
1482
|
-
if (
|
|
1482
|
+
if (chunk4MKCST44_cjs.isParsableJson(toolCall2.function.arguments)) {
|
|
1483
1483
|
controller.enqueue({
|
|
1484
1484
|
type: "tool-input-end",
|
|
1485
1485
|
id: toolCall2.id
|
|
1486
1486
|
});
|
|
1487
1487
|
controller.enqueue({
|
|
1488
1488
|
type: "tool-call",
|
|
1489
|
-
toolCallId: (_k = toolCall2.id) != null ? _k :
|
|
1489
|
+
toolCallId: (_k = toolCall2.id) != null ? _k : chunk4MKCST44_cjs.generateId(),
|
|
1490
1490
|
toolName: toolCall2.function.name,
|
|
1491
1491
|
input: toolCall2.function.arguments
|
|
1492
1492
|
});
|
|
@@ -1507,14 +1507,14 @@ var GroqChatLanguageModel = class {
|
|
|
1507
1507
|
id: toolCall.id,
|
|
1508
1508
|
delta: (_o = toolCallDelta.function.arguments) != null ? _o : ""
|
|
1509
1509
|
});
|
|
1510
|
-
if (((_p = toolCall.function) == null ? void 0 : _p.name) != null && ((_q = toolCall.function) == null ? void 0 : _q.arguments) != null &&
|
|
1510
|
+
if (((_p = toolCall.function) == null ? void 0 : _p.name) != null && ((_q = toolCall.function) == null ? void 0 : _q.arguments) != null && chunk4MKCST44_cjs.isParsableJson(toolCall.function.arguments)) {
|
|
1511
1511
|
controller.enqueue({
|
|
1512
1512
|
type: "tool-input-end",
|
|
1513
1513
|
id: toolCall.id
|
|
1514
1514
|
});
|
|
1515
1515
|
controller.enqueue({
|
|
1516
1516
|
type: "tool-call",
|
|
1517
|
-
toolCallId: (_r = toolCall.id) != null ? _r :
|
|
1517
|
+
toolCallId: (_r = toolCall.id) != null ? _r : chunk4MKCST44_cjs.generateId(),
|
|
1518
1518
|
toolName: toolCall.function.name,
|
|
1519
1519
|
input: toolCall.function.arguments
|
|
1520
1520
|
});
|
|
@@ -1639,15 +1639,15 @@ var GroqTranscriptionModel = class {
|
|
|
1639
1639
|
}) {
|
|
1640
1640
|
var _a15, _b, _c, _d, _e;
|
|
1641
1641
|
const warnings = [];
|
|
1642
|
-
const groqOptions = await
|
|
1642
|
+
const groqOptions = await chunk4MKCST44_cjs.parseProviderOptions({
|
|
1643
1643
|
provider: "groq",
|
|
1644
1644
|
providerOptions,
|
|
1645
1645
|
schema: groqProviderOptionsSchema
|
|
1646
1646
|
});
|
|
1647
1647
|
const formData = new FormData();
|
|
1648
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([
|
|
1648
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([chunk4MKCST44_cjs.convertBase64ToUint8Array(audio)]);
|
|
1649
1649
|
formData.append("model", this.modelId);
|
|
1650
|
-
const fileExtension =
|
|
1650
|
+
const fileExtension = chunk4MKCST44_cjs.mediaTypeToExtension(mediaType);
|
|
1651
1651
|
formData.append(
|
|
1652
1652
|
"file",
|
|
1653
1653
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -1681,15 +1681,15 @@ var GroqTranscriptionModel = class {
|
|
|
1681
1681
|
value: response,
|
|
1682
1682
|
responseHeaders,
|
|
1683
1683
|
rawValue: rawResponse
|
|
1684
|
-
} = await
|
|
1684
|
+
} = await chunk4MKCST44_cjs.postFormDataToApi({
|
|
1685
1685
|
url: this.config.url({
|
|
1686
1686
|
path: "/audio/transcriptions",
|
|
1687
1687
|
modelId: this.modelId
|
|
1688
1688
|
}),
|
|
1689
|
-
headers:
|
|
1689
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
1690
1690
|
formData,
|
|
1691
1691
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1692
|
-
successfulResponseHandler:
|
|
1692
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
1693
1693
|
groqTranscriptionResponseSchema
|
|
1694
1694
|
),
|
|
1695
1695
|
abortSignal: options.abortSignal,
|
|
@@ -1738,7 +1738,7 @@ var groqTranscriptionResponseSchema = v4.z.object({
|
|
|
1738
1738
|
})
|
|
1739
1739
|
).nullish()
|
|
1740
1740
|
});
|
|
1741
|
-
var browserSearch =
|
|
1741
|
+
var browserSearch = chunk4MKCST44_cjs.createProviderDefinedToolFactory({
|
|
1742
1742
|
id: "groq.browser_search",
|
|
1743
1743
|
name: "browser_search",
|
|
1744
1744
|
inputSchema: v4.z.object({})
|
|
@@ -1749,10 +1749,10 @@ var groqTools = {
|
|
|
1749
1749
|
var VERSION4 = "2.0.34" ;
|
|
1750
1750
|
function createGroq(options = {}) {
|
|
1751
1751
|
var _a15;
|
|
1752
|
-
const baseURL = (_a15 =
|
|
1753
|
-
const getHeaders = () =>
|
|
1752
|
+
const baseURL = (_a15 = chunk4MKCST44_cjs.withoutTrailingSlash(options.baseURL)) != null ? _a15 : "https://api.groq.com/openai/v1";
|
|
1753
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
1754
1754
|
{
|
|
1755
|
-
Authorization: `Bearer ${
|
|
1755
|
+
Authorization: `Bearer ${chunk4MKCST44_cjs.loadApiKey({
|
|
1756
1756
|
apiKey: options.apiKey,
|
|
1757
1757
|
environmentVariableName: "GROQ_API_KEY",
|
|
1758
1758
|
description: "Groq"
|
|
@@ -1789,10 +1789,10 @@ function createGroq(options = {}) {
|
|
|
1789
1789
|
provider.languageModel = createLanguageModel;
|
|
1790
1790
|
provider.chat = createChatModel;
|
|
1791
1791
|
provider.textEmbeddingModel = (modelId) => {
|
|
1792
|
-
throw new
|
|
1792
|
+
throw new chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
1793
1793
|
};
|
|
1794
1794
|
provider.imageModel = (modelId) => {
|
|
1795
|
-
throw new
|
|
1795
|
+
throw new chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
1796
1796
|
};
|
|
1797
1797
|
provider.transcription = createTranscriptionModel;
|
|
1798
1798
|
provider.transcriptionModel = createTranscriptionModel;
|
|
@@ -1823,7 +1823,7 @@ function convertToMistralChatMessages(prompt) {
|
|
|
1823
1823
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
1824
1824
|
return {
|
|
1825
1825
|
type: "image_url",
|
|
1826
|
-
image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
1826
|
+
image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunk4MKCST44_cjs.convertToBase64(part.data)}`
|
|
1827
1827
|
};
|
|
1828
1828
|
} else if (part.mediaType === "application/pdf") {
|
|
1829
1829
|
return {
|
|
@@ -1831,7 +1831,7 @@ function convertToMistralChatMessages(prompt) {
|
|
|
1831
1831
|
document_url: part.data.toString()
|
|
1832
1832
|
};
|
|
1833
1833
|
} else {
|
|
1834
|
-
throw new
|
|
1834
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
1835
1835
|
functionality: "Only images and PDF file parts are supported"
|
|
1836
1836
|
});
|
|
1837
1837
|
}
|
|
@@ -1972,7 +1972,7 @@ var mistralErrorDataSchema = v4.z.object({
|
|
|
1972
1972
|
param: v4.z.string().nullable(),
|
|
1973
1973
|
code: v4.z.string().nullable()
|
|
1974
1974
|
});
|
|
1975
|
-
var mistralFailedResponseHandler =
|
|
1975
|
+
var mistralFailedResponseHandler = chunk4MKCST44_cjs.createJsonErrorResponseHandler({
|
|
1976
1976
|
errorSchema: mistralErrorDataSchema,
|
|
1977
1977
|
errorToMessage: (data) => data.message
|
|
1978
1978
|
});
|
|
@@ -2022,7 +2022,7 @@ function prepareTools3({
|
|
|
2022
2022
|
};
|
|
2023
2023
|
default: {
|
|
2024
2024
|
const _exhaustiveCheck = type;
|
|
2025
|
-
throw new
|
|
2025
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
2026
2026
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
2027
2027
|
});
|
|
2028
2028
|
}
|
|
@@ -2037,7 +2037,7 @@ var MistralChatLanguageModel = class {
|
|
|
2037
2037
|
var _a15;
|
|
2038
2038
|
this.modelId = modelId;
|
|
2039
2039
|
this.config = config;
|
|
2040
|
-
this.generateId = (_a15 = config.generateId) != null ? _a15 :
|
|
2040
|
+
this.generateId = (_a15 = config.generateId) != null ? _a15 : chunk4MKCST44_cjs.generateId;
|
|
2041
2041
|
}
|
|
2042
2042
|
get provider() {
|
|
2043
2043
|
return this.config.provider;
|
|
@@ -2059,7 +2059,7 @@ var MistralChatLanguageModel = class {
|
|
|
2059
2059
|
}) {
|
|
2060
2060
|
var _a15, _b, _c, _d;
|
|
2061
2061
|
const warnings = [];
|
|
2062
|
-
const options = (_a15 = await
|
|
2062
|
+
const options = (_a15 = await chunk4MKCST44_cjs.parseProviderOptions({
|
|
2063
2063
|
provider: "mistral",
|
|
2064
2064
|
providerOptions,
|
|
2065
2065
|
schema: mistralLanguageModelOptions
|
|
@@ -2091,7 +2091,7 @@ var MistralChatLanguageModel = class {
|
|
|
2091
2091
|
const structuredOutputs = (_b = options.structuredOutputs) != null ? _b : true;
|
|
2092
2092
|
const strictJsonSchema = (_c = options.strictJsonSchema) != null ? _c : false;
|
|
2093
2093
|
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && !(responseFormat == null ? void 0 : responseFormat.schema)) {
|
|
2094
|
-
prompt =
|
|
2094
|
+
prompt = chunk4MKCST44_cjs.injectJsonInstructionIntoMessages({
|
|
2095
2095
|
messages: prompt,
|
|
2096
2096
|
schema: responseFormat.schema
|
|
2097
2097
|
});
|
|
@@ -2146,12 +2146,12 @@ var MistralChatLanguageModel = class {
|
|
|
2146
2146
|
responseHeaders,
|
|
2147
2147
|
value: response,
|
|
2148
2148
|
rawValue: rawResponse
|
|
2149
|
-
} = await
|
|
2149
|
+
} = await chunk4MKCST44_cjs.postJsonToApi({
|
|
2150
2150
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2151
|
-
headers:
|
|
2151
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2152
2152
|
body,
|
|
2153
2153
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2154
|
-
successfulResponseHandler:
|
|
2154
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
2155
2155
|
mistralChatResponseSchema
|
|
2156
2156
|
),
|
|
2157
2157
|
abortSignal: options.abortSignal,
|
|
@@ -2208,12 +2208,12 @@ var MistralChatLanguageModel = class {
|
|
|
2208
2208
|
async doStream(options) {
|
|
2209
2209
|
const { args, warnings } = await this.getArgs(options);
|
|
2210
2210
|
const body = { ...args, stream: true };
|
|
2211
|
-
const { responseHeaders, value: response } = await
|
|
2211
|
+
const { responseHeaders, value: response } = await chunk4MKCST44_cjs.postJsonToApi({
|
|
2212
2212
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2213
|
-
headers:
|
|
2213
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2214
2214
|
body,
|
|
2215
2215
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2216
|
-
successfulResponseHandler:
|
|
2216
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createEventSourceResponseHandler(
|
|
2217
2217
|
mistralChatChunkSchema
|
|
2218
2218
|
),
|
|
2219
2219
|
abortSignal: options.abortSignal,
|
|
@@ -2486,7 +2486,7 @@ var MistralEmbeddingModel = class {
|
|
|
2486
2486
|
headers
|
|
2487
2487
|
}) {
|
|
2488
2488
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
2489
|
-
throw new
|
|
2489
|
+
throw new chunk4MKCST44_cjs.TooManyEmbeddingValuesForCallError({
|
|
2490
2490
|
provider: this.provider,
|
|
2491
2491
|
modelId: this.modelId,
|
|
2492
2492
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -2497,16 +2497,16 @@ var MistralEmbeddingModel = class {
|
|
|
2497
2497
|
responseHeaders,
|
|
2498
2498
|
value: response,
|
|
2499
2499
|
rawValue
|
|
2500
|
-
} = await
|
|
2500
|
+
} = await chunk4MKCST44_cjs.postJsonToApi({
|
|
2501
2501
|
url: `${this.config.baseURL}/embeddings`,
|
|
2502
|
-
headers:
|
|
2502
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), headers),
|
|
2503
2503
|
body: {
|
|
2504
2504
|
model: this.modelId,
|
|
2505
2505
|
input: values,
|
|
2506
2506
|
encoding_format: "float"
|
|
2507
2507
|
},
|
|
2508
2508
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2509
|
-
successfulResponseHandler:
|
|
2509
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
2510
2510
|
MistralTextEmbeddingResponseSchema
|
|
2511
2511
|
),
|
|
2512
2512
|
abortSignal,
|
|
@@ -2526,10 +2526,10 @@ var MistralTextEmbeddingResponseSchema = v4.z.object({
|
|
|
2526
2526
|
var VERSION5 = "2.0.27" ;
|
|
2527
2527
|
function createMistral(options = {}) {
|
|
2528
2528
|
var _a15;
|
|
2529
|
-
const baseURL = (_a15 =
|
|
2530
|
-
const getHeaders = () =>
|
|
2529
|
+
const baseURL = (_a15 = chunk4MKCST44_cjs.withoutTrailingSlash(options.baseURL)) != null ? _a15 : "https://api.mistral.ai/v1";
|
|
2530
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
2531
2531
|
{
|
|
2532
|
-
Authorization: `Bearer ${
|
|
2532
|
+
Authorization: `Bearer ${chunk4MKCST44_cjs.loadApiKey({
|
|
2533
2533
|
apiKey: options.apiKey,
|
|
2534
2534
|
environmentVariableName: "MISTRAL_API_KEY",
|
|
2535
2535
|
description: "Mistral"
|
|
@@ -2565,7 +2565,7 @@ function createMistral(options = {}) {
|
|
|
2565
2565
|
provider.textEmbedding = createEmbeddingModel;
|
|
2566
2566
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
2567
2567
|
provider.imageModel = (modelId) => {
|
|
2568
|
-
throw new
|
|
2568
|
+
throw new chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
2569
2569
|
};
|
|
2570
2570
|
return provider;
|
|
2571
2571
|
}
|
|
@@ -2603,7 +2603,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2603
2603
|
} : {
|
|
2604
2604
|
type: "file_url",
|
|
2605
2605
|
file_url: {
|
|
2606
|
-
url: typeof part.data === "string" ? part.data :
|
|
2606
|
+
url: typeof part.data === "string" ? part.data : chunk4MKCST44_cjs.convertUint8ArrayToBase64(part.data)
|
|
2607
2607
|
},
|
|
2608
2608
|
file_name: part.filename || `document-${index}.pdf`
|
|
2609
2609
|
};
|
|
@@ -2616,7 +2616,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2616
2616
|
} : {
|
|
2617
2617
|
type: "image_url",
|
|
2618
2618
|
image_url: {
|
|
2619
|
-
url: `data:${(_a15 = part.mediaType) != null ? _a15 : "image/jpeg"};base64,${typeof part.data === "string" ? part.data :
|
|
2619
|
+
url: `data:${(_a15 = part.mediaType) != null ? _a15 : "image/jpeg"};base64,${typeof part.data === "string" ? part.data : chunk4MKCST44_cjs.convertUint8ArrayToBase64(part.data)}`
|
|
2620
2620
|
}
|
|
2621
2621
|
};
|
|
2622
2622
|
}
|
|
@@ -2630,7 +2630,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2630
2630
|
break;
|
|
2631
2631
|
}
|
|
2632
2632
|
case "tool": {
|
|
2633
|
-
throw new
|
|
2633
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
2634
2634
|
functionality: "Tool messages"
|
|
2635
2635
|
});
|
|
2636
2636
|
}
|
|
@@ -2725,15 +2725,15 @@ var PerplexityLanguageModel = class {
|
|
|
2725
2725
|
responseHeaders,
|
|
2726
2726
|
value: response,
|
|
2727
2727
|
rawValue: rawResponse
|
|
2728
|
-
} = await
|
|
2728
|
+
} = await chunk4MKCST44_cjs.postJsonToApi({
|
|
2729
2729
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2730
|
-
headers:
|
|
2730
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2731
2731
|
body,
|
|
2732
|
-
failedResponseHandler:
|
|
2732
|
+
failedResponseHandler: chunk4MKCST44_cjs.createJsonErrorResponseHandler({
|
|
2733
2733
|
errorSchema: perplexityErrorSchema,
|
|
2734
2734
|
errorToMessage
|
|
2735
2735
|
}),
|
|
2736
|
-
successfulResponseHandler:
|
|
2736
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
2737
2737
|
perplexityResponseSchema
|
|
2738
2738
|
),
|
|
2739
2739
|
abortSignal: options.abortSignal,
|
|
@@ -2790,15 +2790,15 @@ var PerplexityLanguageModel = class {
|
|
|
2790
2790
|
async doStream(options) {
|
|
2791
2791
|
const { args, warnings } = this.getArgs(options);
|
|
2792
2792
|
const body = { ...args, stream: true };
|
|
2793
|
-
const { responseHeaders, value: response } = await
|
|
2793
|
+
const { responseHeaders, value: response } = await chunk4MKCST44_cjs.postJsonToApi({
|
|
2794
2794
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2795
|
-
headers:
|
|
2795
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2796
2796
|
body,
|
|
2797
|
-
failedResponseHandler:
|
|
2797
|
+
failedResponseHandler: chunk4MKCST44_cjs.createJsonErrorResponseHandler({
|
|
2798
2798
|
errorSchema: perplexityErrorSchema,
|
|
2799
2799
|
errorToMessage
|
|
2800
2800
|
}),
|
|
2801
|
-
successfulResponseHandler:
|
|
2801
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createEventSourceResponseHandler(
|
|
2802
2802
|
perplexityChunkSchema
|
|
2803
2803
|
),
|
|
2804
2804
|
abortSignal: options.abortSignal,
|
|
@@ -2982,9 +2982,9 @@ var errorToMessage = (data) => {
|
|
|
2982
2982
|
};
|
|
2983
2983
|
var VERSION6 = "2.0.23" ;
|
|
2984
2984
|
function createPerplexity(options = {}) {
|
|
2985
|
-
const getHeaders = () =>
|
|
2985
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
2986
2986
|
{
|
|
2987
|
-
Authorization: `Bearer ${
|
|
2987
|
+
Authorization: `Bearer ${chunk4MKCST44_cjs.loadApiKey({
|
|
2988
2988
|
apiKey: options.apiKey,
|
|
2989
2989
|
environmentVariableName: "PERPLEXITY_API_KEY",
|
|
2990
2990
|
description: "Perplexity"
|
|
@@ -2996,21 +2996,21 @@ function createPerplexity(options = {}) {
|
|
|
2996
2996
|
const createLanguageModel = (modelId) => {
|
|
2997
2997
|
var _a15;
|
|
2998
2998
|
return new PerplexityLanguageModel(modelId, {
|
|
2999
|
-
baseURL:
|
|
2999
|
+
baseURL: chunk4MKCST44_cjs.withoutTrailingSlash(
|
|
3000
3000
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.perplexity.ai"
|
|
3001
3001
|
),
|
|
3002
3002
|
headers: getHeaders,
|
|
3003
|
-
generateId:
|
|
3003
|
+
generateId: chunk4MKCST44_cjs.generateId,
|
|
3004
3004
|
fetch: options.fetch
|
|
3005
3005
|
});
|
|
3006
3006
|
};
|
|
3007
3007
|
const provider = (modelId) => createLanguageModel(modelId);
|
|
3008
3008
|
provider.languageModel = createLanguageModel;
|
|
3009
3009
|
provider.textEmbeddingModel = (modelId) => {
|
|
3010
|
-
throw new
|
|
3010
|
+
throw new chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
3011
3011
|
};
|
|
3012
3012
|
provider.imageModel = (modelId) => {
|
|
3013
|
-
throw new
|
|
3013
|
+
throw new chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
3014
3014
|
};
|
|
3015
3015
|
return provider;
|
|
3016
3016
|
}
|
|
@@ -3045,9 +3045,9 @@ var TogetherAIImageModel = class {
|
|
|
3045
3045
|
}
|
|
3046
3046
|
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3047
3047
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
3048
|
-
const { value: response, responseHeaders } = await
|
|
3048
|
+
const { value: response, responseHeaders } = await chunk4MKCST44_cjs.postJsonToApi({
|
|
3049
3049
|
url: `${this.config.baseURL}/images/generations`,
|
|
3050
|
-
headers:
|
|
3050
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), headers),
|
|
3051
3051
|
body: {
|
|
3052
3052
|
model: this.modelId,
|
|
3053
3053
|
prompt,
|
|
@@ -3060,11 +3060,11 @@ var TogetherAIImageModel = class {
|
|
|
3060
3060
|
response_format: "base64",
|
|
3061
3061
|
...(_d = providerOptions.togetherai) != null ? _d : {}
|
|
3062
3062
|
},
|
|
3063
|
-
failedResponseHandler:
|
|
3063
|
+
failedResponseHandler: chunk4MKCST44_cjs.createJsonErrorResponseHandler({
|
|
3064
3064
|
errorSchema: togetheraiErrorSchema,
|
|
3065
3065
|
errorToMessage: (data) => data.error.message
|
|
3066
3066
|
}),
|
|
3067
|
-
successfulResponseHandler:
|
|
3067
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
3068
3068
|
togetheraiImageResponseSchema
|
|
3069
3069
|
),
|
|
3070
3070
|
abortSignal,
|
|
@@ -3096,12 +3096,12 @@ var togetheraiErrorSchema = v4.z.object({
|
|
|
3096
3096
|
var VERSION7 = "1.0.34" ;
|
|
3097
3097
|
function createTogetherAI(options = {}) {
|
|
3098
3098
|
var _a15;
|
|
3099
|
-
const baseURL =
|
|
3099
|
+
const baseURL = chunk4MKCST44_cjs.withoutTrailingSlash(
|
|
3100
3100
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.together.xyz/v1/"
|
|
3101
3101
|
);
|
|
3102
|
-
const getHeaders = () =>
|
|
3102
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
3103
3103
|
{
|
|
3104
|
-
Authorization: `Bearer ${
|
|
3104
|
+
Authorization: `Bearer ${chunk4MKCST44_cjs.loadApiKey({
|
|
3105
3105
|
apiKey: options.apiKey,
|
|
3106
3106
|
environmentVariableName: "TOGETHER_AI_API_KEY",
|
|
3107
3107
|
description: "TogetherAI"
|
|
@@ -3117,16 +3117,16 @@ function createTogetherAI(options = {}) {
|
|
|
3117
3117
|
fetch: options.fetch
|
|
3118
3118
|
});
|
|
3119
3119
|
const createChatModel = (modelId) => {
|
|
3120
|
-
return new
|
|
3120
|
+
return new chunk4MKCST44_cjs.OpenAICompatibleChatLanguageModel(
|
|
3121
3121
|
modelId,
|
|
3122
3122
|
getCommonModelConfig("chat")
|
|
3123
3123
|
);
|
|
3124
3124
|
};
|
|
3125
|
-
const createCompletionModel = (modelId) => new
|
|
3125
|
+
const createCompletionModel = (modelId) => new chunk4MKCST44_cjs.OpenAICompatibleCompletionLanguageModel(
|
|
3126
3126
|
modelId,
|
|
3127
3127
|
getCommonModelConfig("completion")
|
|
3128
3128
|
);
|
|
3129
|
-
const createTextEmbeddingModel = (modelId) => new
|
|
3129
|
+
const createTextEmbeddingModel = (modelId) => new chunk4MKCST44_cjs.OpenAICompatibleEmbeddingModel(
|
|
3130
3130
|
modelId,
|
|
3131
3131
|
getCommonModelConfig("embedding")
|
|
3132
3132
|
);
|
|
@@ -3171,11 +3171,11 @@ function convertToXaiChatMessages(prompt) {
|
|
|
3171
3171
|
return {
|
|
3172
3172
|
type: "image_url",
|
|
3173
3173
|
image_url: {
|
|
3174
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
3174
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunk4MKCST44_cjs.convertToBase64(part.data)}`
|
|
3175
3175
|
}
|
|
3176
3176
|
};
|
|
3177
3177
|
} else {
|
|
3178
|
-
throw new
|
|
3178
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
3179
3179
|
functionality: `file part media type ${part.mediaType}`
|
|
3180
3180
|
});
|
|
3181
3181
|
}
|
|
@@ -3361,7 +3361,7 @@ var xaiErrorDataSchema = v4.z.object({
|
|
|
3361
3361
|
code: v4.z.union([v4.z.string(), v4.z.number()]).nullish()
|
|
3362
3362
|
})
|
|
3363
3363
|
});
|
|
3364
|
-
var xaiFailedResponseHandler =
|
|
3364
|
+
var xaiFailedResponseHandler = chunk4MKCST44_cjs.createJsonErrorResponseHandler({
|
|
3365
3365
|
errorSchema: xaiErrorDataSchema,
|
|
3366
3366
|
errorToMessage: (data) => data.error.message
|
|
3367
3367
|
});
|
|
@@ -3410,7 +3410,7 @@ function prepareTools4({
|
|
|
3410
3410
|
};
|
|
3411
3411
|
default: {
|
|
3412
3412
|
const _exhaustiveCheck = type;
|
|
3413
|
-
throw new
|
|
3413
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
3414
3414
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
3415
3415
|
});
|
|
3416
3416
|
}
|
|
@@ -3445,7 +3445,7 @@ var XaiChatLanguageModel = class {
|
|
|
3445
3445
|
}) {
|
|
3446
3446
|
var _a15, _b, _c;
|
|
3447
3447
|
const warnings = [];
|
|
3448
|
-
const options = (_a15 = await
|
|
3448
|
+
const options = (_a15 = await chunk4MKCST44_cjs.parseProviderOptions({
|
|
3449
3449
|
provider: "xai",
|
|
3450
3450
|
providerOptions,
|
|
3451
3451
|
schema: xaiProviderOptions
|
|
@@ -3558,19 +3558,19 @@ var XaiChatLanguageModel = class {
|
|
|
3558
3558
|
responseHeaders,
|
|
3559
3559
|
value: response,
|
|
3560
3560
|
rawValue: rawResponse
|
|
3561
|
-
} = await
|
|
3561
|
+
} = await chunk4MKCST44_cjs.postJsonToApi({
|
|
3562
3562
|
url,
|
|
3563
|
-
headers:
|
|
3563
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
3564
3564
|
body,
|
|
3565
3565
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3566
|
-
successfulResponseHandler:
|
|
3566
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
3567
3567
|
xaiChatResponseSchema
|
|
3568
3568
|
),
|
|
3569
3569
|
abortSignal: options.abortSignal,
|
|
3570
3570
|
fetch: this.config.fetch
|
|
3571
3571
|
});
|
|
3572
3572
|
if (response.error != null) {
|
|
3573
|
-
throw new
|
|
3573
|
+
throw new chunk4MKCST44_cjs.APICallError({
|
|
3574
3574
|
message: response.error,
|
|
3575
3575
|
url,
|
|
3576
3576
|
requestBodyValues: body,
|
|
@@ -3581,7 +3581,7 @@ var XaiChatLanguageModel = class {
|
|
|
3581
3581
|
});
|
|
3582
3582
|
}
|
|
3583
3583
|
if (!response.choices || response.choices.length === 0) {
|
|
3584
|
-
throw new
|
|
3584
|
+
throw new chunk4MKCST44_cjs.APICallError({
|
|
3585
3585
|
message: "No choices returned from the API",
|
|
3586
3586
|
url,
|
|
3587
3587
|
requestBodyValues: body,
|
|
@@ -3658,22 +3658,22 @@ var XaiChatLanguageModel = class {
|
|
|
3658
3658
|
}
|
|
3659
3659
|
};
|
|
3660
3660
|
const url = `${(_a15 = this.config.baseURL) != null ? _a15 : "https://api.x.ai/v1"}/chat/completions`;
|
|
3661
|
-
const { responseHeaders, value: response } = await
|
|
3661
|
+
const { responseHeaders, value: response } = await chunk4MKCST44_cjs.postJsonToApi({
|
|
3662
3662
|
url,
|
|
3663
|
-
headers:
|
|
3663
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
3664
3664
|
body,
|
|
3665
3665
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3666
3666
|
successfulResponseHandler: async ({ response: response2 }) => {
|
|
3667
|
-
const responseHeaders2 =
|
|
3667
|
+
const responseHeaders2 = chunk4MKCST44_cjs.extractResponseHeaders(response2);
|
|
3668
3668
|
const contentType = response2.headers.get("content-type");
|
|
3669
3669
|
if (contentType == null ? void 0 : contentType.includes("application/json")) {
|
|
3670
3670
|
const responseBody = await response2.text();
|
|
3671
|
-
const parsedError = await
|
|
3671
|
+
const parsedError = await chunk4MKCST44_cjs.safeParseJSON({
|
|
3672
3672
|
text: responseBody,
|
|
3673
3673
|
schema: xaiStreamErrorSchema
|
|
3674
3674
|
});
|
|
3675
3675
|
if (parsedError.success) {
|
|
3676
|
-
throw new
|
|
3676
|
+
throw new chunk4MKCST44_cjs.APICallError({
|
|
3677
3677
|
message: parsedError.value.error,
|
|
3678
3678
|
url,
|
|
3679
3679
|
requestBodyValues: body,
|
|
@@ -3683,7 +3683,7 @@ var XaiChatLanguageModel = class {
|
|
|
3683
3683
|
isRetryable: parsedError.value.code === "The service is currently unavailable"
|
|
3684
3684
|
});
|
|
3685
3685
|
}
|
|
3686
|
-
throw new
|
|
3686
|
+
throw new chunk4MKCST44_cjs.APICallError({
|
|
3687
3687
|
message: "Invalid JSON response",
|
|
3688
3688
|
url,
|
|
3689
3689
|
requestBodyValues: body,
|
|
@@ -3692,7 +3692,7 @@ var XaiChatLanguageModel = class {
|
|
|
3692
3692
|
responseBody
|
|
3693
3693
|
});
|
|
3694
3694
|
}
|
|
3695
|
-
return
|
|
3695
|
+
return chunk4MKCST44_cjs.createEventSourceResponseHandler(xaiChatChunkSchema)({
|
|
3696
3696
|
response: response2,
|
|
3697
3697
|
url,
|
|
3698
3698
|
requestBodyValues: body
|
|
@@ -4300,10 +4300,10 @@ async function convertToXaiResponsesInput({
|
|
|
4300
4300
|
case "file": {
|
|
4301
4301
|
if (block.mediaType.startsWith("image/")) {
|
|
4302
4302
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
4303
|
-
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${
|
|
4303
|
+
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${chunk4MKCST44_cjs.convertToBase64(block.data)}`;
|
|
4304
4304
|
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
4305
4305
|
} else {
|
|
4306
|
-
throw new
|
|
4306
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
4307
4307
|
functionality: `file part media type ${block.mediaType}`
|
|
4308
4308
|
});
|
|
4309
4309
|
}
|
|
@@ -4414,8 +4414,8 @@ async function convertToXaiResponsesInput({
|
|
|
4414
4414
|
}
|
|
4415
4415
|
return { input, inputWarnings };
|
|
4416
4416
|
}
|
|
4417
|
-
var webSearchArgsSchema =
|
|
4418
|
-
() =>
|
|
4417
|
+
var webSearchArgsSchema = chunk4MKCST44_cjs.lazySchema(
|
|
4418
|
+
() => chunk4MKCST44_cjs.zodSchema(
|
|
4419
4419
|
v4.z.object({
|
|
4420
4420
|
allowedDomains: v4.z.array(v4.z.string()).max(5).optional(),
|
|
4421
4421
|
excludedDomains: v4.z.array(v4.z.string()).max(5).optional(),
|
|
@@ -4423,8 +4423,8 @@ var webSearchArgsSchema = chunk6Q3ZFEII_cjs.lazySchema(
|
|
|
4423
4423
|
})
|
|
4424
4424
|
)
|
|
4425
4425
|
);
|
|
4426
|
-
var webSearchOutputSchema =
|
|
4427
|
-
() =>
|
|
4426
|
+
var webSearchOutputSchema = chunk4MKCST44_cjs.lazySchema(
|
|
4427
|
+
() => chunk4MKCST44_cjs.zodSchema(
|
|
4428
4428
|
v4.z.object({
|
|
4429
4429
|
query: v4.z.string(),
|
|
4430
4430
|
sources: v4.z.array(
|
|
@@ -4437,15 +4437,15 @@ var webSearchOutputSchema = chunk6Q3ZFEII_cjs.lazySchema(
|
|
|
4437
4437
|
})
|
|
4438
4438
|
)
|
|
4439
4439
|
);
|
|
4440
|
-
var webSearchToolFactory =
|
|
4440
|
+
var webSearchToolFactory = chunk4MKCST44_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
4441
4441
|
id: "xai.web_search",
|
|
4442
4442
|
name: "web_search",
|
|
4443
|
-
inputSchema:
|
|
4443
|
+
inputSchema: chunk4MKCST44_cjs.lazySchema(() => chunk4MKCST44_cjs.zodSchema(v4.z.object({}))),
|
|
4444
4444
|
outputSchema: webSearchOutputSchema
|
|
4445
4445
|
});
|
|
4446
4446
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
4447
|
-
var xSearchArgsSchema =
|
|
4448
|
-
() =>
|
|
4447
|
+
var xSearchArgsSchema = chunk4MKCST44_cjs.lazySchema(
|
|
4448
|
+
() => chunk4MKCST44_cjs.zodSchema(
|
|
4449
4449
|
v4.z.object({
|
|
4450
4450
|
allowedXHandles: v4.z.array(v4.z.string()).max(10).optional(),
|
|
4451
4451
|
excludedXHandles: v4.z.array(v4.z.string()).max(10).optional(),
|
|
@@ -4456,8 +4456,8 @@ var xSearchArgsSchema = chunk6Q3ZFEII_cjs.lazySchema(
|
|
|
4456
4456
|
})
|
|
4457
4457
|
)
|
|
4458
4458
|
);
|
|
4459
|
-
var xSearchOutputSchema =
|
|
4460
|
-
() =>
|
|
4459
|
+
var xSearchOutputSchema = chunk4MKCST44_cjs.lazySchema(
|
|
4460
|
+
() => chunk4MKCST44_cjs.zodSchema(
|
|
4461
4461
|
v4.z.object({
|
|
4462
4462
|
query: v4.z.string(),
|
|
4463
4463
|
posts: v4.z.array(
|
|
@@ -4471,10 +4471,10 @@ var xSearchOutputSchema = chunk6Q3ZFEII_cjs.lazySchema(
|
|
|
4471
4471
|
})
|
|
4472
4472
|
)
|
|
4473
4473
|
);
|
|
4474
|
-
var xSearchToolFactory =
|
|
4474
|
+
var xSearchToolFactory = chunk4MKCST44_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
4475
4475
|
id: "xai.x_search",
|
|
4476
4476
|
name: "x_search",
|
|
4477
|
-
inputSchema:
|
|
4477
|
+
inputSchema: chunk4MKCST44_cjs.lazySchema(() => chunk4MKCST44_cjs.zodSchema(v4.z.object({}))),
|
|
4478
4478
|
outputSchema: xSearchOutputSchema
|
|
4479
4479
|
});
|
|
4480
4480
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -4494,7 +4494,7 @@ async function prepareResponsesTools({
|
|
|
4494
4494
|
if (tool.type === "provider-defined") {
|
|
4495
4495
|
switch (tool.id) {
|
|
4496
4496
|
case "xai.web_search": {
|
|
4497
|
-
const args = await
|
|
4497
|
+
const args = await chunk4MKCST44_cjs.validateTypes({
|
|
4498
4498
|
value: tool.args,
|
|
4499
4499
|
schema: webSearchArgsSchema
|
|
4500
4500
|
});
|
|
@@ -4507,7 +4507,7 @@ async function prepareResponsesTools({
|
|
|
4507
4507
|
break;
|
|
4508
4508
|
}
|
|
4509
4509
|
case "xai.x_search": {
|
|
4510
|
-
const args = await
|
|
4510
|
+
const args = await chunk4MKCST44_cjs.validateTypes({
|
|
4511
4511
|
value: tool.args,
|
|
4512
4512
|
schema: xSearchArgsSchema
|
|
4513
4513
|
});
|
|
@@ -4642,7 +4642,7 @@ async function prepareResponsesTools({
|
|
|
4642
4642
|
}
|
|
4643
4643
|
default: {
|
|
4644
4644
|
const _exhaustiveCheck = type;
|
|
4645
|
-
throw new
|
|
4645
|
+
throw new chunk4MKCST44_cjs.UnsupportedFunctionalityError({
|
|
4646
4646
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
4647
4647
|
});
|
|
4648
4648
|
}
|
|
@@ -4674,7 +4674,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
4674
4674
|
}) {
|
|
4675
4675
|
var _a15, _b, _c, _d, _e;
|
|
4676
4676
|
const warnings = [];
|
|
4677
|
-
const options = (_a15 = await
|
|
4677
|
+
const options = (_a15 = await chunk4MKCST44_cjs.parseProviderOptions({
|
|
4678
4678
|
provider: "xai",
|
|
4679
4679
|
providerOptions,
|
|
4680
4680
|
schema: xaiResponsesProviderOptions
|
|
@@ -4762,12 +4762,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
4762
4762
|
responseHeaders,
|
|
4763
4763
|
value: response,
|
|
4764
4764
|
rawValue: rawResponse
|
|
4765
|
-
} = await
|
|
4765
|
+
} = await chunk4MKCST44_cjs.postJsonToApi({
|
|
4766
4766
|
url: `${(_a15 = this.config.baseURL) != null ? _a15 : "https://api.x.ai/v1"}/responses`,
|
|
4767
|
-
headers:
|
|
4767
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
4768
4768
|
body,
|
|
4769
4769
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4770
|
-
successfulResponseHandler:
|
|
4770
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createJsonResponseHandler(
|
|
4771
4771
|
xaiResponsesResponseSchema
|
|
4772
4772
|
),
|
|
4773
4773
|
abortSignal: options.abortSignal,
|
|
@@ -4903,12 +4903,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
4903
4903
|
...args,
|
|
4904
4904
|
stream: true
|
|
4905
4905
|
};
|
|
4906
|
-
const { responseHeaders, value: response } = await
|
|
4906
|
+
const { responseHeaders, value: response } = await chunk4MKCST44_cjs.postJsonToApi({
|
|
4907
4907
|
url: `${(_a15 = this.config.baseURL) != null ? _a15 : "https://api.x.ai/v1"}/responses`,
|
|
4908
|
-
headers:
|
|
4908
|
+
headers: chunk4MKCST44_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
4909
4909
|
body,
|
|
4910
4910
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4911
|
-
successfulResponseHandler:
|
|
4911
|
+
successfulResponseHandler: chunk4MKCST44_cjs.createEventSourceResponseHandler(
|
|
4912
4912
|
xaiResponsesChunkSchema
|
|
4913
4913
|
),
|
|
4914
4914
|
abortSignal: options.abortSignal,
|
|
@@ -5227,7 +5227,7 @@ var codeExecutionOutputSchema = v4.z.object({
|
|
|
5227
5227
|
output: v4.z.string().describe("the output of the code execution"),
|
|
5228
5228
|
error: v4.z.string().optional().describe("any error that occurred")
|
|
5229
5229
|
});
|
|
5230
|
-
var codeExecutionToolFactory =
|
|
5230
|
+
var codeExecutionToolFactory = chunk4MKCST44_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
5231
5231
|
id: "xai.code_execution",
|
|
5232
5232
|
name: "code_execution",
|
|
5233
5233
|
inputSchema: v4.z.object({}).describe("no input parameters"),
|
|
@@ -5238,7 +5238,7 @@ var viewImageOutputSchema = v4.z.object({
|
|
|
5238
5238
|
description: v4.z.string().describe("description of the image"),
|
|
5239
5239
|
objects: v4.z.array(v4.z.string()).optional().describe("objects detected in the image")
|
|
5240
5240
|
});
|
|
5241
|
-
var viewImageToolFactory =
|
|
5241
|
+
var viewImageToolFactory = chunk4MKCST44_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
5242
5242
|
id: "xai.view_image",
|
|
5243
5243
|
name: "view_image",
|
|
5244
5244
|
inputSchema: v4.z.object({}).describe("no input parameters"),
|
|
@@ -5250,7 +5250,7 @@ var viewXVideoOutputSchema = v4.z.object({
|
|
|
5250
5250
|
description: v4.z.string().describe("description of the video content"),
|
|
5251
5251
|
duration: v4.z.number().optional().describe("duration in seconds")
|
|
5252
5252
|
});
|
|
5253
|
-
var viewXVideoToolFactory =
|
|
5253
|
+
var viewXVideoToolFactory = chunk4MKCST44_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
5254
5254
|
id: "xai.view_x_video",
|
|
5255
5255
|
name: "view_x_video",
|
|
5256
5256
|
inputSchema: v4.z.object({}).describe("no input parameters"),
|
|
@@ -5271,12 +5271,12 @@ var xaiErrorStructure = {
|
|
|
5271
5271
|
};
|
|
5272
5272
|
function createXai(options = {}) {
|
|
5273
5273
|
var _a15;
|
|
5274
|
-
const baseURL =
|
|
5274
|
+
const baseURL = chunk4MKCST44_cjs.withoutTrailingSlash(
|
|
5275
5275
|
(_a15 = options.baseURL) != null ? _a15 : "https://api.x.ai/v1"
|
|
5276
5276
|
);
|
|
5277
|
-
const getHeaders = () =>
|
|
5277
|
+
const getHeaders = () => chunk4MKCST44_cjs.withUserAgentSuffix(
|
|
5278
5278
|
{
|
|
5279
|
-
Authorization: `Bearer ${
|
|
5279
|
+
Authorization: `Bearer ${chunk4MKCST44_cjs.loadApiKey({
|
|
5280
5280
|
apiKey: options.apiKey,
|
|
5281
5281
|
environmentVariableName: "XAI_API_KEY",
|
|
5282
5282
|
description: "xAI API key"
|
|
@@ -5290,7 +5290,7 @@ function createXai(options = {}) {
|
|
|
5290
5290
|
provider: "xai.chat",
|
|
5291
5291
|
baseURL,
|
|
5292
5292
|
headers: getHeaders,
|
|
5293
|
-
generateId:
|
|
5293
|
+
generateId: chunk4MKCST44_cjs.generateId,
|
|
5294
5294
|
fetch: options.fetch
|
|
5295
5295
|
});
|
|
5296
5296
|
};
|
|
@@ -5299,12 +5299,12 @@ function createXai(options = {}) {
|
|
|
5299
5299
|
provider: "xai.responses",
|
|
5300
5300
|
baseURL,
|
|
5301
5301
|
headers: getHeaders,
|
|
5302
|
-
generateId:
|
|
5302
|
+
generateId: chunk4MKCST44_cjs.generateId,
|
|
5303
5303
|
fetch: options.fetch
|
|
5304
5304
|
});
|
|
5305
5305
|
};
|
|
5306
5306
|
const createImageModel = (modelId) => {
|
|
5307
|
-
return new
|
|
5307
|
+
return new chunk4MKCST44_cjs.OpenAICompatibleImageModel(modelId, {
|
|
5308
5308
|
provider: "xai.image",
|
|
5309
5309
|
url: ({ path }) => `${baseURL}${path}`,
|
|
5310
5310
|
headers: getHeaders,
|
|
@@ -5318,7 +5318,7 @@ function createXai(options = {}) {
|
|
|
5318
5318
|
provider.chat = createChatLanguageModel;
|
|
5319
5319
|
provider.responses = createResponsesLanguageModel;
|
|
5320
5320
|
provider.textEmbeddingModel = (modelId) => {
|
|
5321
|
-
throw new
|
|
5321
|
+
throw new chunk4MKCST44_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
5322
5322
|
};
|
|
5323
5323
|
provider.imageModel = createImageModel;
|
|
5324
5324
|
provider.image = createImageModel;
|
|
@@ -7833,7 +7833,7 @@ var PROVIDER_OVERRIDES = {
|
|
|
7833
7833
|
npm: "@ai-sdk/anthropic"
|
|
7834
7834
|
}
|
|
7835
7835
|
};
|
|
7836
|
-
var ModelsDevGateway = class extends
|
|
7836
|
+
var ModelsDevGateway = class extends chunk4MKCST44_cjs.MastraModelGateway {
|
|
7837
7837
|
id = "models.dev";
|
|
7838
7838
|
name = "models.dev";
|
|
7839
7839
|
providerConfigs = {};
|
|
@@ -7849,12 +7849,12 @@ var ModelsDevGateway = class extends chunk6Q3ZFEII_cjs.MastraModelGateway {
|
|
|
7849
7849
|
const data = await response.json();
|
|
7850
7850
|
const providerConfigs = {};
|
|
7851
7851
|
for (const [providerId, providerInfo] of Object.entries(data)) {
|
|
7852
|
-
if (
|
|
7852
|
+
if (chunk4MKCST44_cjs.EXCLUDED_PROVIDERS.includes(providerId)) continue;
|
|
7853
7853
|
if (!providerInfo || typeof providerInfo !== "object" || !providerInfo.models) continue;
|
|
7854
7854
|
const normalizedId = providerId;
|
|
7855
7855
|
const isOpenAICompatible = providerInfo.npm === "@ai-sdk/openai-compatible" || providerInfo.npm === "@ai-sdk/gateway" || // Vercel AI Gateway is OpenAI-compatible
|
|
7856
7856
|
normalizedId in PROVIDER_OVERRIDES;
|
|
7857
|
-
const hasInstalledPackage =
|
|
7857
|
+
const hasInstalledPackage = chunk4MKCST44_cjs.PROVIDERS_WITH_INSTALLED_PACKAGES.includes(providerId);
|
|
7858
7858
|
const hasApiAndEnv = providerInfo.api && providerInfo.env && providerInfo.env.length > 0;
|
|
7859
7859
|
if (isOpenAICompatible || hasInstalledPackage || hasApiAndEnv) {
|
|
7860
7860
|
const modelIds = Object.entries(providerInfo.models).filter(([, modelInfo]) => modelInfo?.status !== "deprecated").map(([modelId]) => modelId).sort();
|
|
@@ -7914,15 +7914,15 @@ var ModelsDevGateway = class extends chunk6Q3ZFEII_cjs.MastraModelGateway {
|
|
|
7914
7914
|
headers
|
|
7915
7915
|
}) {
|
|
7916
7916
|
const baseURL = this.buildUrl(`${providerId}/${modelId}`);
|
|
7917
|
-
const mastraHeaders = { "User-Agent":
|
|
7917
|
+
const mastraHeaders = { "User-Agent": chunk4MKCST44_cjs.MASTRA_USER_AGENT, ...headers };
|
|
7918
7918
|
switch (providerId) {
|
|
7919
7919
|
case "openai":
|
|
7920
|
-
return
|
|
7920
|
+
return chunk4MKCST44_cjs.createOpenAI({ apiKey, headers: mastraHeaders }).responses(modelId);
|
|
7921
7921
|
case "gemini":
|
|
7922
7922
|
case "google":
|
|
7923
|
-
return
|
|
7923
|
+
return chunk4MKCST44_cjs.createGoogleGenerativeAI({ apiKey, headers: mastraHeaders }).chat(modelId);
|
|
7924
7924
|
case "anthropic":
|
|
7925
|
-
return
|
|
7925
|
+
return chunk4MKCST44_cjs.createAnthropic({ apiKey, headers: mastraHeaders })(modelId);
|
|
7926
7926
|
case "mistral":
|
|
7927
7927
|
return createMistral({ apiKey, headers: mastraHeaders })(modelId);
|
|
7928
7928
|
case "groq":
|
|
@@ -7946,29 +7946,29 @@ var ModelsDevGateway = class extends chunk6Q3ZFEII_cjs.MastraModelGateway {
|
|
|
7946
7946
|
case "moonshotai":
|
|
7947
7947
|
case "moonshotai-cn": {
|
|
7948
7948
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
7949
|
-
return
|
|
7949
|
+
return chunk4MKCST44_cjs.createAnthropic({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
7950
7950
|
}
|
|
7951
7951
|
default: {
|
|
7952
7952
|
const config = this.providerConfigs[providerId];
|
|
7953
7953
|
const npm = config?.npm;
|
|
7954
7954
|
if (npm === "@ai-sdk/anthropic") {
|
|
7955
7955
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
7956
|
-
return
|
|
7956
|
+
return chunk4MKCST44_cjs.createAnthropic({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
7957
7957
|
}
|
|
7958
7958
|
if (npm === "@ai-sdk/openai") {
|
|
7959
7959
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
7960
|
-
return
|
|
7960
|
+
return chunk4MKCST44_cjs.createOpenAI({ apiKey, baseURL, headers: mastraHeaders }).chat(modelId);
|
|
7961
7961
|
}
|
|
7962
7962
|
if (npm === "@ai-sdk/google") {
|
|
7963
7963
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
7964
|
-
return
|
|
7964
|
+
return chunk4MKCST44_cjs.createGoogleGenerativeAI({ apiKey, baseURL, headers: mastraHeaders }).chat(modelId);
|
|
7965
7965
|
}
|
|
7966
7966
|
if (npm === "@ai-sdk/mistral") {
|
|
7967
7967
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
7968
7968
|
return createMistral({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
7969
7969
|
}
|
|
7970
7970
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
7971
|
-
return
|
|
7971
|
+
return chunk4MKCST44_cjs.createOpenAICompatible({
|
|
7972
7972
|
name: providerId,
|
|
7973
7973
|
apiKey,
|
|
7974
7974
|
baseURL,
|
|
@@ -7982,5 +7982,5 @@ var ModelsDevGateway = class extends chunk6Q3ZFEII_cjs.MastraModelGateway {
|
|
|
7982
7982
|
|
|
7983
7983
|
exports.ModelsDevGateway = ModelsDevGateway;
|
|
7984
7984
|
exports.parseModelRouterId = parseModelRouterId;
|
|
7985
|
-
//# sourceMappingURL=chunk-
|
|
7986
|
-
//# sourceMappingURL=chunk-
|
|
7985
|
+
//# sourceMappingURL=chunk-VX2T4M3C.cjs.map
|
|
7986
|
+
//# sourceMappingURL=chunk-VX2T4M3C.cjs.map
|