ai 3.1.0-canary.0 → 3.1.0-canary.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/ai-model-specification/dist/index.d.mts +539 -0
- package/ai-model-specification/dist/index.d.ts +539 -0
- package/ai-model-specification/dist/index.js +581 -0
- package/ai-model-specification/dist/index.js.map +1 -0
- package/ai-model-specification/dist/index.mjs +526 -0
- package/ai-model-specification/dist/index.mjs.map +1 -0
- package/core/dist/index.d.mts +122 -77
- package/core/dist/index.d.ts +122 -77
- package/core/dist/index.js +266 -174
- package/core/dist/index.js.map +1 -1
- package/core/dist/index.mjs +266 -173
- package/core/dist/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -4
- package/prompts/dist/index.d.mts +32 -19
- package/prompts/dist/index.d.ts +32 -19
- package/prompts/dist/index.js +0 -1
- package/prompts/dist/index.js.map +1 -1
- package/prompts/dist/index.mjs +0 -1
- package/prompts/dist/index.mjs.map +1 -1
- package/provider/dist/index.d.mts +154 -191
- package/provider/dist/index.d.ts +154 -191
- package/provider/dist/index.js +800 -26131
- package/provider/dist/index.js.map +1 -1
- package/provider/dist/index.mjs +770 -7736
- package/provider/dist/index.mjs.map +1 -1
- package/react/dist/index.js +16 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +16 -1
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +11 -0
- package/rsc/dist/rsc-server.d.mts +11 -0
- package/rsc/dist/rsc-server.mjs +21 -21
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs +21 -1
- package/rsc/dist/rsc-shared.mjs.map +1 -1
- package/provider/dist/chunk-3DTRVHCT.mjs +0 -5046
- package/provider/dist/chunk-3DTRVHCT.mjs.map +0 -1
- package/provider/dist/chunk-4OUDS3CP.mjs +0 -30
- package/provider/dist/chunk-4OUDS3CP.mjs.map +0 -1
- package/provider/dist/chunk-5IYCPJBV.mjs +0 -56
- package/provider/dist/chunk-5IYCPJBV.mjs.map +0 -1
- package/provider/dist/chunk-VB2TCVQ4.mjs +0 -6746
- package/provider/dist/chunk-VB2TCVQ4.mjs.map +0 -1
- package/provider/dist/chunk-VYIXVZ6L.mjs +0 -317
- package/provider/dist/chunk-VYIXVZ6L.mjs.map +0 -1
- package/provider/dist/chunk-WTOUHN6A.mjs +0 -2251
- package/provider/dist/chunk-WTOUHN6A.mjs.map +0 -1
- package/provider/dist/client-22WAAXR7.mjs +0 -10
- package/provider/dist/client-22WAAXR7.mjs.map +0 -1
- package/provider/dist/fileFromPath-23RINPB2.mjs +0 -115
- package/provider/dist/fileFromPath-23RINPB2.mjs.map +0 -1
- package/provider/dist/lib-BZMMM4HX.mjs +0 -20
- package/provider/dist/lib-BZMMM4HX.mjs.map +0 -1
- package/provider/dist/openai-3YL4AWLI.mjs +0 -3451
- package/provider/dist/openai-3YL4AWLI.mjs.map +0 -1
package/core/dist/index.js
CHANGED
@@ -35,7 +35,6 @@ __export(core_exports, {
|
|
35
35
|
StreamObjectResult: () => StreamObjectResult,
|
36
36
|
StreamTextHttpResponse: () => StreamTextHttpResponse,
|
37
37
|
StreamTextResult: () => StreamTextResult,
|
38
|
-
UnsupportedFunctionalityError: () => UnsupportedFunctionalityError,
|
39
38
|
convertDataContentToBase64String: () => convertDataContentToBase64String,
|
40
39
|
convertDataContentToUint8Array: () => convertDataContentToUint8Array,
|
41
40
|
generateObject: () => generateObject,
|
@@ -46,7 +45,162 @@ __export(core_exports, {
|
|
46
45
|
});
|
47
46
|
module.exports = __toCommonJS(core_exports);
|
48
47
|
|
49
|
-
// core/
|
48
|
+
// core/generate-object/generate-object.ts
|
49
|
+
var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
|
50
|
+
|
51
|
+
// ai-model-specification/errors/ai-invalid-argument-error.ts
|
52
|
+
var AI_InvalidArgumentError = class extends Error {
|
53
|
+
// readonly learnMore =
|
54
|
+
// 'https://sdk.vercel.com/docs/ai/errors/ai_invalid_argument_error';
|
55
|
+
constructor({
|
56
|
+
parameter,
|
57
|
+
value,
|
58
|
+
message
|
59
|
+
}) {
|
60
|
+
super(`Invalid argument for parameter ${parameter}: ${message}`);
|
61
|
+
this.name = "AI_InvalidArgumentError";
|
62
|
+
this.parameter = parameter;
|
63
|
+
this.value = value;
|
64
|
+
}
|
65
|
+
toJSON() {
|
66
|
+
return {
|
67
|
+
name: this.name,
|
68
|
+
message: this.message,
|
69
|
+
stack: this.stack,
|
70
|
+
parameter: this.parameter,
|
71
|
+
value: this.value
|
72
|
+
};
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
// ai-model-specification/util/get-error-message.ts
|
77
|
+
function getErrorMessage(error) {
|
78
|
+
if (error == null) {
|
79
|
+
return "unknown error";
|
80
|
+
}
|
81
|
+
if (typeof error === "string") {
|
82
|
+
return error;
|
83
|
+
}
|
84
|
+
if (error instanceof Error) {
|
85
|
+
return error.message;
|
86
|
+
}
|
87
|
+
return JSON.stringify(error);
|
88
|
+
}
|
89
|
+
|
90
|
+
// ai-model-specification/errors/json-parse-error.ts
|
91
|
+
var JSONParseError = class extends Error {
|
92
|
+
constructor({ text, cause }) {
|
93
|
+
super(
|
94
|
+
`JSON parsing failed: Text: ${text}.
|
95
|
+
Error message: ${getErrorMessage(cause)}`
|
96
|
+
);
|
97
|
+
this.name = "JSONParseError";
|
98
|
+
this.cause = cause;
|
99
|
+
this.text = text;
|
100
|
+
}
|
101
|
+
toJSON() {
|
102
|
+
return {
|
103
|
+
name: this.name,
|
104
|
+
message: this.message,
|
105
|
+
cause: this.cause,
|
106
|
+
stack: this.stack,
|
107
|
+
valueText: this.text
|
108
|
+
};
|
109
|
+
}
|
110
|
+
};
|
111
|
+
|
112
|
+
// ai-model-specification/errors/no-object-generated-error.ts
|
113
|
+
var NoTextGeneratedError = class extends Error {
|
114
|
+
constructor() {
|
115
|
+
super(`No text generated.`);
|
116
|
+
this.name = "NoTextGeneratedError";
|
117
|
+
}
|
118
|
+
toJSON() {
|
119
|
+
return {
|
120
|
+
name: this.name,
|
121
|
+
cause: this.cause,
|
122
|
+
message: this.message,
|
123
|
+
stack: this.stack
|
124
|
+
};
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
// ai-model-specification/errors/type-validation-error.ts
|
129
|
+
var TypeValidationError = class extends Error {
|
130
|
+
constructor({ value, cause }) {
|
131
|
+
super(
|
132
|
+
`Type validation failed: Value: ${JSON.stringify(value)}.
|
133
|
+
Error message: ${getErrorMessage(cause)}`
|
134
|
+
);
|
135
|
+
this.name = "TypeValidationError";
|
136
|
+
this.cause = cause;
|
137
|
+
this.value = value;
|
138
|
+
}
|
139
|
+
toJSON() {
|
140
|
+
return {
|
141
|
+
name: this.name,
|
142
|
+
message: this.message,
|
143
|
+
cause: this.cause,
|
144
|
+
stack: this.stack,
|
145
|
+
value: this.value
|
146
|
+
};
|
147
|
+
}
|
148
|
+
};
|
149
|
+
|
150
|
+
// ai-model-specification/util/parse-json.ts
|
151
|
+
var import_secure_json_parse = __toESM(require("secure-json-parse"));
|
152
|
+
|
153
|
+
// ai-model-specification/util/validate-types.ts
|
154
|
+
function safeValidateTypes({
|
155
|
+
value,
|
156
|
+
schema
|
157
|
+
}) {
|
158
|
+
try {
|
159
|
+
const validationResult = schema.safeParse(value);
|
160
|
+
if (validationResult.success) {
|
161
|
+
return {
|
162
|
+
success: true,
|
163
|
+
value: validationResult.data
|
164
|
+
};
|
165
|
+
}
|
166
|
+
return {
|
167
|
+
success: false,
|
168
|
+
error: new TypeValidationError({
|
169
|
+
value,
|
170
|
+
cause: validationResult.error
|
171
|
+
})
|
172
|
+
};
|
173
|
+
} catch (error) {
|
174
|
+
return {
|
175
|
+
success: false,
|
176
|
+
error: error instanceof TypeValidationError ? error : new TypeValidationError({ value, cause: error })
|
177
|
+
};
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
// ai-model-specification/util/parse-json.ts
|
182
|
+
function safeParseJSON({
|
183
|
+
text,
|
184
|
+
schema
|
185
|
+
}) {
|
186
|
+
try {
|
187
|
+
const value = import_secure_json_parse.default.parse(text);
|
188
|
+
if (schema == null) {
|
189
|
+
return {
|
190
|
+
success: true,
|
191
|
+
value
|
192
|
+
};
|
193
|
+
}
|
194
|
+
return safeValidateTypes({ value, schema });
|
195
|
+
} catch (error) {
|
196
|
+
return {
|
197
|
+
success: false,
|
198
|
+
error: error instanceof JSONParseError ? error : new JSONParseError({ text, cause: error })
|
199
|
+
};
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
// ai-model-specification/util/uint8-utils.ts
|
50
204
|
function convertBase64ToUint8Array(base64String) {
|
51
205
|
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
52
206
|
const latin1string = globalThis.atob(base64Url);
|
@@ -171,129 +325,100 @@ function getInputFormat({
|
|
171
325
|
return prompt != null ? "prompt" : "messages";
|
172
326
|
}
|
173
327
|
|
174
|
-
// core/
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
// core/language-model/errors/json-parse-error.ts
|
192
|
-
var JSONParseError = class extends Error {
|
193
|
-
constructor({ text, cause }) {
|
194
|
-
super(
|
195
|
-
`JSON parsing failed: Text: ${text}.
|
196
|
-
Error message: ${getErrorMessage(cause)}`
|
197
|
-
);
|
198
|
-
this.name = "JSONParseError";
|
199
|
-
this.cause = cause;
|
200
|
-
this.text = text;
|
328
|
+
// core/prompt/validate-call-settings.ts
|
329
|
+
function validateCallSettings(settings) {
|
330
|
+
if (settings.maxTokens != null) {
|
331
|
+
if (!Number.isInteger(settings.maxTokens)) {
|
332
|
+
throw new AI_InvalidArgumentError({
|
333
|
+
parameter: "maxTokens",
|
334
|
+
value: settings.maxTokens,
|
335
|
+
message: "maxTokens must be an integer"
|
336
|
+
});
|
337
|
+
}
|
338
|
+
if (settings.maxTokens < 1) {
|
339
|
+
throw new AI_InvalidArgumentError({
|
340
|
+
parameter: "maxTokens",
|
341
|
+
value: settings.maxTokens,
|
342
|
+
message: "maxTokens must be >= 1"
|
343
|
+
});
|
344
|
+
}
|
201
345
|
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
}
|
346
|
+
if (settings.temperature != null) {
|
347
|
+
if (typeof settings.temperature !== "number") {
|
348
|
+
throw new AI_InvalidArgumentError({
|
349
|
+
parameter: "temperature",
|
350
|
+
value: settings.temperature,
|
351
|
+
message: "temperature must be a number"
|
352
|
+
});
|
353
|
+
}
|
354
|
+
if (settings.temperature < 0 || settings.temperature > 1) {
|
355
|
+
throw new AI_InvalidArgumentError({
|
356
|
+
parameter: "temperature",
|
357
|
+
value: settings.temperature,
|
358
|
+
message: "temperature must be between 0 and 1 (inclusive)"
|
359
|
+
});
|
360
|
+
}
|
210
361
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
)
|
220
|
-
|
221
|
-
|
222
|
-
|
362
|
+
if (settings.topP != null) {
|
363
|
+
if (typeof settings.topP !== "number") {
|
364
|
+
throw new AI_InvalidArgumentError({
|
365
|
+
parameter: "topP",
|
366
|
+
value: settings.topP,
|
367
|
+
message: "topP must be a number"
|
368
|
+
});
|
369
|
+
}
|
370
|
+
if (settings.topP < 0 || settings.topP > 1) {
|
371
|
+
throw new AI_InvalidArgumentError({
|
372
|
+
parameter: "topP",
|
373
|
+
value: settings.topP,
|
374
|
+
message: "topP must be between 0 and 1 (inclusive)"
|
375
|
+
});
|
376
|
+
}
|
223
377
|
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
}
|
378
|
+
if (settings.presencePenalty != null) {
|
379
|
+
if (typeof settings.presencePenalty !== "number") {
|
380
|
+
throw new AI_InvalidArgumentError({
|
381
|
+
parameter: "presencePenalty",
|
382
|
+
value: settings.presencePenalty,
|
383
|
+
message: "presencePenalty must be a number"
|
384
|
+
});
|
385
|
+
}
|
386
|
+
if (settings.presencePenalty < -1 || settings.presencePenalty > 1) {
|
387
|
+
throw new AI_InvalidArgumentError({
|
388
|
+
parameter: "presencePenalty",
|
389
|
+
value: settings.presencePenalty,
|
390
|
+
message: "presencePenalty must be between -1 and 1 (inclusive)"
|
391
|
+
});
|
392
|
+
}
|
232
393
|
}
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
})
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
394
|
+
if (settings.frequencyPenalty != null) {
|
395
|
+
if (typeof settings.frequencyPenalty !== "number") {
|
396
|
+
throw new AI_InvalidArgumentError({
|
397
|
+
parameter: "frequencyPenalty",
|
398
|
+
value: settings.frequencyPenalty,
|
399
|
+
message: "frequencyPenalty must be a number"
|
400
|
+
});
|
401
|
+
}
|
402
|
+
if (settings.frequencyPenalty < -1 || settings.frequencyPenalty > 1) {
|
403
|
+
throw new AI_InvalidArgumentError({
|
404
|
+
parameter: "frequencyPenalty",
|
405
|
+
value: settings.frequencyPenalty,
|
406
|
+
message: "frequencyPenalty must be between -1 and 1 (inclusive)"
|
407
|
+
});
|
244
408
|
}
|
245
|
-
return {
|
246
|
-
success: false,
|
247
|
-
error: new TypeValidationError({
|
248
|
-
value,
|
249
|
-
cause: validationResult.error
|
250
|
-
})
|
251
|
-
};
|
252
|
-
} catch (error) {
|
253
|
-
return {
|
254
|
-
success: false,
|
255
|
-
error: error instanceof TypeValidationError ? error : new TypeValidationError({ value, cause: error })
|
256
|
-
};
|
257
409
|
}
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
})
|
265
|
-
try {
|
266
|
-
const value = import_secure_json_parse.default.parse(text);
|
267
|
-
if (schema == null) {
|
268
|
-
return {
|
269
|
-
success: true,
|
270
|
-
value
|
271
|
-
};
|
410
|
+
if (settings.seed != null) {
|
411
|
+
if (!Number.isInteger(settings.seed)) {
|
412
|
+
throw new AI_InvalidArgumentError({
|
413
|
+
parameter: "seed",
|
414
|
+
value: settings.seed,
|
415
|
+
message: "seed must be an integer"
|
416
|
+
});
|
272
417
|
}
|
273
|
-
return safeValidateTypes({ value, schema });
|
274
|
-
} catch (error) {
|
275
|
-
return {
|
276
|
-
success: false,
|
277
|
-
error: error instanceof JSONParseError ? error : new JSONParseError({ text, cause: error })
|
278
|
-
};
|
279
418
|
}
|
419
|
+
return settings;
|
280
420
|
}
|
281
421
|
|
282
|
-
// core/schema/zod-schema.ts
|
283
|
-
var import_zod_to_json_schema = require("zod-to-json-schema");
|
284
|
-
var ZodSchema = class {
|
285
|
-
constructor(zodSchema) {
|
286
|
-
this.zodSchema = zodSchema;
|
287
|
-
}
|
288
|
-
validate(value) {
|
289
|
-
const result = this.zodSchema.safeParse(value);
|
290
|
-
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
291
|
-
}
|
292
|
-
getJsonSchema() {
|
293
|
-
return (0, import_zod_to_json_schema.zodToJsonSchema)(this.zodSchema);
|
294
|
-
}
|
295
|
-
};
|
296
|
-
|
297
422
|
// core/generate-object/inject-json-schema-into-system.ts
|
298
423
|
var DEFAULT_SCHEMA_PREFIX = "JSON schema:";
|
299
424
|
var DEFAULT_SCHEMA_SUFFIX = "You MUST answer with a JSON object that matches the JSON schema above.";
|
@@ -313,26 +438,10 @@ function injectJsonSchemaIntoSystem({
|
|
313
438
|
].filter((line) => line != null).join("\n");
|
314
439
|
}
|
315
440
|
|
316
|
-
// core/language-model/errors/no-object-generated-error.ts
|
317
|
-
var NoTextGeneratedError = class extends Error {
|
318
|
-
constructor() {
|
319
|
-
super(`No text generated.`);
|
320
|
-
this.name = "NoTextGeneratedError";
|
321
|
-
}
|
322
|
-
toJSON() {
|
323
|
-
return {
|
324
|
-
name: this.name,
|
325
|
-
cause: this.cause,
|
326
|
-
message: this.message,
|
327
|
-
stack: this.stack
|
328
|
-
};
|
329
|
-
}
|
330
|
-
};
|
331
|
-
|
332
441
|
// core/generate-object/generate-object.ts
|
333
442
|
async function generateObject({
|
334
443
|
model,
|
335
|
-
schema
|
444
|
+
schema,
|
336
445
|
mode,
|
337
446
|
system,
|
338
447
|
prompt,
|
@@ -340,15 +449,16 @@ async function generateObject({
|
|
340
449
|
...settings
|
341
450
|
}) {
|
342
451
|
var _a, _b;
|
343
|
-
const
|
344
|
-
|
452
|
+
const jsonSchema = (0, import_zod_to_json_schema.default)(schema);
|
453
|
+
if (mode === "auto" || mode == null) {
|
454
|
+
mode = model.defaultObjectGenerationMode;
|
455
|
+
}
|
345
456
|
let result;
|
346
|
-
mode = mode != null ? mode : model.defaultObjectGenerationMode;
|
347
457
|
switch (mode) {
|
348
458
|
case "json": {
|
349
459
|
const generateResult = await model.doGenerate({
|
350
460
|
mode: { type: "object-json" },
|
351
|
-
...settings,
|
461
|
+
...validateCallSettings(settings),
|
352
462
|
inputFormat: getInputFormat({ prompt, messages }),
|
353
463
|
prompt: convertToLanguageModelPrompt({
|
354
464
|
system: injectJsonSchemaIntoSystem({ system, schema: jsonSchema }),
|
@@ -423,6 +533,9 @@ var GenerateObjectResult = class {
|
|
423
533
|
}
|
424
534
|
};
|
425
535
|
|
536
|
+
// core/generate-object/stream-object.ts
|
537
|
+
var import_zod_to_json_schema2 = __toESM(require("zod-to-json-schema"));
|
538
|
+
|
426
539
|
// core/util/is-deep-equal-data.ts
|
427
540
|
function isDeepEqualData(obj1, obj2) {
|
428
541
|
if (obj1 === obj2)
|
@@ -798,22 +911,23 @@ function parsePartialJson(jsonText) {
|
|
798
911
|
// core/generate-object/stream-object.ts
|
799
912
|
async function streamObject({
|
800
913
|
model,
|
801
|
-
schema
|
914
|
+
schema,
|
802
915
|
mode,
|
803
916
|
system,
|
804
917
|
prompt,
|
805
918
|
messages,
|
806
919
|
...settings
|
807
920
|
}) {
|
808
|
-
const
|
809
|
-
const jsonSchema = schema.getJsonSchema();
|
921
|
+
const jsonSchema = (0, import_zod_to_json_schema2.default)(schema);
|
810
922
|
let modelStream;
|
811
|
-
|
923
|
+
if (mode === "auto" || mode == null) {
|
924
|
+
mode = model.defaultObjectGenerationMode;
|
925
|
+
}
|
812
926
|
switch (mode) {
|
813
927
|
case "json": {
|
814
928
|
const { stream, warnings } = await model.doStream({
|
815
929
|
mode: { type: "object-json" },
|
816
|
-
...settings,
|
930
|
+
...validateCallSettings(settings),
|
817
931
|
inputFormat: getInputFormat({ prompt, messages }),
|
818
932
|
prompt: convertToLanguageModelPrompt({
|
819
933
|
system: injectJsonSchemaIntoSystem({ system, schema: jsonSchema }),
|
@@ -938,7 +1052,7 @@ var StreamObjectResult = class {
|
|
938
1052
|
};
|
939
1053
|
|
940
1054
|
// core/generate-text/generate-text.ts
|
941
|
-
var
|
1055
|
+
var import_zod_to_json_schema3 = __toESM(require("zod-to-json-schema"));
|
942
1056
|
|
943
1057
|
// core/generate-text/tool-call.ts
|
944
1058
|
function parseToolCall({
|
@@ -955,7 +1069,7 @@ function parseToolCall({
|
|
955
1069
|
}
|
956
1070
|
const parseResult = safeParseJSON({
|
957
1071
|
text: toolCall.args,
|
958
|
-
schema:
|
1072
|
+
schema: tool2.parameters
|
959
1073
|
});
|
960
1074
|
if (parseResult.success === false) {
|
961
1075
|
throw new Error(
|
@@ -987,10 +1101,10 @@ async function generateText({
|
|
987
1101
|
type: "function",
|
988
1102
|
name,
|
989
1103
|
description: tool2.description,
|
990
|
-
parameters: (0,
|
1104
|
+
parameters: (0, import_zod_to_json_schema3.default)(tool2.parameters)
|
991
1105
|
}))
|
992
1106
|
},
|
993
|
-
...settings,
|
1107
|
+
...validateCallSettings(settings),
|
994
1108
|
inputFormat: getInputFormat({ prompt, messages }),
|
995
1109
|
prompt: convertToLanguageModelPrompt({
|
996
1110
|
system,
|
@@ -1044,7 +1158,7 @@ var GenerateTextResult = class {
|
|
1044
1158
|
};
|
1045
1159
|
|
1046
1160
|
// core/generate-text/stream-text.ts
|
1047
|
-
var
|
1161
|
+
var import_zod_to_json_schema4 = __toESM(require("zod-to-json-schema"));
|
1048
1162
|
|
1049
1163
|
// core/generate-text/run-tools-transformation.ts
|
1050
1164
|
var import_nanoid = require("nanoid");
|
@@ -1123,6 +1237,7 @@ function runToolsTransformation({
|
|
1123
1237
|
}
|
1124
1238
|
break;
|
1125
1239
|
}
|
1240
|
+
case "finish-metadata":
|
1126
1241
|
case "tool-call-delta": {
|
1127
1242
|
break;
|
1128
1243
|
}
|
@@ -1412,10 +1527,10 @@ async function streamText({
|
|
1412
1527
|
type: "function",
|
1413
1528
|
name,
|
1414
1529
|
description: tool2.description,
|
1415
|
-
parameters: (0,
|
1530
|
+
parameters: (0, import_zod_to_json_schema4.default)(tool2.parameters)
|
1416
1531
|
}))
|
1417
1532
|
},
|
1418
|
-
...settings,
|
1533
|
+
...validateCallSettings(settings),
|
1419
1534
|
inputFormat: getInputFormat({ prompt, messages }),
|
1420
1535
|
prompt: convertToLanguageModelPrompt({
|
1421
1536
|
system,
|
@@ -1447,6 +1562,9 @@ var StreamTextResult = class {
|
|
1447
1562
|
return { value: value.textDelta, done: false };
|
1448
1563
|
}
|
1449
1564
|
}
|
1565
|
+
if (value.type === "error") {
|
1566
|
+
console.error("Error:", value.error);
|
1567
|
+
}
|
1450
1568
|
}
|
1451
1569
|
}
|
1452
1570
|
};
|
@@ -1484,31 +1602,6 @@ var StreamTextResult = class {
|
|
1484
1602
|
function tool(tool2) {
|
1485
1603
|
return tool2;
|
1486
1604
|
}
|
1487
|
-
|
1488
|
-
// core/language-model/errors/unsupported-functionality-error.ts
|
1489
|
-
var UnsupportedFunctionalityError = class extends Error {
|
1490
|
-
constructor({
|
1491
|
-
provider,
|
1492
|
-
functionality
|
1493
|
-
}) {
|
1494
|
-
super(
|
1495
|
-
`Functionality not supported by the provider. Provider: ${provider}.
|
1496
|
-
Functionality: ${functionality}`
|
1497
|
-
);
|
1498
|
-
this.name = "UnsupportedFunctionalityError";
|
1499
|
-
this.provider = provider;
|
1500
|
-
this.functionality = functionality;
|
1501
|
-
}
|
1502
|
-
toJSON() {
|
1503
|
-
return {
|
1504
|
-
name: this.name,
|
1505
|
-
message: this.message,
|
1506
|
-
stack: this.stack,
|
1507
|
-
provider: this.provider,
|
1508
|
-
functionality: this.functionality
|
1509
|
-
};
|
1510
|
-
}
|
1511
|
-
};
|
1512
1605
|
// Annotate the CommonJS export names for ESM import in node:
|
1513
1606
|
0 && (module.exports = {
|
1514
1607
|
GenerateObjectResult,
|
@@ -1516,7 +1609,6 @@ Functionality: ${functionality}`
|
|
1516
1609
|
StreamObjectResult,
|
1517
1610
|
StreamTextHttpResponse,
|
1518
1611
|
StreamTextResult,
|
1519
|
-
UnsupportedFunctionalityError,
|
1520
1612
|
convertDataContentToBase64String,
|
1521
1613
|
convertDataContentToUint8Array,
|
1522
1614
|
generateObject,
|