@mastra/core 1.11.0 → 1.12.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-QAIBZ7GH.cjs → chunk-2DFKNHEI.cjs} +79 -48
- package/dist/chunk-2DFKNHEI.cjs.map +1 -0
- package/dist/{chunk-RF2EPUM4.js → chunk-4RE5DA24.js} +4 -4
- package/dist/{chunk-RF2EPUM4.js.map → chunk-4RE5DA24.js.map} +1 -1
- package/dist/{chunk-GOGAIHBU.js → chunk-55I2D5RA.js} +22 -3
- package/dist/chunk-55I2D5RA.js.map +1 -0
- package/dist/{chunk-NJVIJQ4R.cjs → chunk-5CZTEH74.cjs} +18 -14
- package/dist/chunk-5CZTEH74.cjs.map +1 -0
- package/dist/{chunk-W3LSSG4T.js → chunk-5X4N6M7R.js} +2 -2
- package/dist/{chunk-W3LSSG4T.js.map → chunk-5X4N6M7R.js.map} +1 -1
- package/dist/{chunk-CWLK5FXA.cjs → chunk-BJHH5WFG.cjs} +202 -221
- package/dist/chunk-BJHH5WFG.cjs.map +1 -0
- package/dist/{chunk-FN6ZOGJ7.cjs → chunk-NMUP4X54.cjs} +2 -2
- package/dist/{chunk-FN6ZOGJ7.cjs.map → chunk-NMUP4X54.cjs.map} +1 -1
- package/dist/{chunk-VW4MYD6N.js → chunk-PYRU2AFG.js} +15 -11
- package/dist/chunk-PYRU2AFG.js.map +1 -0
- package/dist/{chunk-KK2U4Z7X.cjs → chunk-RD2IELJM.cjs} +24 -2
- package/dist/chunk-RD2IELJM.cjs.map +1 -0
- package/dist/{chunk-Y2MVLQFW.js → chunk-TZE75LDQ.js} +29 -48
- package/dist/chunk-TZE75LDQ.js.map +1 -0
- package/dist/{chunk-FIQRYC7M.cjs → chunk-Y5TNEU6E.cjs} +5 -5
- package/dist/{chunk-FIQRYC7M.cjs.map → chunk-Y5TNEU6E.cjs.map} +1 -1
- package/dist/{chunk-S5BMBKUR.js → chunk-Z7VOJIJU.js} +55 -24
- package/dist/chunk-Z7VOJIJU.js.map +1 -0
- package/dist/datasets/index.cjs +16 -16
- package/dist/datasets/index.js +1 -1
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +424 -424
- package/dist/docs/references/docs-memory-storage.md +5 -5
- package/dist/docs/references/reference-storage-composite.md +11 -3
- package/dist/docs/references/reference-storage-overview.md +18 -1
- package/dist/evals/index.cjs +19 -19
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/harness/index.cjs +6 -6
- package/dist/harness/index.js +4 -4
- 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/llm/model/gateways/azure.d.ts +2 -1
- package/dist/llm/model/gateways/azure.d.ts.map +1 -1
- package/dist/llm/model/gateways/constants.d.ts +1 -0
- package/dist/llm/model/gateways/constants.d.ts.map +1 -1
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/gateways/netlify.d.ts.map +1 -1
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +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/models-dev-G3WSTWOC.cjs +12 -0
- package/dist/{models-dev-7JBNQXVK.cjs.map → models-dev-G3WSTWOC.cjs.map} +1 -1
- package/dist/models-dev-RXHGE3WI.js +3 -0
- package/dist/{models-dev-BB5C46BD.js.map → models-dev-RXHGE3WI.js.map} +1 -1
- package/dist/netlify-EEOC6JL7.cjs +12 -0
- package/dist/{netlify-RN36CL4F.cjs.map → netlify-EEOC6JL7.cjs.map} +1 -1
- package/dist/netlify-ZUJJUCID.js +3 -0
- package/dist/{netlify-BFMLDQM5.js.map → netlify-ZUJJUCID.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-7ZTKNI7T.cjs +40 -0
- package/dist/{provider-registry-IHJW2WNI.cjs.map → provider-registry-7ZTKNI7T.cjs.map} +1 -1
- package/dist/provider-registry-E5XXTB3V.js +3 -0
- package/dist/{provider-registry-6FITK73S.js.map → provider-registry-E5XXTB3V.js.map} +1 -1
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +56 -56
- package/dist/storage/constants.d.ts +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/observability/types.d.ts +6 -6
- package/dist/storage/index.cjs +172 -172
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +10 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/utils.cjs +23 -23
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +9 -9
- package/dist/vector/index.js +2 -2
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +3 -0
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/handlers/entry.d.ts +9 -0
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/types.d.ts +13 -0
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-CWLK5FXA.cjs.map +0 -1
- package/dist/chunk-GOGAIHBU.js.map +0 -1
- package/dist/chunk-KK2U4Z7X.cjs.map +0 -1
- package/dist/chunk-NJVIJQ4R.cjs.map +0 -1
- package/dist/chunk-QAIBZ7GH.cjs.map +0 -1
- package/dist/chunk-S5BMBKUR.js.map +0 -1
- package/dist/chunk-VW4MYD6N.js.map +0 -1
- package/dist/chunk-Y2MVLQFW.js.map +0 -1
- package/dist/models-dev-7JBNQXVK.cjs +0 -12
- package/dist/models-dev-BB5C46BD.js +0 -3
- package/dist/netlify-BFMLDQM5.js +0 -3
- package/dist/netlify-RN36CL4F.cjs +0 -12
- package/dist/provider-registry-6FITK73S.js +0 -3
- package/dist/provider-registry-IHJW2WNI.cjs +0 -40
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkRD2IELJM_cjs = require('./chunk-RD2IELJM.cjs');
|
|
4
4
|
var chunkQX73JATY_cjs = require('./chunk-QX73JATY.cjs');
|
|
5
5
|
var z45 = require('zod/v4');
|
|
6
6
|
var v3 = require('zod/v3');
|
|
@@ -39,12 +39,12 @@ var cerebrasErrorStructure = {
|
|
|
39
39
|
};
|
|
40
40
|
function createCerebras(options = {}) {
|
|
41
41
|
var _a24;
|
|
42
|
-
const baseURL =
|
|
42
|
+
const baseURL = chunkRD2IELJM_cjs.withoutTrailingSlash(
|
|
43
43
|
(_a24 = options.baseURL) != null ? _a24 : "https://api.cerebras.ai/v1"
|
|
44
44
|
);
|
|
45
|
-
const getHeaders = () =>
|
|
45
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
46
46
|
{
|
|
47
|
-
Authorization: `Bearer ${
|
|
47
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
48
48
|
apiKey: options.apiKey,
|
|
49
49
|
environmentVariableName: "CEREBRAS_API_KEY",
|
|
50
50
|
description: "Cerebras API key"
|
|
@@ -54,7 +54,7 @@ function createCerebras(options = {}) {
|
|
|
54
54
|
`ai-sdk/cerebras/${VERSION}`
|
|
55
55
|
);
|
|
56
56
|
const createLanguageModel = (modelId) => {
|
|
57
|
-
return new
|
|
57
|
+
return new chunkRD2IELJM_cjs.OpenAICompatibleChatLanguageModel(modelId, {
|
|
58
58
|
provider: `cerebras.chat`,
|
|
59
59
|
url: ({ path }) => `${baseURL}${path}`,
|
|
60
60
|
headers: getHeaders,
|
|
@@ -67,10 +67,10 @@ function createCerebras(options = {}) {
|
|
|
67
67
|
provider.languageModel = createLanguageModel;
|
|
68
68
|
provider.chat = createLanguageModel;
|
|
69
69
|
provider.textEmbeddingModel = (modelId) => {
|
|
70
|
-
throw new
|
|
70
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
71
71
|
};
|
|
72
72
|
provider.imageModel = (modelId) => {
|
|
73
|
-
throw new
|
|
73
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
74
74
|
};
|
|
75
75
|
return provider;
|
|
76
76
|
}
|
|
@@ -99,9 +99,9 @@ var DeepInfraImageModel = class {
|
|
|
99
99
|
const warnings = [];
|
|
100
100
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
101
101
|
const currentDate = (_c = (_b17 = (_a24 = this.config._internal) == null ? void 0 : _a24.currentDate) == null ? void 0 : _b17.call(_a24)) != null ? _c : /* @__PURE__ */ new Date();
|
|
102
|
-
const { value: response, responseHeaders } = await
|
|
102
|
+
const { value: response, responseHeaders } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
103
103
|
url: `${this.config.baseURL}/${this.modelId}`,
|
|
104
|
-
headers:
|
|
104
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), headers),
|
|
105
105
|
body: {
|
|
106
106
|
prompt,
|
|
107
107
|
num_images: n,
|
|
@@ -110,11 +110,11 @@ var DeepInfraImageModel = class {
|
|
|
110
110
|
...seed != null && { seed },
|
|
111
111
|
...(_d = providerOptions.deepinfra) != null ? _d : {}
|
|
112
112
|
},
|
|
113
|
-
failedResponseHandler:
|
|
113
|
+
failedResponseHandler: chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
114
114
|
errorSchema: deepInfraErrorSchema,
|
|
115
115
|
errorToMessage: (error) => error.detail.error
|
|
116
116
|
}),
|
|
117
|
-
successfulResponseHandler:
|
|
117
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
118
118
|
deepInfraImageResponseSchema
|
|
119
119
|
),
|
|
120
120
|
abortSignal,
|
|
@@ -141,7 +141,7 @@ var deepInfraErrorSchema = z45.z.object({
|
|
|
141
141
|
var deepInfraImageResponseSchema = z45.z.object({
|
|
142
142
|
images: z45.z.array(z45.z.string())
|
|
143
143
|
});
|
|
144
|
-
var DeepInfraChatLanguageModel = class extends
|
|
144
|
+
var DeepInfraChatLanguageModel = class extends chunkRD2IELJM_cjs.OpenAICompatibleChatLanguageModel {
|
|
145
145
|
constructor(modelId, config) {
|
|
146
146
|
super(modelId, config);
|
|
147
147
|
}
|
|
@@ -192,12 +192,12 @@ var DeepInfraChatLanguageModel = class extends chunkKK2U4Z7X_cjs.OpenAICompatibl
|
|
|
192
192
|
var VERSION2 = "1.0.35" ;
|
|
193
193
|
function createDeepInfra(options = {}) {
|
|
194
194
|
var _a24;
|
|
195
|
-
const baseURL =
|
|
195
|
+
const baseURL = chunkRD2IELJM_cjs.withoutTrailingSlash(
|
|
196
196
|
(_a24 = options.baseURL) != null ? _a24 : "https://api.deepinfra.com/v1"
|
|
197
197
|
);
|
|
198
|
-
const getHeaders = () =>
|
|
198
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
199
199
|
{
|
|
200
|
-
Authorization: `Bearer ${
|
|
200
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
201
201
|
apiKey: options.apiKey,
|
|
202
202
|
environmentVariableName: "DEEPINFRA_API_KEY",
|
|
203
203
|
description: "DeepInfra's API key"
|
|
@@ -218,11 +218,11 @@ function createDeepInfra(options = {}) {
|
|
|
218
218
|
getCommonModelConfig("chat")
|
|
219
219
|
);
|
|
220
220
|
};
|
|
221
|
-
const createCompletionModel = (modelId) => new
|
|
221
|
+
const createCompletionModel = (modelId) => new chunkRD2IELJM_cjs.OpenAICompatibleCompletionLanguageModel(
|
|
222
222
|
modelId,
|
|
223
223
|
getCommonModelConfig("completion")
|
|
224
224
|
);
|
|
225
|
-
const createTextEmbeddingModel = (modelId) => new
|
|
225
|
+
const createTextEmbeddingModel = (modelId) => new chunkRD2IELJM_cjs.OpenAICompatibleEmbeddingModel(
|
|
226
226
|
modelId,
|
|
227
227
|
getCommonModelConfig("embedding")
|
|
228
228
|
);
|
|
@@ -411,8 +411,8 @@ var deepseekChatResponseSchema = z45.z.object({
|
|
|
411
411
|
),
|
|
412
412
|
usage: tokenUsageSchema
|
|
413
413
|
});
|
|
414
|
-
var deepseekChatChunkSchema =
|
|
415
|
-
() =>
|
|
414
|
+
var deepseekChatChunkSchema = chunkRD2IELJM_cjs.lazySchema(
|
|
415
|
+
() => chunkRD2IELJM_cjs.zodSchema(
|
|
416
416
|
z45.z.union([
|
|
417
417
|
z45.z.object({
|
|
418
418
|
id: z45.z.string().nullish(),
|
|
@@ -499,7 +499,7 @@ function prepareTools({
|
|
|
499
499
|
};
|
|
500
500
|
default: {
|
|
501
501
|
const _exhaustiveCheck = type;
|
|
502
|
-
throw new
|
|
502
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
503
503
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
504
504
|
});
|
|
505
505
|
}
|
|
@@ -538,7 +538,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
538
538
|
this.supportedUrls = {};
|
|
539
539
|
this.modelId = modelId;
|
|
540
540
|
this.config = config;
|
|
541
|
-
this.failedResponseHandler =
|
|
541
|
+
this.failedResponseHandler = chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
542
542
|
errorSchema: deepSeekErrorSchema,
|
|
543
543
|
errorToMessage: (error) => error.error.message
|
|
544
544
|
});
|
|
@@ -565,7 +565,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
565
565
|
seed
|
|
566
566
|
}) {
|
|
567
567
|
var _a24, _b17;
|
|
568
|
-
const deepseekOptions = (_a24 = await
|
|
568
|
+
const deepseekOptions = (_a24 = await chunkRD2IELJM_cjs.parseProviderOptions({
|
|
569
569
|
provider: this.providerOptionsName,
|
|
570
570
|
providerOptions,
|
|
571
571
|
schema: deepseekChatOptions
|
|
@@ -613,15 +613,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
613
613
|
responseHeaders,
|
|
614
614
|
value: responseBody,
|
|
615
615
|
rawValue: rawResponse
|
|
616
|
-
} = await
|
|
616
|
+
} = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
617
617
|
url: this.config.url({
|
|
618
618
|
path: "/chat/completions",
|
|
619
619
|
modelId: this.modelId
|
|
620
620
|
}),
|
|
621
|
-
headers:
|
|
621
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
622
622
|
body: args,
|
|
623
623
|
failedResponseHandler: this.failedResponseHandler,
|
|
624
|
-
successfulResponseHandler:
|
|
624
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
625
625
|
deepseekChatResponseSchema
|
|
626
626
|
),
|
|
627
627
|
abortSignal: options.abortSignal,
|
|
@@ -640,7 +640,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
640
640
|
for (const toolCall of choice2.message.tool_calls) {
|
|
641
641
|
content.push({
|
|
642
642
|
type: "tool-call",
|
|
643
|
-
toolCallId: (_a24 = toolCall.id) != null ? _a24 :
|
|
643
|
+
toolCallId: (_a24 = toolCall.id) != null ? _a24 : chunkRD2IELJM_cjs.generateId(),
|
|
644
644
|
toolName: toolCall.function.name,
|
|
645
645
|
input: toolCall.function.arguments
|
|
646
646
|
});
|
|
@@ -682,15 +682,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
682
682
|
stream: true,
|
|
683
683
|
stream_options: { include_usage: true }
|
|
684
684
|
};
|
|
685
|
-
const { responseHeaders, value: response } = await
|
|
685
|
+
const { responseHeaders, value: response } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
686
686
|
url: this.config.url({
|
|
687
687
|
path: "/chat/completions",
|
|
688
688
|
modelId: this.modelId
|
|
689
689
|
}),
|
|
690
|
-
headers:
|
|
690
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
691
691
|
body,
|
|
692
692
|
failedResponseHandler: this.failedResponseHandler,
|
|
693
|
-
successfulResponseHandler:
|
|
693
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createEventSourceResponseHandler(
|
|
694
694
|
deepseekChatChunkSchema
|
|
695
695
|
),
|
|
696
696
|
abortSignal: options.abortSignal,
|
|
@@ -788,13 +788,13 @@ var DeepSeekChatLanguageModel = class {
|
|
|
788
788
|
const index = toolCallDelta.index;
|
|
789
789
|
if (toolCalls[index] == null) {
|
|
790
790
|
if (toolCallDelta.id == null) {
|
|
791
|
-
throw new
|
|
791
|
+
throw new chunkRD2IELJM_cjs.InvalidResponseDataError({
|
|
792
792
|
data: toolCallDelta,
|
|
793
793
|
message: `Expected 'id' to be a string.`
|
|
794
794
|
});
|
|
795
795
|
}
|
|
796
796
|
if (((_a24 = toolCallDelta.function) == null ? void 0 : _a24.name) == null) {
|
|
797
|
-
throw new
|
|
797
|
+
throw new chunkRD2IELJM_cjs.InvalidResponseDataError({
|
|
798
798
|
data: toolCallDelta,
|
|
799
799
|
message: `Expected 'function.name' to be a string.`
|
|
800
800
|
});
|
|
@@ -822,14 +822,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
822
822
|
delta: toolCall2.function.arguments
|
|
823
823
|
});
|
|
824
824
|
}
|
|
825
|
-
if (
|
|
825
|
+
if (chunkRD2IELJM_cjs.isParsableJson(toolCall2.function.arguments)) {
|
|
826
826
|
controller.enqueue({
|
|
827
827
|
type: "tool-input-end",
|
|
828
828
|
id: toolCall2.id
|
|
829
829
|
});
|
|
830
830
|
controller.enqueue({
|
|
831
831
|
type: "tool-call",
|
|
832
|
-
toolCallId: (_e = toolCall2.id) != null ? _e :
|
|
832
|
+
toolCallId: (_e = toolCall2.id) != null ? _e : chunkRD2IELJM_cjs.generateId(),
|
|
833
833
|
toolName: toolCall2.function.name,
|
|
834
834
|
input: toolCall2.function.arguments
|
|
835
835
|
});
|
|
@@ -850,14 +850,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
850
850
|
id: toolCall.id,
|
|
851
851
|
delta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
|
|
852
852
|
});
|
|
853
|
-
if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null &&
|
|
853
|
+
if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && chunkRD2IELJM_cjs.isParsableJson(toolCall.function.arguments)) {
|
|
854
854
|
controller.enqueue({
|
|
855
855
|
type: "tool-input-end",
|
|
856
856
|
id: toolCall.id
|
|
857
857
|
});
|
|
858
858
|
controller.enqueue({
|
|
859
859
|
type: "tool-call",
|
|
860
|
-
toolCallId: (_l = toolCall.id) != null ? _l :
|
|
860
|
+
toolCallId: (_l = toolCall.id) != null ? _l : chunkRD2IELJM_cjs.generateId(),
|
|
861
861
|
toolName: toolCall.function.name,
|
|
862
862
|
input: toolCall.function.arguments
|
|
863
863
|
});
|
|
@@ -883,7 +883,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
883
883
|
});
|
|
884
884
|
controller.enqueue({
|
|
885
885
|
type: "tool-call",
|
|
886
|
-
toolCallId: (_a24 = toolCall.id) != null ? _a24 :
|
|
886
|
+
toolCallId: (_a24 = toolCall.id) != null ? _a24 : chunkRD2IELJM_cjs.generateId(),
|
|
887
887
|
toolName: toolCall.function.name,
|
|
888
888
|
input: toolCall.function.arguments
|
|
889
889
|
});
|
|
@@ -916,12 +916,12 @@ var DeepSeekChatLanguageModel = class {
|
|
|
916
916
|
var VERSION3 = "1.0.33" ;
|
|
917
917
|
function createDeepSeek(options = {}) {
|
|
918
918
|
var _a24;
|
|
919
|
-
const baseURL =
|
|
919
|
+
const baseURL = chunkRD2IELJM_cjs.withoutTrailingSlash(
|
|
920
920
|
(_a24 = options.baseURL) != null ? _a24 : "https://api.deepseek.com"
|
|
921
921
|
);
|
|
922
|
-
const getHeaders = () =>
|
|
922
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
923
923
|
{
|
|
924
|
-
Authorization: `Bearer ${
|
|
924
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
925
925
|
apiKey: options.apiKey,
|
|
926
926
|
environmentVariableName: "DEEPSEEK_API_KEY",
|
|
927
927
|
description: "DeepSeek API key"
|
|
@@ -942,10 +942,10 @@ function createDeepSeek(options = {}) {
|
|
|
942
942
|
provider.languageModel = createLanguageModel;
|
|
943
943
|
provider.chat = createLanguageModel;
|
|
944
944
|
provider.textEmbeddingModel = (modelId) => {
|
|
945
|
-
throw new
|
|
945
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
946
946
|
};
|
|
947
947
|
provider.imageModel = (modelId) => {
|
|
948
|
-
throw new
|
|
948
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
949
949
|
};
|
|
950
950
|
return provider;
|
|
951
951
|
}
|
|
@@ -972,7 +972,7 @@ function convertToGroqChatMessages(prompt) {
|
|
|
972
972
|
}
|
|
973
973
|
case "file": {
|
|
974
974
|
if (!part.mediaType.startsWith("image/")) {
|
|
975
|
-
throw new
|
|
975
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
976
976
|
functionality: "Non-image file content parts"
|
|
977
977
|
});
|
|
978
978
|
}
|
|
@@ -980,7 +980,7 @@ function convertToGroqChatMessages(prompt) {
|
|
|
980
980
|
return {
|
|
981
981
|
type: "image_url",
|
|
982
982
|
image_url: {
|
|
983
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
983
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunkRD2IELJM_cjs.convertToBase64(part.data)}`
|
|
984
984
|
}
|
|
985
985
|
};
|
|
986
986
|
}
|
|
@@ -1106,7 +1106,7 @@ var groqErrorDataSchema = z45.z.object({
|
|
|
1106
1106
|
type: z45.z.string()
|
|
1107
1107
|
})
|
|
1108
1108
|
});
|
|
1109
|
-
var groqFailedResponseHandler =
|
|
1109
|
+
var groqFailedResponseHandler = chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
1110
1110
|
errorSchema: groqErrorDataSchema,
|
|
1111
1111
|
errorToMessage: (data) => data.error.message
|
|
1112
1112
|
});
|
|
@@ -1181,7 +1181,7 @@ function prepareTools2({
|
|
|
1181
1181
|
};
|
|
1182
1182
|
default: {
|
|
1183
1183
|
const _exhaustiveCheck = type;
|
|
1184
|
-
throw new
|
|
1184
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
1185
1185
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1186
1186
|
});
|
|
1187
1187
|
}
|
|
@@ -1232,7 +1232,7 @@ var GroqChatLanguageModel = class {
|
|
|
1232
1232
|
}) {
|
|
1233
1233
|
var _a24, _b17;
|
|
1234
1234
|
const warnings = [];
|
|
1235
|
-
const groqOptions = await
|
|
1235
|
+
const groqOptions = await chunkRD2IELJM_cjs.parseProviderOptions({
|
|
1236
1236
|
provider: "groq",
|
|
1237
1237
|
providerOptions,
|
|
1238
1238
|
schema: groqProviderOptions
|
|
@@ -1304,15 +1304,15 @@ var GroqChatLanguageModel = class {
|
|
|
1304
1304
|
responseHeaders,
|
|
1305
1305
|
value: response,
|
|
1306
1306
|
rawValue: rawResponse
|
|
1307
|
-
} = await
|
|
1307
|
+
} = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
1308
1308
|
url: this.config.url({
|
|
1309
1309
|
path: "/chat/completions",
|
|
1310
1310
|
modelId: this.modelId
|
|
1311
1311
|
}),
|
|
1312
|
-
headers:
|
|
1312
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
1313
1313
|
body: args,
|
|
1314
1314
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1315
|
-
successfulResponseHandler:
|
|
1315
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
1316
1316
|
groqChatResponseSchema
|
|
1317
1317
|
),
|
|
1318
1318
|
abortSignal: options.abortSignal,
|
|
@@ -1335,7 +1335,7 @@ var GroqChatLanguageModel = class {
|
|
|
1335
1335
|
for (const toolCall of choice2.message.tool_calls) {
|
|
1336
1336
|
content.push({
|
|
1337
1337
|
type: "tool-call",
|
|
1338
|
-
toolCallId: (_a24 = toolCall.id) != null ? _a24 :
|
|
1338
|
+
toolCallId: (_a24 = toolCall.id) != null ? _a24 : chunkRD2IELJM_cjs.generateId(),
|
|
1339
1339
|
toolName: toolCall.function.name,
|
|
1340
1340
|
input: toolCall.function.arguments
|
|
1341
1341
|
});
|
|
@@ -1362,18 +1362,18 @@ var GroqChatLanguageModel = class {
|
|
|
1362
1362
|
async doStream(options) {
|
|
1363
1363
|
const { args, warnings } = await this.getArgs({ ...options, stream: true });
|
|
1364
1364
|
const body = JSON.stringify({ ...args, stream: true });
|
|
1365
|
-
const { responseHeaders, value: response } = await
|
|
1365
|
+
const { responseHeaders, value: response } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
1366
1366
|
url: this.config.url({
|
|
1367
1367
|
path: "/chat/completions",
|
|
1368
1368
|
modelId: this.modelId
|
|
1369
1369
|
}),
|
|
1370
|
-
headers:
|
|
1370
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
1371
1371
|
body: {
|
|
1372
1372
|
...args,
|
|
1373
1373
|
stream: true
|
|
1374
1374
|
},
|
|
1375
1375
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1376
|
-
successfulResponseHandler:
|
|
1376
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createEventSourceResponseHandler(groqChatChunkSchema),
|
|
1377
1377
|
abortSignal: options.abortSignal,
|
|
1378
1378
|
fetch: this.config.fetch
|
|
1379
1379
|
});
|
|
@@ -1461,19 +1461,19 @@ var GroqChatLanguageModel = class {
|
|
|
1461
1461
|
const index = toolCallDelta.index;
|
|
1462
1462
|
if (toolCalls[index] == null) {
|
|
1463
1463
|
if (toolCallDelta.type !== "function") {
|
|
1464
|
-
throw new
|
|
1464
|
+
throw new chunkRD2IELJM_cjs.InvalidResponseDataError({
|
|
1465
1465
|
data: toolCallDelta,
|
|
1466
1466
|
message: `Expected 'function' type.`
|
|
1467
1467
|
});
|
|
1468
1468
|
}
|
|
1469
1469
|
if (toolCallDelta.id == null) {
|
|
1470
|
-
throw new
|
|
1470
|
+
throw new chunkRD2IELJM_cjs.InvalidResponseDataError({
|
|
1471
1471
|
data: toolCallDelta,
|
|
1472
1472
|
message: `Expected 'id' to be a string.`
|
|
1473
1473
|
});
|
|
1474
1474
|
}
|
|
1475
1475
|
if (((_g = toolCallDelta.function) == null ? void 0 : _g.name) == null) {
|
|
1476
|
-
throw new
|
|
1476
|
+
throw new chunkRD2IELJM_cjs.InvalidResponseDataError({
|
|
1477
1477
|
data: toolCallDelta,
|
|
1478
1478
|
message: `Expected 'function.name' to be a string.`
|
|
1479
1479
|
});
|
|
@@ -1501,14 +1501,14 @@ var GroqChatLanguageModel = class {
|
|
|
1501
1501
|
delta: toolCall2.function.arguments
|
|
1502
1502
|
});
|
|
1503
1503
|
}
|
|
1504
|
-
if (
|
|
1504
|
+
if (chunkRD2IELJM_cjs.isParsableJson(toolCall2.function.arguments)) {
|
|
1505
1505
|
controller.enqueue({
|
|
1506
1506
|
type: "tool-input-end",
|
|
1507
1507
|
id: toolCall2.id
|
|
1508
1508
|
});
|
|
1509
1509
|
controller.enqueue({
|
|
1510
1510
|
type: "tool-call",
|
|
1511
|
-
toolCallId: (_k = toolCall2.id) != null ? _k :
|
|
1511
|
+
toolCallId: (_k = toolCall2.id) != null ? _k : chunkRD2IELJM_cjs.generateId(),
|
|
1512
1512
|
toolName: toolCall2.function.name,
|
|
1513
1513
|
input: toolCall2.function.arguments
|
|
1514
1514
|
});
|
|
@@ -1529,14 +1529,14 @@ var GroqChatLanguageModel = class {
|
|
|
1529
1529
|
id: toolCall.id,
|
|
1530
1530
|
delta: (_o = toolCallDelta.function.arguments) != null ? _o : ""
|
|
1531
1531
|
});
|
|
1532
|
-
if (((_p = toolCall.function) == null ? void 0 : _p.name) != null && ((_q = toolCall.function) == null ? void 0 : _q.arguments) != null &&
|
|
1532
|
+
if (((_p = toolCall.function) == null ? void 0 : _p.name) != null && ((_q = toolCall.function) == null ? void 0 : _q.arguments) != null && chunkRD2IELJM_cjs.isParsableJson(toolCall.function.arguments)) {
|
|
1533
1533
|
controller.enqueue({
|
|
1534
1534
|
type: "tool-input-end",
|
|
1535
1535
|
id: toolCall.id
|
|
1536
1536
|
});
|
|
1537
1537
|
controller.enqueue({
|
|
1538
1538
|
type: "tool-call",
|
|
1539
|
-
toolCallId: (_r = toolCall.id) != null ? _r :
|
|
1539
|
+
toolCallId: (_r = toolCall.id) != null ? _r : chunkRD2IELJM_cjs.generateId(),
|
|
1540
1540
|
toolName: toolCall.function.name,
|
|
1541
1541
|
input: toolCall.function.arguments
|
|
1542
1542
|
});
|
|
@@ -1661,15 +1661,15 @@ var GroqTranscriptionModel = class {
|
|
|
1661
1661
|
}) {
|
|
1662
1662
|
var _a24, _b17, _c, _d, _e;
|
|
1663
1663
|
const warnings = [];
|
|
1664
|
-
const groqOptions = await
|
|
1664
|
+
const groqOptions = await chunkRD2IELJM_cjs.parseProviderOptions({
|
|
1665
1665
|
provider: "groq",
|
|
1666
1666
|
providerOptions,
|
|
1667
1667
|
schema: groqProviderOptionsSchema
|
|
1668
1668
|
});
|
|
1669
1669
|
const formData = new FormData();
|
|
1670
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([
|
|
1670
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([chunkRD2IELJM_cjs.convertBase64ToUint8Array(audio)]);
|
|
1671
1671
|
formData.append("model", this.modelId);
|
|
1672
|
-
const fileExtension =
|
|
1672
|
+
const fileExtension = chunkRD2IELJM_cjs.mediaTypeToExtension(mediaType);
|
|
1673
1673
|
formData.append(
|
|
1674
1674
|
"file",
|
|
1675
1675
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -1703,15 +1703,15 @@ var GroqTranscriptionModel = class {
|
|
|
1703
1703
|
value: response,
|
|
1704
1704
|
responseHeaders,
|
|
1705
1705
|
rawValue: rawResponse
|
|
1706
|
-
} = await
|
|
1706
|
+
} = await chunkRD2IELJM_cjs.postFormDataToApi({
|
|
1707
1707
|
url: this.config.url({
|
|
1708
1708
|
path: "/audio/transcriptions",
|
|
1709
1709
|
modelId: this.modelId
|
|
1710
1710
|
}),
|
|
1711
|
-
headers:
|
|
1711
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
1712
1712
|
formData,
|
|
1713
1713
|
failedResponseHandler: groqFailedResponseHandler,
|
|
1714
|
-
successfulResponseHandler:
|
|
1714
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
1715
1715
|
groqTranscriptionResponseSchema
|
|
1716
1716
|
),
|
|
1717
1717
|
abortSignal: options.abortSignal,
|
|
@@ -1760,7 +1760,7 @@ var groqTranscriptionResponseSchema = z45.z.object({
|
|
|
1760
1760
|
})
|
|
1761
1761
|
).nullish()
|
|
1762
1762
|
});
|
|
1763
|
-
var browserSearch =
|
|
1763
|
+
var browserSearch = chunkRD2IELJM_cjs.createProviderDefinedToolFactory({
|
|
1764
1764
|
id: "groq.browser_search",
|
|
1765
1765
|
name: "browser_search",
|
|
1766
1766
|
inputSchema: z45.z.object({})
|
|
@@ -1771,10 +1771,10 @@ var groqTools = {
|
|
|
1771
1771
|
var VERSION4 = "2.0.34" ;
|
|
1772
1772
|
function createGroq(options = {}) {
|
|
1773
1773
|
var _a24;
|
|
1774
|
-
const baseURL = (_a24 =
|
|
1775
|
-
const getHeaders = () =>
|
|
1774
|
+
const baseURL = (_a24 = chunkRD2IELJM_cjs.withoutTrailingSlash(options.baseURL)) != null ? _a24 : "https://api.groq.com/openai/v1";
|
|
1775
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
1776
1776
|
{
|
|
1777
|
-
Authorization: `Bearer ${
|
|
1777
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
1778
1778
|
apiKey: options.apiKey,
|
|
1779
1779
|
environmentVariableName: "GROQ_API_KEY",
|
|
1780
1780
|
description: "Groq"
|
|
@@ -1811,10 +1811,10 @@ function createGroq(options = {}) {
|
|
|
1811
1811
|
provider.languageModel = createLanguageModel;
|
|
1812
1812
|
provider.chat = createChatModel;
|
|
1813
1813
|
provider.textEmbeddingModel = (modelId) => {
|
|
1814
|
-
throw new
|
|
1814
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
1815
1815
|
};
|
|
1816
1816
|
provider.imageModel = (modelId) => {
|
|
1817
|
-
throw new
|
|
1817
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
1818
1818
|
};
|
|
1819
1819
|
provider.transcription = createTranscriptionModel;
|
|
1820
1820
|
provider.transcriptionModel = createTranscriptionModel;
|
|
@@ -1845,7 +1845,7 @@ function convertToMistralChatMessages(prompt) {
|
|
|
1845
1845
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
1846
1846
|
return {
|
|
1847
1847
|
type: "image_url",
|
|
1848
|
-
image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
1848
|
+
image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunkRD2IELJM_cjs.convertToBase64(part.data)}`
|
|
1849
1849
|
};
|
|
1850
1850
|
} else if (part.mediaType === "application/pdf") {
|
|
1851
1851
|
return {
|
|
@@ -1853,7 +1853,7 @@ function convertToMistralChatMessages(prompt) {
|
|
|
1853
1853
|
document_url: part.data.toString()
|
|
1854
1854
|
};
|
|
1855
1855
|
} else {
|
|
1856
|
-
throw new
|
|
1856
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
1857
1857
|
functionality: "Only images and PDF file parts are supported"
|
|
1858
1858
|
});
|
|
1859
1859
|
}
|
|
@@ -1994,7 +1994,7 @@ var mistralErrorDataSchema = z45.z.object({
|
|
|
1994
1994
|
param: z45.z.string().nullable(),
|
|
1995
1995
|
code: z45.z.string().nullable()
|
|
1996
1996
|
});
|
|
1997
|
-
var mistralFailedResponseHandler =
|
|
1997
|
+
var mistralFailedResponseHandler = chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
1998
1998
|
errorSchema: mistralErrorDataSchema,
|
|
1999
1999
|
errorToMessage: (data) => data.message
|
|
2000
2000
|
});
|
|
@@ -2044,7 +2044,7 @@ function prepareTools3({
|
|
|
2044
2044
|
};
|
|
2045
2045
|
default: {
|
|
2046
2046
|
const _exhaustiveCheck = type;
|
|
2047
|
-
throw new
|
|
2047
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
2048
2048
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
2049
2049
|
});
|
|
2050
2050
|
}
|
|
@@ -2059,7 +2059,7 @@ var MistralChatLanguageModel = class {
|
|
|
2059
2059
|
var _a24;
|
|
2060
2060
|
this.modelId = modelId;
|
|
2061
2061
|
this.config = config;
|
|
2062
|
-
this.generateId = (_a24 = config.generateId) != null ? _a24 :
|
|
2062
|
+
this.generateId = (_a24 = config.generateId) != null ? _a24 : chunkRD2IELJM_cjs.generateId;
|
|
2063
2063
|
}
|
|
2064
2064
|
get provider() {
|
|
2065
2065
|
return this.config.provider;
|
|
@@ -2081,7 +2081,7 @@ var MistralChatLanguageModel = class {
|
|
|
2081
2081
|
}) {
|
|
2082
2082
|
var _a24, _b17, _c, _d;
|
|
2083
2083
|
const warnings = [];
|
|
2084
|
-
const options = (_a24 = await
|
|
2084
|
+
const options = (_a24 = await chunkRD2IELJM_cjs.parseProviderOptions({
|
|
2085
2085
|
provider: "mistral",
|
|
2086
2086
|
providerOptions,
|
|
2087
2087
|
schema: mistralLanguageModelOptions
|
|
@@ -2113,7 +2113,7 @@ var MistralChatLanguageModel = class {
|
|
|
2113
2113
|
const structuredOutputs = (_b17 = options.structuredOutputs) != null ? _b17 : true;
|
|
2114
2114
|
const strictJsonSchema = (_c = options.strictJsonSchema) != null ? _c : false;
|
|
2115
2115
|
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && !(responseFormat == null ? void 0 : responseFormat.schema)) {
|
|
2116
|
-
prompt =
|
|
2116
|
+
prompt = chunkRD2IELJM_cjs.injectJsonInstructionIntoMessages({
|
|
2117
2117
|
messages: prompt,
|
|
2118
2118
|
schema: responseFormat.schema
|
|
2119
2119
|
});
|
|
@@ -2168,12 +2168,12 @@ var MistralChatLanguageModel = class {
|
|
|
2168
2168
|
responseHeaders,
|
|
2169
2169
|
value: response,
|
|
2170
2170
|
rawValue: rawResponse
|
|
2171
|
-
} = await
|
|
2171
|
+
} = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
2172
2172
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2173
|
-
headers:
|
|
2173
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2174
2174
|
body,
|
|
2175
2175
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2176
|
-
successfulResponseHandler:
|
|
2176
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
2177
2177
|
mistralChatResponseSchema
|
|
2178
2178
|
),
|
|
2179
2179
|
abortSignal: options.abortSignal,
|
|
@@ -2230,12 +2230,12 @@ var MistralChatLanguageModel = class {
|
|
|
2230
2230
|
async doStream(options) {
|
|
2231
2231
|
const { args, warnings } = await this.getArgs(options);
|
|
2232
2232
|
const body = { ...args, stream: true };
|
|
2233
|
-
const { responseHeaders, value: response } = await
|
|
2233
|
+
const { responseHeaders, value: response } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
2234
2234
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2235
|
-
headers:
|
|
2235
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2236
2236
|
body,
|
|
2237
2237
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2238
|
-
successfulResponseHandler:
|
|
2238
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createEventSourceResponseHandler(
|
|
2239
2239
|
mistralChatChunkSchema
|
|
2240
2240
|
),
|
|
2241
2241
|
abortSignal: options.abortSignal,
|
|
@@ -2508,7 +2508,7 @@ var MistralEmbeddingModel = class {
|
|
|
2508
2508
|
headers
|
|
2509
2509
|
}) {
|
|
2510
2510
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
2511
|
-
throw new
|
|
2511
|
+
throw new chunkRD2IELJM_cjs.TooManyEmbeddingValuesForCallError({
|
|
2512
2512
|
provider: this.provider,
|
|
2513
2513
|
modelId: this.modelId,
|
|
2514
2514
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -2519,16 +2519,16 @@ var MistralEmbeddingModel = class {
|
|
|
2519
2519
|
responseHeaders,
|
|
2520
2520
|
value: response,
|
|
2521
2521
|
rawValue
|
|
2522
|
-
} = await
|
|
2522
|
+
} = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
2523
2523
|
url: `${this.config.baseURL}/embeddings`,
|
|
2524
|
-
headers:
|
|
2524
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), headers),
|
|
2525
2525
|
body: {
|
|
2526
2526
|
model: this.modelId,
|
|
2527
2527
|
input: values,
|
|
2528
2528
|
encoding_format: "float"
|
|
2529
2529
|
},
|
|
2530
2530
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
2531
|
-
successfulResponseHandler:
|
|
2531
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
2532
2532
|
MistralTextEmbeddingResponseSchema
|
|
2533
2533
|
),
|
|
2534
2534
|
abortSignal,
|
|
@@ -2548,10 +2548,10 @@ var MistralTextEmbeddingResponseSchema = z45.z.object({
|
|
|
2548
2548
|
var VERSION5 = "2.0.27" ;
|
|
2549
2549
|
function createMistral(options = {}) {
|
|
2550
2550
|
var _a24;
|
|
2551
|
-
const baseURL = (_a24 =
|
|
2552
|
-
const getHeaders = () =>
|
|
2551
|
+
const baseURL = (_a24 = chunkRD2IELJM_cjs.withoutTrailingSlash(options.baseURL)) != null ? _a24 : "https://api.mistral.ai/v1";
|
|
2552
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
2553
2553
|
{
|
|
2554
|
-
Authorization: `Bearer ${
|
|
2554
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
2555
2555
|
apiKey: options.apiKey,
|
|
2556
2556
|
environmentVariableName: "MISTRAL_API_KEY",
|
|
2557
2557
|
description: "Mistral"
|
|
@@ -2587,7 +2587,7 @@ function createMistral(options = {}) {
|
|
|
2587
2587
|
provider.textEmbedding = createEmbeddingModel;
|
|
2588
2588
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
2589
2589
|
provider.imageModel = (modelId) => {
|
|
2590
|
-
throw new
|
|
2590
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
2591
2591
|
};
|
|
2592
2592
|
return provider;
|
|
2593
2593
|
}
|
|
@@ -2625,7 +2625,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2625
2625
|
} : {
|
|
2626
2626
|
type: "file_url",
|
|
2627
2627
|
file_url: {
|
|
2628
|
-
url: typeof part.data === "string" ? part.data :
|
|
2628
|
+
url: typeof part.data === "string" ? part.data : chunkRD2IELJM_cjs.convertUint8ArrayToBase64(part.data)
|
|
2629
2629
|
},
|
|
2630
2630
|
file_name: part.filename || `document-${index}.pdf`
|
|
2631
2631
|
};
|
|
@@ -2638,7 +2638,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2638
2638
|
} : {
|
|
2639
2639
|
type: "image_url",
|
|
2640
2640
|
image_url: {
|
|
2641
|
-
url: `data:${(_a24 = part.mediaType) != null ? _a24 : "image/jpeg"};base64,${typeof part.data === "string" ? part.data :
|
|
2641
|
+
url: `data:${(_a24 = part.mediaType) != null ? _a24 : "image/jpeg"};base64,${typeof part.data === "string" ? part.data : chunkRD2IELJM_cjs.convertUint8ArrayToBase64(part.data)}`
|
|
2642
2642
|
}
|
|
2643
2643
|
};
|
|
2644
2644
|
}
|
|
@@ -2652,7 +2652,7 @@ function convertToPerplexityMessages(prompt) {
|
|
|
2652
2652
|
break;
|
|
2653
2653
|
}
|
|
2654
2654
|
case "tool": {
|
|
2655
|
-
throw new
|
|
2655
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
2656
2656
|
functionality: "Tool messages"
|
|
2657
2657
|
});
|
|
2658
2658
|
}
|
|
@@ -2747,15 +2747,15 @@ var PerplexityLanguageModel = class {
|
|
|
2747
2747
|
responseHeaders,
|
|
2748
2748
|
value: response,
|
|
2749
2749
|
rawValue: rawResponse
|
|
2750
|
-
} = await
|
|
2750
|
+
} = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
2751
2751
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2752
|
-
headers:
|
|
2752
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2753
2753
|
body,
|
|
2754
|
-
failedResponseHandler:
|
|
2754
|
+
failedResponseHandler: chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
2755
2755
|
errorSchema: perplexityErrorSchema,
|
|
2756
2756
|
errorToMessage
|
|
2757
2757
|
}),
|
|
2758
|
-
successfulResponseHandler:
|
|
2758
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
2759
2759
|
perplexityResponseSchema
|
|
2760
2760
|
),
|
|
2761
2761
|
abortSignal: options.abortSignal,
|
|
@@ -2812,15 +2812,15 @@ var PerplexityLanguageModel = class {
|
|
|
2812
2812
|
async doStream(options) {
|
|
2813
2813
|
const { args, warnings } = this.getArgs(options);
|
|
2814
2814
|
const body = { ...args, stream: true };
|
|
2815
|
-
const { responseHeaders, value: response } = await
|
|
2815
|
+
const { responseHeaders, value: response } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
2816
2816
|
url: `${this.config.baseURL}/chat/completions`,
|
|
2817
|
-
headers:
|
|
2817
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
2818
2818
|
body,
|
|
2819
|
-
failedResponseHandler:
|
|
2819
|
+
failedResponseHandler: chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
2820
2820
|
errorSchema: perplexityErrorSchema,
|
|
2821
2821
|
errorToMessage
|
|
2822
2822
|
}),
|
|
2823
|
-
successfulResponseHandler:
|
|
2823
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createEventSourceResponseHandler(
|
|
2824
2824
|
perplexityChunkSchema
|
|
2825
2825
|
),
|
|
2826
2826
|
abortSignal: options.abortSignal,
|
|
@@ -3004,9 +3004,9 @@ var errorToMessage = (data) => {
|
|
|
3004
3004
|
};
|
|
3005
3005
|
var VERSION6 = "2.0.23" ;
|
|
3006
3006
|
function createPerplexity(options = {}) {
|
|
3007
|
-
const getHeaders = () =>
|
|
3007
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
3008
3008
|
{
|
|
3009
|
-
Authorization: `Bearer ${
|
|
3009
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
3010
3010
|
apiKey: options.apiKey,
|
|
3011
3011
|
environmentVariableName: "PERPLEXITY_API_KEY",
|
|
3012
3012
|
description: "Perplexity"
|
|
@@ -3018,21 +3018,21 @@ function createPerplexity(options = {}) {
|
|
|
3018
3018
|
const createLanguageModel = (modelId) => {
|
|
3019
3019
|
var _a24;
|
|
3020
3020
|
return new PerplexityLanguageModel(modelId, {
|
|
3021
|
-
baseURL:
|
|
3021
|
+
baseURL: chunkRD2IELJM_cjs.withoutTrailingSlash(
|
|
3022
3022
|
(_a24 = options.baseURL) != null ? _a24 : "https://api.perplexity.ai"
|
|
3023
3023
|
),
|
|
3024
3024
|
headers: getHeaders,
|
|
3025
|
-
generateId:
|
|
3025
|
+
generateId: chunkRD2IELJM_cjs.generateId,
|
|
3026
3026
|
fetch: options.fetch
|
|
3027
3027
|
});
|
|
3028
3028
|
};
|
|
3029
3029
|
const provider = (modelId) => createLanguageModel(modelId);
|
|
3030
3030
|
provider.languageModel = createLanguageModel;
|
|
3031
3031
|
provider.textEmbeddingModel = (modelId) => {
|
|
3032
|
-
throw new
|
|
3032
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
3033
3033
|
};
|
|
3034
3034
|
provider.imageModel = (modelId) => {
|
|
3035
|
-
throw new
|
|
3035
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
3036
3036
|
};
|
|
3037
3037
|
return provider;
|
|
3038
3038
|
}
|
|
@@ -3067,9 +3067,9 @@ var TogetherAIImageModel = class {
|
|
|
3067
3067
|
}
|
|
3068
3068
|
const currentDate = (_c = (_b17 = (_a24 = this.config._internal) == null ? void 0 : _a24.currentDate) == null ? void 0 : _b17.call(_a24)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3069
3069
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
3070
|
-
const { value: response, responseHeaders } = await
|
|
3070
|
+
const { value: response, responseHeaders } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
3071
3071
|
url: `${this.config.baseURL}/images/generations`,
|
|
3072
|
-
headers:
|
|
3072
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), headers),
|
|
3073
3073
|
body: {
|
|
3074
3074
|
model: this.modelId,
|
|
3075
3075
|
prompt,
|
|
@@ -3082,11 +3082,11 @@ var TogetherAIImageModel = class {
|
|
|
3082
3082
|
response_format: "base64",
|
|
3083
3083
|
...(_d = providerOptions.togetherai) != null ? _d : {}
|
|
3084
3084
|
},
|
|
3085
|
-
failedResponseHandler:
|
|
3085
|
+
failedResponseHandler: chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
3086
3086
|
errorSchema: togetheraiErrorSchema,
|
|
3087
3087
|
errorToMessage: (data) => data.error.message
|
|
3088
3088
|
}),
|
|
3089
|
-
successfulResponseHandler:
|
|
3089
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
3090
3090
|
togetheraiImageResponseSchema
|
|
3091
3091
|
),
|
|
3092
3092
|
abortSignal,
|
|
@@ -3118,12 +3118,12 @@ var togetheraiErrorSchema = z45.z.object({
|
|
|
3118
3118
|
var VERSION7 = "1.0.34" ;
|
|
3119
3119
|
function createTogetherAI(options = {}) {
|
|
3120
3120
|
var _a24;
|
|
3121
|
-
const baseURL =
|
|
3121
|
+
const baseURL = chunkRD2IELJM_cjs.withoutTrailingSlash(
|
|
3122
3122
|
(_a24 = options.baseURL) != null ? _a24 : "https://api.together.xyz/v1/"
|
|
3123
3123
|
);
|
|
3124
|
-
const getHeaders = () =>
|
|
3124
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
3125
3125
|
{
|
|
3126
|
-
Authorization: `Bearer ${
|
|
3126
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
3127
3127
|
apiKey: options.apiKey,
|
|
3128
3128
|
environmentVariableName: "TOGETHER_AI_API_KEY",
|
|
3129
3129
|
description: "TogetherAI"
|
|
@@ -3139,16 +3139,16 @@ function createTogetherAI(options = {}) {
|
|
|
3139
3139
|
fetch: options.fetch
|
|
3140
3140
|
});
|
|
3141
3141
|
const createChatModel = (modelId) => {
|
|
3142
|
-
return new
|
|
3142
|
+
return new chunkRD2IELJM_cjs.OpenAICompatibleChatLanguageModel(
|
|
3143
3143
|
modelId,
|
|
3144
3144
|
getCommonModelConfig("chat")
|
|
3145
3145
|
);
|
|
3146
3146
|
};
|
|
3147
|
-
const createCompletionModel = (modelId) => new
|
|
3147
|
+
const createCompletionModel = (modelId) => new chunkRD2IELJM_cjs.OpenAICompatibleCompletionLanguageModel(
|
|
3148
3148
|
modelId,
|
|
3149
3149
|
getCommonModelConfig("completion")
|
|
3150
3150
|
);
|
|
3151
|
-
const createTextEmbeddingModel = (modelId) => new
|
|
3151
|
+
const createTextEmbeddingModel = (modelId) => new chunkRD2IELJM_cjs.OpenAICompatibleEmbeddingModel(
|
|
3152
3152
|
modelId,
|
|
3153
3153
|
getCommonModelConfig("embedding")
|
|
3154
3154
|
);
|
|
@@ -3193,11 +3193,11 @@ function convertToXaiChatMessages(prompt) {
|
|
|
3193
3193
|
return {
|
|
3194
3194
|
type: "image_url",
|
|
3195
3195
|
image_url: {
|
|
3196
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
3196
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${chunkRD2IELJM_cjs.convertToBase64(part.data)}`
|
|
3197
3197
|
}
|
|
3198
3198
|
};
|
|
3199
3199
|
} else {
|
|
3200
|
-
throw new
|
|
3200
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
3201
3201
|
functionality: `file part media type ${part.mediaType}`
|
|
3202
3202
|
});
|
|
3203
3203
|
}
|
|
@@ -3383,7 +3383,7 @@ var xaiErrorDataSchema = z45.z.object({
|
|
|
3383
3383
|
code: z45.z.union([z45.z.string(), z45.z.number()]).nullish()
|
|
3384
3384
|
})
|
|
3385
3385
|
});
|
|
3386
|
-
var xaiFailedResponseHandler =
|
|
3386
|
+
var xaiFailedResponseHandler = chunkRD2IELJM_cjs.createJsonErrorResponseHandler({
|
|
3387
3387
|
errorSchema: xaiErrorDataSchema,
|
|
3388
3388
|
errorToMessage: (data) => data.error.message
|
|
3389
3389
|
});
|
|
@@ -3432,7 +3432,7 @@ function prepareTools4({
|
|
|
3432
3432
|
};
|
|
3433
3433
|
default: {
|
|
3434
3434
|
const _exhaustiveCheck = type;
|
|
3435
|
-
throw new
|
|
3435
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
3436
3436
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
3437
3437
|
});
|
|
3438
3438
|
}
|
|
@@ -3467,7 +3467,7 @@ var XaiChatLanguageModel = class {
|
|
|
3467
3467
|
}) {
|
|
3468
3468
|
var _a24, _b17, _c;
|
|
3469
3469
|
const warnings = [];
|
|
3470
|
-
const options = (_a24 = await
|
|
3470
|
+
const options = (_a24 = await chunkRD2IELJM_cjs.parseProviderOptions({
|
|
3471
3471
|
provider: "xai",
|
|
3472
3472
|
providerOptions,
|
|
3473
3473
|
schema: xaiProviderOptions
|
|
@@ -3580,19 +3580,19 @@ var XaiChatLanguageModel = class {
|
|
|
3580
3580
|
responseHeaders,
|
|
3581
3581
|
value: response,
|
|
3582
3582
|
rawValue: rawResponse
|
|
3583
|
-
} = await
|
|
3583
|
+
} = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
3584
3584
|
url,
|
|
3585
|
-
headers:
|
|
3585
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
3586
3586
|
body,
|
|
3587
3587
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3588
|
-
successfulResponseHandler:
|
|
3588
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
3589
3589
|
xaiChatResponseSchema
|
|
3590
3590
|
),
|
|
3591
3591
|
abortSignal: options.abortSignal,
|
|
3592
3592
|
fetch: this.config.fetch
|
|
3593
3593
|
});
|
|
3594
3594
|
if (response.error != null) {
|
|
3595
|
-
throw new
|
|
3595
|
+
throw new chunkRD2IELJM_cjs.APICallError({
|
|
3596
3596
|
message: response.error,
|
|
3597
3597
|
url,
|
|
3598
3598
|
requestBodyValues: body,
|
|
@@ -3603,7 +3603,7 @@ var XaiChatLanguageModel = class {
|
|
|
3603
3603
|
});
|
|
3604
3604
|
}
|
|
3605
3605
|
if (!response.choices || response.choices.length === 0) {
|
|
3606
|
-
throw new
|
|
3606
|
+
throw new chunkRD2IELJM_cjs.APICallError({
|
|
3607
3607
|
message: "No choices returned from the API",
|
|
3608
3608
|
url,
|
|
3609
3609
|
requestBodyValues: body,
|
|
@@ -3680,22 +3680,22 @@ var XaiChatLanguageModel = class {
|
|
|
3680
3680
|
}
|
|
3681
3681
|
};
|
|
3682
3682
|
const url = `${(_a24 = this.config.baseURL) != null ? _a24 : "https://api.x.ai/v1"}/chat/completions`;
|
|
3683
|
-
const { responseHeaders, value: response } = await
|
|
3683
|
+
const { responseHeaders, value: response } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
3684
3684
|
url,
|
|
3685
|
-
headers:
|
|
3685
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
3686
3686
|
body,
|
|
3687
3687
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3688
3688
|
successfulResponseHandler: async ({ response: response2 }) => {
|
|
3689
|
-
const responseHeaders2 =
|
|
3689
|
+
const responseHeaders2 = chunkRD2IELJM_cjs.extractResponseHeaders(response2);
|
|
3690
3690
|
const contentType = response2.headers.get("content-type");
|
|
3691
3691
|
if (contentType == null ? void 0 : contentType.includes("application/json")) {
|
|
3692
3692
|
const responseBody = await response2.text();
|
|
3693
|
-
const parsedError = await
|
|
3693
|
+
const parsedError = await chunkRD2IELJM_cjs.safeParseJSON({
|
|
3694
3694
|
text: responseBody,
|
|
3695
3695
|
schema: xaiStreamErrorSchema
|
|
3696
3696
|
});
|
|
3697
3697
|
if (parsedError.success) {
|
|
3698
|
-
throw new
|
|
3698
|
+
throw new chunkRD2IELJM_cjs.APICallError({
|
|
3699
3699
|
message: parsedError.value.error,
|
|
3700
3700
|
url,
|
|
3701
3701
|
requestBodyValues: body,
|
|
@@ -3705,7 +3705,7 @@ var XaiChatLanguageModel = class {
|
|
|
3705
3705
|
isRetryable: parsedError.value.code === "The service is currently unavailable"
|
|
3706
3706
|
});
|
|
3707
3707
|
}
|
|
3708
|
-
throw new
|
|
3708
|
+
throw new chunkRD2IELJM_cjs.APICallError({
|
|
3709
3709
|
message: "Invalid JSON response",
|
|
3710
3710
|
url,
|
|
3711
3711
|
requestBodyValues: body,
|
|
@@ -3714,7 +3714,7 @@ var XaiChatLanguageModel = class {
|
|
|
3714
3714
|
responseBody
|
|
3715
3715
|
});
|
|
3716
3716
|
}
|
|
3717
|
-
return
|
|
3717
|
+
return chunkRD2IELJM_cjs.createEventSourceResponseHandler(xaiChatChunkSchema)({
|
|
3718
3718
|
response: response2,
|
|
3719
3719
|
url,
|
|
3720
3720
|
requestBodyValues: body
|
|
@@ -4322,10 +4322,10 @@ async function convertToXaiResponsesInput({
|
|
|
4322
4322
|
case "file": {
|
|
4323
4323
|
if (block.mediaType.startsWith("image/")) {
|
|
4324
4324
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
4325
|
-
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${
|
|
4325
|
+
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${chunkRD2IELJM_cjs.convertToBase64(block.data)}`;
|
|
4326
4326
|
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
4327
4327
|
} else {
|
|
4328
|
-
throw new
|
|
4328
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
4329
4329
|
functionality: `file part media type ${block.mediaType}`
|
|
4330
4330
|
});
|
|
4331
4331
|
}
|
|
@@ -4436,8 +4436,8 @@ async function convertToXaiResponsesInput({
|
|
|
4436
4436
|
}
|
|
4437
4437
|
return { input, inputWarnings };
|
|
4438
4438
|
}
|
|
4439
|
-
var webSearchArgsSchema =
|
|
4440
|
-
() =>
|
|
4439
|
+
var webSearchArgsSchema = chunkRD2IELJM_cjs.lazySchema(
|
|
4440
|
+
() => chunkRD2IELJM_cjs.zodSchema(
|
|
4441
4441
|
z45.z.object({
|
|
4442
4442
|
allowedDomains: z45.z.array(z45.z.string()).max(5).optional(),
|
|
4443
4443
|
excludedDomains: z45.z.array(z45.z.string()).max(5).optional(),
|
|
@@ -4445,8 +4445,8 @@ var webSearchArgsSchema = chunkKK2U4Z7X_cjs.lazySchema(
|
|
|
4445
4445
|
})
|
|
4446
4446
|
)
|
|
4447
4447
|
);
|
|
4448
|
-
var webSearchOutputSchema =
|
|
4449
|
-
() =>
|
|
4448
|
+
var webSearchOutputSchema = chunkRD2IELJM_cjs.lazySchema(
|
|
4449
|
+
() => chunkRD2IELJM_cjs.zodSchema(
|
|
4450
4450
|
z45.z.object({
|
|
4451
4451
|
query: z45.z.string(),
|
|
4452
4452
|
sources: z45.z.array(
|
|
@@ -4459,15 +4459,15 @@ var webSearchOutputSchema = chunkKK2U4Z7X_cjs.lazySchema(
|
|
|
4459
4459
|
})
|
|
4460
4460
|
)
|
|
4461
4461
|
);
|
|
4462
|
-
var webSearchToolFactory =
|
|
4462
|
+
var webSearchToolFactory = chunkRD2IELJM_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
4463
4463
|
id: "xai.web_search",
|
|
4464
4464
|
name: "web_search",
|
|
4465
|
-
inputSchema:
|
|
4465
|
+
inputSchema: chunkRD2IELJM_cjs.lazySchema(() => chunkRD2IELJM_cjs.zodSchema(z45.z.object({}))),
|
|
4466
4466
|
outputSchema: webSearchOutputSchema
|
|
4467
4467
|
});
|
|
4468
4468
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
4469
|
-
var xSearchArgsSchema =
|
|
4470
|
-
() =>
|
|
4469
|
+
var xSearchArgsSchema = chunkRD2IELJM_cjs.lazySchema(
|
|
4470
|
+
() => chunkRD2IELJM_cjs.zodSchema(
|
|
4471
4471
|
z45.z.object({
|
|
4472
4472
|
allowedXHandles: z45.z.array(z45.z.string()).max(10).optional(),
|
|
4473
4473
|
excludedXHandles: z45.z.array(z45.z.string()).max(10).optional(),
|
|
@@ -4478,8 +4478,8 @@ var xSearchArgsSchema = chunkKK2U4Z7X_cjs.lazySchema(
|
|
|
4478
4478
|
})
|
|
4479
4479
|
)
|
|
4480
4480
|
);
|
|
4481
|
-
var xSearchOutputSchema =
|
|
4482
|
-
() =>
|
|
4481
|
+
var xSearchOutputSchema = chunkRD2IELJM_cjs.lazySchema(
|
|
4482
|
+
() => chunkRD2IELJM_cjs.zodSchema(
|
|
4483
4483
|
z45.z.object({
|
|
4484
4484
|
query: z45.z.string(),
|
|
4485
4485
|
posts: z45.z.array(
|
|
@@ -4493,10 +4493,10 @@ var xSearchOutputSchema = chunkKK2U4Z7X_cjs.lazySchema(
|
|
|
4493
4493
|
})
|
|
4494
4494
|
)
|
|
4495
4495
|
);
|
|
4496
|
-
var xSearchToolFactory =
|
|
4496
|
+
var xSearchToolFactory = chunkRD2IELJM_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
4497
4497
|
id: "xai.x_search",
|
|
4498
4498
|
name: "x_search",
|
|
4499
|
-
inputSchema:
|
|
4499
|
+
inputSchema: chunkRD2IELJM_cjs.lazySchema(() => chunkRD2IELJM_cjs.zodSchema(z45.z.object({}))),
|
|
4500
4500
|
outputSchema: xSearchOutputSchema
|
|
4501
4501
|
});
|
|
4502
4502
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -4516,7 +4516,7 @@ async function prepareResponsesTools({
|
|
|
4516
4516
|
if (tool2.type === "provider-defined") {
|
|
4517
4517
|
switch (tool2.id) {
|
|
4518
4518
|
case "xai.web_search": {
|
|
4519
|
-
const args = await
|
|
4519
|
+
const args = await chunkRD2IELJM_cjs.validateTypes({
|
|
4520
4520
|
value: tool2.args,
|
|
4521
4521
|
schema: webSearchArgsSchema
|
|
4522
4522
|
});
|
|
@@ -4529,7 +4529,7 @@ async function prepareResponsesTools({
|
|
|
4529
4529
|
break;
|
|
4530
4530
|
}
|
|
4531
4531
|
case "xai.x_search": {
|
|
4532
|
-
const args = await
|
|
4532
|
+
const args = await chunkRD2IELJM_cjs.validateTypes({
|
|
4533
4533
|
value: tool2.args,
|
|
4534
4534
|
schema: xSearchArgsSchema
|
|
4535
4535
|
});
|
|
@@ -4664,7 +4664,7 @@ async function prepareResponsesTools({
|
|
|
4664
4664
|
}
|
|
4665
4665
|
default: {
|
|
4666
4666
|
const _exhaustiveCheck = type;
|
|
4667
|
-
throw new
|
|
4667
|
+
throw new chunkRD2IELJM_cjs.UnsupportedFunctionalityError({
|
|
4668
4668
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
4669
4669
|
});
|
|
4670
4670
|
}
|
|
@@ -4696,7 +4696,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
4696
4696
|
}) {
|
|
4697
4697
|
var _a24, _b17, _c, _d, _e;
|
|
4698
4698
|
const warnings = [];
|
|
4699
|
-
const options = (_a24 = await
|
|
4699
|
+
const options = (_a24 = await chunkRD2IELJM_cjs.parseProviderOptions({
|
|
4700
4700
|
provider: "xai",
|
|
4701
4701
|
providerOptions,
|
|
4702
4702
|
schema: xaiResponsesProviderOptions
|
|
@@ -4784,12 +4784,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
4784
4784
|
responseHeaders,
|
|
4785
4785
|
value: response,
|
|
4786
4786
|
rawValue: rawResponse
|
|
4787
|
-
} = await
|
|
4787
|
+
} = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
4788
4788
|
url: `${(_a24 = this.config.baseURL) != null ? _a24 : "https://api.x.ai/v1"}/responses`,
|
|
4789
|
-
headers:
|
|
4789
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
4790
4790
|
body,
|
|
4791
4791
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4792
|
-
successfulResponseHandler:
|
|
4792
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createJsonResponseHandler(
|
|
4793
4793
|
xaiResponsesResponseSchema
|
|
4794
4794
|
),
|
|
4795
4795
|
abortSignal: options.abortSignal,
|
|
@@ -4925,12 +4925,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
4925
4925
|
...args,
|
|
4926
4926
|
stream: true
|
|
4927
4927
|
};
|
|
4928
|
-
const { responseHeaders, value: response } = await
|
|
4928
|
+
const { responseHeaders, value: response } = await chunkRD2IELJM_cjs.postJsonToApi({
|
|
4929
4929
|
url: `${(_a24 = this.config.baseURL) != null ? _a24 : "https://api.x.ai/v1"}/responses`,
|
|
4930
|
-
headers:
|
|
4930
|
+
headers: chunkRD2IELJM_cjs.combineHeaders(this.config.headers(), options.headers),
|
|
4931
4931
|
body,
|
|
4932
4932
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4933
|
-
successfulResponseHandler:
|
|
4933
|
+
successfulResponseHandler: chunkRD2IELJM_cjs.createEventSourceResponseHandler(
|
|
4934
4934
|
xaiResponsesChunkSchema
|
|
4935
4935
|
),
|
|
4936
4936
|
abortSignal: options.abortSignal,
|
|
@@ -5249,7 +5249,7 @@ var codeExecutionOutputSchema = z45.z.object({
|
|
|
5249
5249
|
output: z45.z.string().describe("the output of the code execution"),
|
|
5250
5250
|
error: z45.z.string().optional().describe("any error that occurred")
|
|
5251
5251
|
});
|
|
5252
|
-
var codeExecutionToolFactory =
|
|
5252
|
+
var codeExecutionToolFactory = chunkRD2IELJM_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
5253
5253
|
id: "xai.code_execution",
|
|
5254
5254
|
name: "code_execution",
|
|
5255
5255
|
inputSchema: z45.z.object({}).describe("no input parameters"),
|
|
@@ -5260,7 +5260,7 @@ var viewImageOutputSchema = z45.z.object({
|
|
|
5260
5260
|
description: z45.z.string().describe("description of the image"),
|
|
5261
5261
|
objects: z45.z.array(z45.z.string()).optional().describe("objects detected in the image")
|
|
5262
5262
|
});
|
|
5263
|
-
var viewImageToolFactory =
|
|
5263
|
+
var viewImageToolFactory = chunkRD2IELJM_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
5264
5264
|
id: "xai.view_image",
|
|
5265
5265
|
name: "view_image",
|
|
5266
5266
|
inputSchema: z45.z.object({}).describe("no input parameters"),
|
|
@@ -5272,7 +5272,7 @@ var viewXVideoOutputSchema = z45.z.object({
|
|
|
5272
5272
|
description: z45.z.string().describe("description of the video content"),
|
|
5273
5273
|
duration: z45.z.number().optional().describe("duration in seconds")
|
|
5274
5274
|
});
|
|
5275
|
-
var viewXVideoToolFactory =
|
|
5275
|
+
var viewXVideoToolFactory = chunkRD2IELJM_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
5276
5276
|
id: "xai.view_x_video",
|
|
5277
5277
|
name: "view_x_video",
|
|
5278
5278
|
inputSchema: z45.z.object({}).describe("no input parameters"),
|
|
@@ -5293,12 +5293,12 @@ var xaiErrorStructure = {
|
|
|
5293
5293
|
};
|
|
5294
5294
|
function createXai(options = {}) {
|
|
5295
5295
|
var _a24;
|
|
5296
|
-
const baseURL =
|
|
5296
|
+
const baseURL = chunkRD2IELJM_cjs.withoutTrailingSlash(
|
|
5297
5297
|
(_a24 = options.baseURL) != null ? _a24 : "https://api.x.ai/v1"
|
|
5298
5298
|
);
|
|
5299
|
-
const getHeaders = () =>
|
|
5299
|
+
const getHeaders = () => chunkRD2IELJM_cjs.withUserAgentSuffix(
|
|
5300
5300
|
{
|
|
5301
|
-
Authorization: `Bearer ${
|
|
5301
|
+
Authorization: `Bearer ${chunkRD2IELJM_cjs.loadApiKey({
|
|
5302
5302
|
apiKey: options.apiKey,
|
|
5303
5303
|
environmentVariableName: "XAI_API_KEY",
|
|
5304
5304
|
description: "xAI API key"
|
|
@@ -5312,7 +5312,7 @@ function createXai(options = {}) {
|
|
|
5312
5312
|
provider: "xai.chat",
|
|
5313
5313
|
baseURL,
|
|
5314
5314
|
headers: getHeaders,
|
|
5315
|
-
generateId:
|
|
5315
|
+
generateId: chunkRD2IELJM_cjs.generateId,
|
|
5316
5316
|
fetch: options.fetch
|
|
5317
5317
|
});
|
|
5318
5318
|
};
|
|
@@ -5321,12 +5321,12 @@ function createXai(options = {}) {
|
|
|
5321
5321
|
provider: "xai.responses",
|
|
5322
5322
|
baseURL,
|
|
5323
5323
|
headers: getHeaders,
|
|
5324
|
-
generateId:
|
|
5324
|
+
generateId: chunkRD2IELJM_cjs.generateId,
|
|
5325
5325
|
fetch: options.fetch
|
|
5326
5326
|
});
|
|
5327
5327
|
};
|
|
5328
5328
|
const createImageModel = (modelId) => {
|
|
5329
|
-
return new
|
|
5329
|
+
return new chunkRD2IELJM_cjs.OpenAICompatibleImageModel(modelId, {
|
|
5330
5330
|
provider: "xai.image",
|
|
5331
5331
|
url: ({ path }) => `${baseURL}${path}`,
|
|
5332
5332
|
headers: getHeaders,
|
|
@@ -5340,7 +5340,7 @@ function createXai(options = {}) {
|
|
|
5340
5340
|
provider.chat = createChatLanguageModel;
|
|
5341
5341
|
provider.responses = createResponsesLanguageModel;
|
|
5342
5342
|
provider.textEmbeddingModel = (modelId) => {
|
|
5343
|
-
throw new
|
|
5343
|
+
throw new chunkRD2IELJM_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
5344
5344
|
};
|
|
5345
5345
|
provider.imageModel = createImageModel;
|
|
5346
5346
|
provider.image = createImageModel;
|
|
@@ -19851,24 +19851,6 @@ function parseModelRouterId(routerId, gatewayPrefix) {
|
|
|
19851
19851
|
};
|
|
19852
19852
|
}
|
|
19853
19853
|
|
|
19854
|
-
// src/llm/model/gateways/constants.ts
|
|
19855
|
-
var PROVIDERS_WITH_INSTALLED_PACKAGES = [
|
|
19856
|
-
"anthropic",
|
|
19857
|
-
"cerebras",
|
|
19858
|
-
"deepinfra",
|
|
19859
|
-
"deepseek",
|
|
19860
|
-
"google",
|
|
19861
|
-
"groq",
|
|
19862
|
-
"mistral",
|
|
19863
|
-
"openai",
|
|
19864
|
-
"openrouter",
|
|
19865
|
-
"perplexity",
|
|
19866
|
-
"togetherai",
|
|
19867
|
-
"vercel",
|
|
19868
|
-
"xai"
|
|
19869
|
-
];
|
|
19870
|
-
var EXCLUDED_PROVIDERS = ["github-copilot"];
|
|
19871
|
-
|
|
19872
19854
|
// src/llm/model/gateways/models-dev.ts
|
|
19873
19855
|
var PROVIDER_OVERRIDES = {
|
|
19874
19856
|
mistral: {
|
|
@@ -19888,7 +19870,7 @@ var PROVIDER_OVERRIDES = {
|
|
|
19888
19870
|
npm: "@ai-sdk/anthropic"
|
|
19889
19871
|
}
|
|
19890
19872
|
};
|
|
19891
|
-
var ModelsDevGateway = class extends
|
|
19873
|
+
var ModelsDevGateway = class extends chunkRD2IELJM_cjs.MastraModelGateway {
|
|
19892
19874
|
id = "models.dev";
|
|
19893
19875
|
name = "models.dev";
|
|
19894
19876
|
providerConfigs = {};
|
|
@@ -19904,12 +19886,12 @@ var ModelsDevGateway = class extends chunkKK2U4Z7X_cjs.MastraModelGateway {
|
|
|
19904
19886
|
const data = await response.json();
|
|
19905
19887
|
const providerConfigs = {};
|
|
19906
19888
|
for (const [providerId, providerInfo] of Object.entries(data)) {
|
|
19907
|
-
if (EXCLUDED_PROVIDERS.includes(providerId)) continue;
|
|
19889
|
+
if (chunkRD2IELJM_cjs.EXCLUDED_PROVIDERS.includes(providerId)) continue;
|
|
19908
19890
|
if (!providerInfo || typeof providerInfo !== "object" || !providerInfo.models) continue;
|
|
19909
19891
|
const normalizedId = providerId;
|
|
19910
19892
|
const isOpenAICompatible = providerInfo.npm === "@ai-sdk/openai-compatible" || providerInfo.npm === "@ai-sdk/gateway" || // Vercel AI Gateway is OpenAI-compatible
|
|
19911
19893
|
normalizedId in PROVIDER_OVERRIDES;
|
|
19912
|
-
const hasInstalledPackage = PROVIDERS_WITH_INSTALLED_PACKAGES.includes(providerId);
|
|
19894
|
+
const hasInstalledPackage = chunkRD2IELJM_cjs.PROVIDERS_WITH_INSTALLED_PACKAGES.includes(providerId);
|
|
19913
19895
|
const hasApiAndEnv = providerInfo.api && providerInfo.env && providerInfo.env.length > 0;
|
|
19914
19896
|
if (isOpenAICompatible || hasInstalledPackage || hasApiAndEnv) {
|
|
19915
19897
|
const modelIds = Object.entries(providerInfo.models).filter(([, modelInfo]) => modelInfo?.status !== "deprecated").map(([modelId]) => modelId).sort();
|
|
@@ -19969,68 +19951,67 @@ var ModelsDevGateway = class extends chunkKK2U4Z7X_cjs.MastraModelGateway {
|
|
|
19969
19951
|
headers
|
|
19970
19952
|
}) {
|
|
19971
19953
|
const baseURL = this.buildUrl(`${providerId}/${modelId}`);
|
|
19954
|
+
const mastraHeaders = { "User-Agent": chunkRD2IELJM_cjs.MASTRA_USER_AGENT, ...headers };
|
|
19972
19955
|
switch (providerId) {
|
|
19973
19956
|
case "openai":
|
|
19974
|
-
return
|
|
19957
|
+
return chunkRD2IELJM_cjs.createOpenAI({ apiKey, headers: mastraHeaders }).responses(modelId);
|
|
19975
19958
|
case "gemini":
|
|
19976
19959
|
case "google":
|
|
19977
|
-
return
|
|
19978
|
-
apiKey
|
|
19979
|
-
}).chat(modelId);
|
|
19960
|
+
return chunkRD2IELJM_cjs.createGoogleGenerativeAI({ apiKey, headers: mastraHeaders }).chat(modelId);
|
|
19980
19961
|
case "anthropic":
|
|
19981
|
-
return
|
|
19962
|
+
return chunkRD2IELJM_cjs.createAnthropic({ apiKey, headers: mastraHeaders })(modelId);
|
|
19982
19963
|
case "mistral":
|
|
19983
|
-
return createMistral({ apiKey })(modelId);
|
|
19964
|
+
return createMistral({ apiKey, headers: mastraHeaders })(modelId);
|
|
19984
19965
|
case "groq":
|
|
19985
|
-
return createGroq({ apiKey })(modelId);
|
|
19966
|
+
return createGroq({ apiKey, headers: mastraHeaders })(modelId);
|
|
19986
19967
|
case "openrouter":
|
|
19987
|
-
return createOpenRouter({ apiKey, headers })(modelId);
|
|
19968
|
+
return createOpenRouter({ apiKey, headers: mastraHeaders })(modelId);
|
|
19988
19969
|
case "xai":
|
|
19989
|
-
return createXai({
|
|
19990
|
-
apiKey
|
|
19991
|
-
})(modelId);
|
|
19970
|
+
return createXai({ apiKey, headers: mastraHeaders })(modelId);
|
|
19992
19971
|
case "deepseek":
|
|
19993
|
-
return createDeepSeek({
|
|
19994
|
-
apiKey
|
|
19995
|
-
})(modelId);
|
|
19972
|
+
return createDeepSeek({ apiKey, headers: mastraHeaders })(modelId);
|
|
19996
19973
|
case "perplexity":
|
|
19997
|
-
return createPerplexity({ apiKey })(modelId);
|
|
19974
|
+
return createPerplexity({ apiKey, headers: mastraHeaders })(modelId);
|
|
19998
19975
|
case "cerebras":
|
|
19999
|
-
return createCerebras({ apiKey })(modelId);
|
|
19976
|
+
return createCerebras({ apiKey, headers: mastraHeaders })(modelId);
|
|
20000
19977
|
case "togetherai":
|
|
20001
|
-
return createTogetherAI({ apiKey })(modelId);
|
|
19978
|
+
return createTogetherAI({ apiKey, headers: mastraHeaders })(modelId);
|
|
20002
19979
|
case "deepinfra":
|
|
20003
|
-
return createDeepInfra({ apiKey })(modelId);
|
|
19980
|
+
return createDeepInfra({ apiKey, headers: mastraHeaders })(modelId);
|
|
20004
19981
|
case "vercel":
|
|
20005
|
-
return createGatewayProvider({ apiKey, headers })(modelId);
|
|
19982
|
+
return createGatewayProvider({ apiKey, headers: mastraHeaders })(modelId);
|
|
20006
19983
|
case "moonshotai":
|
|
20007
19984
|
case "moonshotai-cn": {
|
|
20008
19985
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
20009
|
-
return
|
|
19986
|
+
return chunkRD2IELJM_cjs.createAnthropic({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
20010
19987
|
}
|
|
20011
19988
|
default: {
|
|
20012
19989
|
const config = this.providerConfigs[providerId];
|
|
20013
19990
|
const npm = config?.npm;
|
|
20014
19991
|
if (npm === "@ai-sdk/anthropic") {
|
|
20015
19992
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
20016
|
-
return
|
|
19993
|
+
return chunkRD2IELJM_cjs.createAnthropic({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
20017
19994
|
}
|
|
20018
19995
|
if (npm === "@ai-sdk/openai") {
|
|
20019
19996
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
20020
|
-
return
|
|
19997
|
+
return chunkRD2IELJM_cjs.createOpenAI({ apiKey, baseURL, headers: mastraHeaders }).chat(modelId);
|
|
20021
19998
|
}
|
|
20022
19999
|
if (npm === "@ai-sdk/google") {
|
|
20023
20000
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
20024
|
-
return
|
|
20001
|
+
return chunkRD2IELJM_cjs.createGoogleGenerativeAI({ apiKey, baseURL, headers: mastraHeaders }).chat(modelId);
|
|
20025
20002
|
}
|
|
20026
20003
|
if (npm === "@ai-sdk/mistral") {
|
|
20027
20004
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
20028
|
-
return createMistral({ apiKey, baseURL })(modelId);
|
|
20005
|
+
return createMistral({ apiKey, baseURL, headers: mastraHeaders })(modelId);
|
|
20029
20006
|
}
|
|
20030
20007
|
if (!baseURL) throw new Error(`No API URL found for ${providerId}/${modelId}`);
|
|
20031
|
-
return
|
|
20032
|
-
|
|
20033
|
-
|
|
20008
|
+
return chunkRD2IELJM_cjs.createOpenAICompatible({
|
|
20009
|
+
name: providerId,
|
|
20010
|
+
apiKey,
|
|
20011
|
+
baseURL,
|
|
20012
|
+
headers: mastraHeaders,
|
|
20013
|
+
supportsStructuredOutputs: true
|
|
20014
|
+
}).chatModel(modelId);
|
|
20034
20015
|
}
|
|
20035
20016
|
}
|
|
20036
20017
|
}
|
|
@@ -20040,5 +20021,5 @@ exports.ModelsDevGateway = ModelsDevGateway;
|
|
|
20040
20021
|
exports.ToolLoopAgent = ToolLoopAgent;
|
|
20041
20022
|
exports.embed = embed;
|
|
20042
20023
|
exports.parseModelRouterId = parseModelRouterId;
|
|
20043
|
-
//# sourceMappingURL=chunk-
|
|
20044
|
-
//# sourceMappingURL=chunk-
|
|
20024
|
+
//# sourceMappingURL=chunk-BJHH5WFG.cjs.map
|
|
20025
|
+
//# sourceMappingURL=chunk-BJHH5WFG.cjs.map
|