ai 4.0.24 → 4.0.25
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 +6 -0
- package/dist/index.js +104 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -109
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -3243,40 +3243,17 @@ var DefaultStreamObjectResult = class {
|
|
3243
3243
|
// core/generate-text/generate-text.ts
|
3244
3244
|
import { createIdGenerator as createIdGenerator3 } from "@ai-sdk/provider-utils";
|
3245
3245
|
|
3246
|
-
// errors/
|
3247
|
-
import {
|
3248
|
-
|
3249
|
-
APICallError as APICallError2,
|
3250
|
-
EmptyResponseBodyError,
|
3251
|
-
InvalidPromptError as InvalidPromptError2,
|
3252
|
-
InvalidResponseDataError,
|
3253
|
-
JSONParseError,
|
3254
|
-
LoadAPIKeyError,
|
3255
|
-
NoContentGeneratedError,
|
3256
|
-
NoSuchModelError,
|
3257
|
-
TypeValidationError as TypeValidationError2,
|
3258
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
3259
|
-
} from "@ai-sdk/provider";
|
3260
|
-
|
3261
|
-
// errors/invalid-tool-arguments-error.ts
|
3262
|
-
import { AISDKError as AISDKError8, getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider";
|
3263
|
-
var name8 = "AI_InvalidToolArgumentsError";
|
3246
|
+
// errors/no-output-specified-error.ts
|
3247
|
+
import { AISDKError as AISDKError8 } from "@ai-sdk/provider";
|
3248
|
+
var name8 = "AI_NoOutputSpecifiedError";
|
3264
3249
|
var marker8 = `vercel.ai.error.${name8}`;
|
3265
3250
|
var symbol8 = Symbol.for(marker8);
|
3266
3251
|
var _a8;
|
3267
|
-
var
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
cause,
|
3272
|
-
message = `Invalid arguments for tool ${toolName}: ${getErrorMessage2(
|
3273
|
-
cause
|
3274
|
-
)}`
|
3275
|
-
}) {
|
3276
|
-
super({ name: name8, message, cause });
|
3252
|
+
var NoOutputSpecifiedError = class extends AISDKError8 {
|
3253
|
+
// used in isInstance
|
3254
|
+
constructor({ message = "No output specified." } = {}) {
|
3255
|
+
super({ name: name8, message });
|
3277
3256
|
this[_a8] = true;
|
3278
|
-
this.toolArgs = toolArgs;
|
3279
|
-
this.toolName = toolName;
|
3280
3257
|
}
|
3281
3258
|
static isInstance(error) {
|
3282
3259
|
return AISDKError8.hasMarker(error, marker8);
|
@@ -3284,92 +3261,29 @@ var InvalidToolArgumentsError = class extends AISDKError8 {
|
|
3284
3261
|
};
|
3285
3262
|
_a8 = symbol8;
|
3286
3263
|
|
3287
|
-
// errors/
|
3288
|
-
import { AISDKError as AISDKError9 } from "@ai-sdk/provider";
|
3289
|
-
var name9 = "
|
3264
|
+
// errors/tool-execution-error.ts
|
3265
|
+
import { AISDKError as AISDKError9, getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider";
|
3266
|
+
var name9 = "AI_ToolExecutionError";
|
3290
3267
|
var marker9 = `vercel.ai.error.${name9}`;
|
3291
3268
|
var symbol9 = Symbol.for(marker9);
|
3292
3269
|
var _a9;
|
3293
|
-
var
|
3294
|
-
// used in isInstance
|
3295
|
-
constructor({ message = "No output specified." } = {}) {
|
3296
|
-
super({ name: name9, message });
|
3297
|
-
this[_a9] = true;
|
3298
|
-
}
|
3299
|
-
static isInstance(error) {
|
3300
|
-
return AISDKError9.hasMarker(error, marker9);
|
3301
|
-
}
|
3302
|
-
};
|
3303
|
-
_a9 = symbol9;
|
3304
|
-
|
3305
|
-
// errors/no-such-tool-error.ts
|
3306
|
-
import { AISDKError as AISDKError10 } from "@ai-sdk/provider";
|
3307
|
-
var name10 = "AI_NoSuchToolError";
|
3308
|
-
var marker10 = `vercel.ai.error.${name10}`;
|
3309
|
-
var symbol10 = Symbol.for(marker10);
|
3310
|
-
var _a10;
|
3311
|
-
var NoSuchToolError = class extends AISDKError10 {
|
3312
|
-
constructor({
|
3313
|
-
toolName,
|
3314
|
-
availableTools = void 0,
|
3315
|
-
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
3316
|
-
}) {
|
3317
|
-
super({ name: name10, message });
|
3318
|
-
this[_a10] = true;
|
3319
|
-
this.toolName = toolName;
|
3320
|
-
this.availableTools = availableTools;
|
3321
|
-
}
|
3322
|
-
static isInstance(error) {
|
3323
|
-
return AISDKError10.hasMarker(error, marker10);
|
3324
|
-
}
|
3325
|
-
};
|
3326
|
-
_a10 = symbol10;
|
3327
|
-
|
3328
|
-
// errors/tool-call-repair-error.ts
|
3329
|
-
import { AISDKError as AISDKError11, getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
|
3330
|
-
var name11 = "AI_ToolCallRepairError";
|
3331
|
-
var marker11 = `vercel.ai.error.${name11}`;
|
3332
|
-
var symbol11 = Symbol.for(marker11);
|
3333
|
-
var _a11;
|
3334
|
-
var ToolCallRepairError = class extends AISDKError11 {
|
3335
|
-
constructor({
|
3336
|
-
cause,
|
3337
|
-
originalError,
|
3338
|
-
message = `Error repairing tool call: ${getErrorMessage3(cause)}`
|
3339
|
-
}) {
|
3340
|
-
super({ name: name11, message, cause });
|
3341
|
-
this[_a11] = true;
|
3342
|
-
this.originalError = originalError;
|
3343
|
-
}
|
3344
|
-
static isInstance(error) {
|
3345
|
-
return AISDKError11.hasMarker(error, marker11);
|
3346
|
-
}
|
3347
|
-
};
|
3348
|
-
_a11 = symbol11;
|
3349
|
-
|
3350
|
-
// errors/tool-execution-error.ts
|
3351
|
-
import { AISDKError as AISDKError12, getErrorMessage as getErrorMessage4 } from "@ai-sdk/provider";
|
3352
|
-
var name12 = "AI_ToolExecutionError";
|
3353
|
-
var marker12 = `vercel.ai.error.${name12}`;
|
3354
|
-
var symbol12 = Symbol.for(marker12);
|
3355
|
-
var _a12;
|
3356
|
-
var ToolExecutionError = class extends AISDKError12 {
|
3270
|
+
var ToolExecutionError = class extends AISDKError9 {
|
3357
3271
|
constructor({
|
3358
3272
|
toolArgs,
|
3359
3273
|
toolName,
|
3360
3274
|
cause,
|
3361
|
-
message = `Error executing tool ${toolName}: ${
|
3275
|
+
message = `Error executing tool ${toolName}: ${getErrorMessage2(cause)}`
|
3362
3276
|
}) {
|
3363
|
-
super({ name:
|
3364
|
-
this[
|
3277
|
+
super({ name: name9, message, cause });
|
3278
|
+
this[_a9] = true;
|
3365
3279
|
this.toolArgs = toolArgs;
|
3366
3280
|
this.toolName = toolName;
|
3367
3281
|
}
|
3368
3282
|
static isInstance(error) {
|
3369
|
-
return
|
3283
|
+
return AISDKError9.hasMarker(error, marker9);
|
3370
3284
|
}
|
3371
3285
|
};
|
3372
|
-
|
3286
|
+
_a9 = symbol9;
|
3373
3287
|
|
3374
3288
|
// core/prompt/prepare-tools-and-tool-choice.ts
|
3375
3289
|
import { asSchema as asSchema2 } from "@ai-sdk/ui-utils";
|
@@ -3439,6 +3353,79 @@ function removeTextAfterLastWhitespace(text2) {
|
|
3439
3353
|
// core/generate-text/parse-tool-call.ts
|
3440
3354
|
import { safeParseJSON as safeParseJSON2, safeValidateTypes as safeValidateTypes3 } from "@ai-sdk/provider-utils";
|
3441
3355
|
import { asSchema as asSchema3 } from "@ai-sdk/ui-utils";
|
3356
|
+
|
3357
|
+
// errors/invalid-tool-arguments-error.ts
|
3358
|
+
import { AISDKError as AISDKError10, getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
|
3359
|
+
var name10 = "AI_InvalidToolArgumentsError";
|
3360
|
+
var marker10 = `vercel.ai.error.${name10}`;
|
3361
|
+
var symbol10 = Symbol.for(marker10);
|
3362
|
+
var _a10;
|
3363
|
+
var InvalidToolArgumentsError = class extends AISDKError10 {
|
3364
|
+
constructor({
|
3365
|
+
toolArgs,
|
3366
|
+
toolName,
|
3367
|
+
cause,
|
3368
|
+
message = `Invalid arguments for tool ${toolName}: ${getErrorMessage3(
|
3369
|
+
cause
|
3370
|
+
)}`
|
3371
|
+
}) {
|
3372
|
+
super({ name: name10, message, cause });
|
3373
|
+
this[_a10] = true;
|
3374
|
+
this.toolArgs = toolArgs;
|
3375
|
+
this.toolName = toolName;
|
3376
|
+
}
|
3377
|
+
static isInstance(error) {
|
3378
|
+
return AISDKError10.hasMarker(error, marker10);
|
3379
|
+
}
|
3380
|
+
};
|
3381
|
+
_a10 = symbol10;
|
3382
|
+
|
3383
|
+
// errors/no-such-tool-error.ts
|
3384
|
+
import { AISDKError as AISDKError11 } from "@ai-sdk/provider";
|
3385
|
+
var name11 = "AI_NoSuchToolError";
|
3386
|
+
var marker11 = `vercel.ai.error.${name11}`;
|
3387
|
+
var symbol11 = Symbol.for(marker11);
|
3388
|
+
var _a11;
|
3389
|
+
var NoSuchToolError = class extends AISDKError11 {
|
3390
|
+
constructor({
|
3391
|
+
toolName,
|
3392
|
+
availableTools = void 0,
|
3393
|
+
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
3394
|
+
}) {
|
3395
|
+
super({ name: name11, message });
|
3396
|
+
this[_a11] = true;
|
3397
|
+
this.toolName = toolName;
|
3398
|
+
this.availableTools = availableTools;
|
3399
|
+
}
|
3400
|
+
static isInstance(error) {
|
3401
|
+
return AISDKError11.hasMarker(error, marker11);
|
3402
|
+
}
|
3403
|
+
};
|
3404
|
+
_a11 = symbol11;
|
3405
|
+
|
3406
|
+
// errors/tool-call-repair-error.ts
|
3407
|
+
import { AISDKError as AISDKError12, getErrorMessage as getErrorMessage4 } from "@ai-sdk/provider";
|
3408
|
+
var name12 = "AI_ToolCallRepairError";
|
3409
|
+
var marker12 = `vercel.ai.error.${name12}`;
|
3410
|
+
var symbol12 = Symbol.for(marker12);
|
3411
|
+
var _a12;
|
3412
|
+
var ToolCallRepairError = class extends AISDKError12 {
|
3413
|
+
constructor({
|
3414
|
+
cause,
|
3415
|
+
originalError,
|
3416
|
+
message = `Error repairing tool call: ${getErrorMessage4(cause)}`
|
3417
|
+
}) {
|
3418
|
+
super({ name: name12, message, cause });
|
3419
|
+
this[_a12] = true;
|
3420
|
+
this.originalError = originalError;
|
3421
|
+
}
|
3422
|
+
static isInstance(error) {
|
3423
|
+
return AISDKError12.hasMarker(error, marker12);
|
3424
|
+
}
|
3425
|
+
};
|
3426
|
+
_a12 = symbol12;
|
3427
|
+
|
3428
|
+
// core/generate-text/parse-tool-call.ts
|
3442
3429
|
async function parseToolCall({
|
3443
3430
|
toolCall,
|
3444
3431
|
tools,
|
@@ -3832,13 +3819,15 @@ async function generateText({
|
|
3832
3819
|
);
|
3833
3820
|
return new DefaultGenerateTextResult({
|
3834
3821
|
text: text2,
|
3835
|
-
|
3836
|
-
|
3837
|
-
|
3838
|
-
response: currentModelResponse.response,
|
3839
|
-
usage
|
3822
|
+
outputResolver: () => {
|
3823
|
+
if (output == null) {
|
3824
|
+
throw new NoOutputSpecifiedError();
|
3840
3825
|
}
|
3841
|
-
|
3826
|
+
return output.parseOutput(
|
3827
|
+
{ text: text2 },
|
3828
|
+
{ response: currentModelResponse.response, usage }
|
3829
|
+
);
|
3830
|
+
},
|
3842
3831
|
toolCalls: currentToolCalls,
|
3843
3832
|
toolResults: currentToolResults,
|
3844
3833
|
finishReason: currentModelResponse.finishReason,
|
@@ -3944,7 +3933,10 @@ var DefaultGenerateTextResult = class {
|
|
3944
3933
|
this.steps = options.steps;
|
3945
3934
|
this.experimental_providerMetadata = options.providerMetadata;
|
3946
3935
|
this.logprobs = options.logprobs;
|
3947
|
-
this.
|
3936
|
+
this.outputResolver = options.outputResolver;
|
3937
|
+
}
|
3938
|
+
get experimental_output() {
|
3939
|
+
return this.outputResolver();
|
3948
3940
|
}
|
3949
3941
|
};
|
3950
3942
|
|
@@ -3959,6 +3951,23 @@ import {
|
|
3959
3951
|
asSchema as asSchema4,
|
3960
3952
|
parsePartialJson as parsePartialJson2
|
3961
3953
|
} from "@ai-sdk/ui-utils";
|
3954
|
+
|
3955
|
+
// errors/index.ts
|
3956
|
+
import {
|
3957
|
+
AISDKError as AISDKError13,
|
3958
|
+
APICallError as APICallError2,
|
3959
|
+
EmptyResponseBodyError,
|
3960
|
+
InvalidPromptError as InvalidPromptError2,
|
3961
|
+
InvalidResponseDataError,
|
3962
|
+
JSONParseError,
|
3963
|
+
LoadAPIKeyError,
|
3964
|
+
NoContentGeneratedError,
|
3965
|
+
NoSuchModelError,
|
3966
|
+
TypeValidationError as TypeValidationError2,
|
3967
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
3968
|
+
} from "@ai-sdk/provider";
|
3969
|
+
|
3970
|
+
// core/generate-text/output.ts
|
3962
3971
|
var text = () => ({
|
3963
3972
|
type: "text",
|
3964
3973
|
responseFormat: () => ({ type: "text" }),
|