ai 3.1.0-canary.1 → 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 +120 -75
- package/core/dist/index.d.ts +120 -75
- package/core/dist/index.js +261 -173
- package/core/dist/index.js.map +1 -1
- package/core/dist/index.mjs +261 -172
- 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 +13 -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 +795 -26126
- package/provider/dist/index.js.map +1 -1
- package/provider/dist/index.mjs +763 -7729
- 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,17 +449,16 @@ async function generateObject({
|
|
340
449
|
...settings
|
341
450
|
}) {
|
342
451
|
var _a, _b;
|
343
|
-
const
|
344
|
-
const jsonSchema = schema.getJsonSchema();
|
345
|
-
let result;
|
452
|
+
const jsonSchema = (0, import_zod_to_json_schema.default)(schema);
|
346
453
|
if (mode === "auto" || mode == null) {
|
347
454
|
mode = model.defaultObjectGenerationMode;
|
348
455
|
}
|
456
|
+
let result;
|
349
457
|
switch (mode) {
|
350
458
|
case "json": {
|
351
459
|
const generateResult = await model.doGenerate({
|
352
460
|
mode: { type: "object-json" },
|
353
|
-
...settings,
|
461
|
+
...validateCallSettings(settings),
|
354
462
|
inputFormat: getInputFormat({ prompt, messages }),
|
355
463
|
prompt: convertToLanguageModelPrompt({
|
356
464
|
system: injectJsonSchemaIntoSystem({ system, schema: jsonSchema }),
|
@@ -425,6 +533,9 @@ var GenerateObjectResult = class {
|
|
425
533
|
}
|
426
534
|
};
|
427
535
|
|
536
|
+
// core/generate-object/stream-object.ts
|
537
|
+
var import_zod_to_json_schema2 = __toESM(require("zod-to-json-schema"));
|
538
|
+
|
428
539
|
// core/util/is-deep-equal-data.ts
|
429
540
|
function isDeepEqualData(obj1, obj2) {
|
430
541
|
if (obj1 === obj2)
|
@@ -800,15 +911,14 @@ function parsePartialJson(jsonText) {
|
|
800
911
|
// core/generate-object/stream-object.ts
|
801
912
|
async function streamObject({
|
802
913
|
model,
|
803
|
-
schema
|
914
|
+
schema,
|
804
915
|
mode,
|
805
916
|
system,
|
806
917
|
prompt,
|
807
918
|
messages,
|
808
919
|
...settings
|
809
920
|
}) {
|
810
|
-
const
|
811
|
-
const jsonSchema = schema.getJsonSchema();
|
921
|
+
const jsonSchema = (0, import_zod_to_json_schema2.default)(schema);
|
812
922
|
let modelStream;
|
813
923
|
if (mode === "auto" || mode == null) {
|
814
924
|
mode = model.defaultObjectGenerationMode;
|
@@ -817,7 +927,7 @@ async function streamObject({
|
|
817
927
|
case "json": {
|
818
928
|
const { stream, warnings } = await model.doStream({
|
819
929
|
mode: { type: "object-json" },
|
820
|
-
...settings,
|
930
|
+
...validateCallSettings(settings),
|
821
931
|
inputFormat: getInputFormat({ prompt, messages }),
|
822
932
|
prompt: convertToLanguageModelPrompt({
|
823
933
|
system: injectJsonSchemaIntoSystem({ system, schema: jsonSchema }),
|
@@ -942,7 +1052,7 @@ var StreamObjectResult = class {
|
|
942
1052
|
};
|
943
1053
|
|
944
1054
|
// core/generate-text/generate-text.ts
|
945
|
-
var
|
1055
|
+
var import_zod_to_json_schema3 = __toESM(require("zod-to-json-schema"));
|
946
1056
|
|
947
1057
|
// core/generate-text/tool-call.ts
|
948
1058
|
function parseToolCall({
|
@@ -959,7 +1069,7 @@ function parseToolCall({
|
|
959
1069
|
}
|
960
1070
|
const parseResult = safeParseJSON({
|
961
1071
|
text: toolCall.args,
|
962
|
-
schema:
|
1072
|
+
schema: tool2.parameters
|
963
1073
|
});
|
964
1074
|
if (parseResult.success === false) {
|
965
1075
|
throw new Error(
|
@@ -991,10 +1101,10 @@ async function generateText({
|
|
991
1101
|
type: "function",
|
992
1102
|
name,
|
993
1103
|
description: tool2.description,
|
994
|
-
parameters: (0,
|
1104
|
+
parameters: (0, import_zod_to_json_schema3.default)(tool2.parameters)
|
995
1105
|
}))
|
996
1106
|
},
|
997
|
-
...settings,
|
1107
|
+
...validateCallSettings(settings),
|
998
1108
|
inputFormat: getInputFormat({ prompt, messages }),
|
999
1109
|
prompt: convertToLanguageModelPrompt({
|
1000
1110
|
system,
|
@@ -1048,7 +1158,7 @@ var GenerateTextResult = class {
|
|
1048
1158
|
};
|
1049
1159
|
|
1050
1160
|
// core/generate-text/stream-text.ts
|
1051
|
-
var
|
1161
|
+
var import_zod_to_json_schema4 = __toESM(require("zod-to-json-schema"));
|
1052
1162
|
|
1053
1163
|
// core/generate-text/run-tools-transformation.ts
|
1054
1164
|
var import_nanoid = require("nanoid");
|
@@ -1127,6 +1237,7 @@ function runToolsTransformation({
|
|
1127
1237
|
}
|
1128
1238
|
break;
|
1129
1239
|
}
|
1240
|
+
case "finish-metadata":
|
1130
1241
|
case "tool-call-delta": {
|
1131
1242
|
break;
|
1132
1243
|
}
|
@@ -1416,10 +1527,10 @@ async function streamText({
|
|
1416
1527
|
type: "function",
|
1417
1528
|
name,
|
1418
1529
|
description: tool2.description,
|
1419
|
-
parameters: (0,
|
1530
|
+
parameters: (0, import_zod_to_json_schema4.default)(tool2.parameters)
|
1420
1531
|
}))
|
1421
1532
|
},
|
1422
|
-
...settings,
|
1533
|
+
...validateCallSettings(settings),
|
1423
1534
|
inputFormat: getInputFormat({ prompt, messages }),
|
1424
1535
|
prompt: convertToLanguageModelPrompt({
|
1425
1536
|
system,
|
@@ -1451,6 +1562,9 @@ var StreamTextResult = class {
|
|
1451
1562
|
return { value: value.textDelta, done: false };
|
1452
1563
|
}
|
1453
1564
|
}
|
1565
|
+
if (value.type === "error") {
|
1566
|
+
console.error("Error:", value.error);
|
1567
|
+
}
|
1454
1568
|
}
|
1455
1569
|
}
|
1456
1570
|
};
|
@@ -1488,31 +1602,6 @@ var StreamTextResult = class {
|
|
1488
1602
|
function tool(tool2) {
|
1489
1603
|
return tool2;
|
1490
1604
|
}
|
1491
|
-
|
1492
|
-
// core/language-model/errors/unsupported-functionality-error.ts
|
1493
|
-
var UnsupportedFunctionalityError = class extends Error {
|
1494
|
-
constructor({
|
1495
|
-
provider,
|
1496
|
-
functionality
|
1497
|
-
}) {
|
1498
|
-
super(
|
1499
|
-
`Functionality not supported by the provider. Provider: ${provider}.
|
1500
|
-
Functionality: ${functionality}`
|
1501
|
-
);
|
1502
|
-
this.name = "UnsupportedFunctionalityError";
|
1503
|
-
this.provider = provider;
|
1504
|
-
this.functionality = functionality;
|
1505
|
-
}
|
1506
|
-
toJSON() {
|
1507
|
-
return {
|
1508
|
-
name: this.name,
|
1509
|
-
message: this.message,
|
1510
|
-
stack: this.stack,
|
1511
|
-
provider: this.provider,
|
1512
|
-
functionality: this.functionality
|
1513
|
-
};
|
1514
|
-
}
|
1515
|
-
};
|
1516
1605
|
// Annotate the CommonJS export names for ESM import in node:
|
1517
1606
|
0 && (module.exports = {
|
1518
1607
|
GenerateObjectResult,
|
@@ -1520,7 +1609,6 @@ Functionality: ${functionality}`
|
|
1520
1609
|
StreamObjectResult,
|
1521
1610
|
StreamTextHttpResponse,
|
1522
1611
|
StreamTextResult,
|
1523
|
-
UnsupportedFunctionalityError,
|
1524
1612
|
convertDataContentToBase64String,
|
1525
1613
|
convertDataContentToUint8Array,
|
1526
1614
|
generateObject,
|