ai 3.1.0-canary.3 → 3.1.0-canary.4
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/README.md +1 -1
- package/ai-model-specification/dist/index.d.mts +77 -18
- package/ai-model-specification/dist/index.d.ts +77 -18
- package/ai-model-specification/dist/index.js +236 -137
- package/ai-model-specification/dist/index.js.map +1 -1
- package/ai-model-specification/dist/index.mjs +232 -136
- package/ai-model-specification/dist/index.mjs.map +1 -1
- package/core/dist/index.d.mts +42 -6
- package/core/dist/index.d.ts +42 -6
- package/core/dist/index.js +681 -291
- package/core/dist/index.js.map +1 -1
- package/core/dist/index.mjs +683 -291
- package/core/dist/index.mjs.map +1 -1
- package/{provider → openai}/dist/index.js +153 -116
- package/openai/dist/index.js.map +1 -0
- package/{provider → openai}/dist/index.mjs +149 -112
- package/openai/dist/index.mjs.map +1 -0
- package/package.json +12 -12
- package/react/dist/index.d.mts +4 -0
- package/react/dist/index.d.ts +4 -0
- package/react/dist/index.js +2 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +2 -1
- package/react/dist/index.mjs.map +1 -1
- package/provider/dist/index.js.map +0 -1
- package/provider/dist/index.mjs.map +0 -1
- /package/{provider → openai}/dist/index.d.mts +0 -0
- /package/{provider → openai}/dist/index.d.ts +0 -0
package/README.md
CHANGED
@@ -26,7 +26,7 @@ This library is created by [Vercel](https://vercel.com) and [Next.js](https://ne
|
|
26
26
|
- Shu Ding ([@shuding\_](https://twitter.com/shuding_)) - [Vercel](https://vercel.com)
|
27
27
|
- Max Leiter ([@max_leiter](https://twitter.com/max_leiter)) - [Vercel](https://vercel.com)
|
28
28
|
- Malte Ubl ([@cramforce](https://twitter.com/cramforce)) - [Vercel](https://vercel.com)
|
29
|
-
- Justin Ridgewell ([@jridgewell](https://github.com/jridgewell))
|
29
|
+
- Justin Ridgewell ([@jridgewell](https://github.com/jridgewell))
|
30
30
|
|
31
31
|
[Contributors](https://github.com/vercel/ai/graphs/contributors)
|
32
32
|
|
@@ -1,23 +1,6 @@
|
|
1
1
|
import * as zod from 'zod';
|
2
2
|
import { ZodSchema } from 'zod';
|
3
3
|
|
4
|
-
declare class AI_InvalidArgumentError extends Error {
|
5
|
-
readonly parameter: string;
|
6
|
-
readonly value: unknown;
|
7
|
-
constructor({ parameter, value, message, }: {
|
8
|
-
parameter: string;
|
9
|
-
value: unknown;
|
10
|
-
message: string;
|
11
|
-
});
|
12
|
-
toJSON(): {
|
13
|
-
name: string;
|
14
|
-
message: string;
|
15
|
-
stack: string | undefined;
|
16
|
-
parameter: string;
|
17
|
-
value: unknown;
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
4
|
declare class APICallError extends Error {
|
22
5
|
readonly url: string;
|
23
6
|
readonly requestBodyValues: unknown;
|
@@ -37,6 +20,7 @@ declare class APICallError extends Error {
|
|
37
20
|
isRetryable?: boolean;
|
38
21
|
data?: unknown;
|
39
22
|
});
|
23
|
+
static isAPICallError(error: unknown): error is APICallError;
|
40
24
|
toJSON(): {
|
41
25
|
name: string;
|
42
26
|
message: string;
|
@@ -50,6 +34,60 @@ declare class APICallError extends Error {
|
|
50
34
|
};
|
51
35
|
}
|
52
36
|
|
37
|
+
declare class InvalidArgumentError extends Error {
|
38
|
+
readonly parameter: string;
|
39
|
+
readonly value: unknown;
|
40
|
+
constructor({ parameter, value, message, }: {
|
41
|
+
parameter: string;
|
42
|
+
value: unknown;
|
43
|
+
message: string;
|
44
|
+
});
|
45
|
+
static isInvalidArgumentError(error: unknown): error is InvalidArgumentError;
|
46
|
+
toJSON(): {
|
47
|
+
name: string;
|
48
|
+
message: string;
|
49
|
+
stack: string | undefined;
|
50
|
+
parameter: string;
|
51
|
+
value: unknown;
|
52
|
+
};
|
53
|
+
}
|
54
|
+
|
55
|
+
declare class InvalidPromptError extends Error {
|
56
|
+
readonly prompt: unknown;
|
57
|
+
constructor({ prompt, message }: {
|
58
|
+
prompt: unknown;
|
59
|
+
message: string;
|
60
|
+
});
|
61
|
+
static isInvalidPromptError(error: unknown): error is InvalidPromptError;
|
62
|
+
toJSON(): {
|
63
|
+
name: string;
|
64
|
+
message: string;
|
65
|
+
stack: string | undefined;
|
66
|
+
prompt: unknown;
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
declare class InvalidToolArgumentsError extends Error {
|
71
|
+
readonly toolName: string;
|
72
|
+
readonly toolArgs: string;
|
73
|
+
readonly cause: unknown;
|
74
|
+
constructor({ toolArgs, toolName, cause, message, }: {
|
75
|
+
message?: string;
|
76
|
+
toolArgs: string;
|
77
|
+
toolName: string;
|
78
|
+
cause: unknown;
|
79
|
+
});
|
80
|
+
static isInvalidToolArgumentsError(error: unknown): error is InvalidToolArgumentsError;
|
81
|
+
toJSON(): {
|
82
|
+
name: string;
|
83
|
+
message: string;
|
84
|
+
cause: unknown;
|
85
|
+
stack: string | undefined;
|
86
|
+
toolName: string;
|
87
|
+
toolArgs: string;
|
88
|
+
};
|
89
|
+
}
|
90
|
+
|
53
91
|
declare class JSONParseError extends Error {
|
54
92
|
readonly text: string;
|
55
93
|
readonly cause: unknown;
|
@@ -57,6 +95,7 @@ declare class JSONParseError extends Error {
|
|
57
95
|
text: string;
|
58
96
|
cause: unknown;
|
59
97
|
});
|
98
|
+
static isJSONParseError(error: unknown): error is JSONParseError;
|
60
99
|
toJSON(): {
|
61
100
|
name: string;
|
62
101
|
message: string;
|
@@ -70,6 +109,7 @@ declare class LoadAPIKeyError extends Error {
|
|
70
109
|
constructor({ message }: {
|
71
110
|
message: string;
|
72
111
|
});
|
112
|
+
static isLoadAPIKeyError(error: unknown): error is LoadAPIKeyError;
|
73
113
|
toJSON(): {
|
74
114
|
name: string;
|
75
115
|
message: string;
|
@@ -79,6 +119,7 @@ declare class LoadAPIKeyError extends Error {
|
|
79
119
|
declare class NoTextGeneratedError extends Error {
|
80
120
|
readonly cause: unknown;
|
81
121
|
constructor();
|
122
|
+
static isNoTextGeneratedError(error: unknown): error is NoTextGeneratedError;
|
82
123
|
toJSON(): {
|
83
124
|
name: string;
|
84
125
|
cause: unknown;
|
@@ -87,6 +128,21 @@ declare class NoTextGeneratedError extends Error {
|
|
87
128
|
};
|
88
129
|
}
|
89
130
|
|
131
|
+
declare class NoSuchToolError extends Error {
|
132
|
+
readonly toolName: string;
|
133
|
+
constructor({ message, toolName }: {
|
134
|
+
message: string;
|
135
|
+
toolName: string;
|
136
|
+
});
|
137
|
+
static isNoSuchToolError(error: unknown): error is NoSuchToolError;
|
138
|
+
toJSON(): {
|
139
|
+
name: string;
|
140
|
+
message: string;
|
141
|
+
stack: string | undefined;
|
142
|
+
toolName: string;
|
143
|
+
};
|
144
|
+
}
|
145
|
+
|
90
146
|
type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable' | 'abort';
|
91
147
|
declare class RetryError extends Error {
|
92
148
|
readonly reason: RetryErrorReason;
|
@@ -97,6 +153,7 @@ declare class RetryError extends Error {
|
|
97
153
|
reason: RetryErrorReason;
|
98
154
|
errors: Array<unknown>;
|
99
155
|
});
|
156
|
+
static isRetryError(error: unknown): error is RetryError;
|
100
157
|
toJSON(): {
|
101
158
|
name: string;
|
102
159
|
message: string;
|
@@ -113,6 +170,7 @@ declare class TypeValidationError extends Error {
|
|
113
170
|
value: unknown;
|
114
171
|
cause: unknown;
|
115
172
|
});
|
173
|
+
static isTypeValidationError(error: unknown): error is TypeValidationError;
|
116
174
|
toJSON(): {
|
117
175
|
name: string;
|
118
176
|
message: string;
|
@@ -129,6 +187,7 @@ declare class UnsupportedFunctionalityError extends Error {
|
|
129
187
|
provider: string;
|
130
188
|
functionality: string;
|
131
189
|
});
|
190
|
+
static isUnsupportedFunctionalityError(error: unknown): error is UnsupportedFunctionalityError;
|
132
191
|
toJSON(): {
|
133
192
|
name: string;
|
134
193
|
message: string;
|
@@ -603,4 +662,4 @@ declare function safeValidateTypes<T>({ value, schema, }: {
|
|
603
662
|
error: TypeValidationError;
|
604
663
|
};
|
605
664
|
|
606
|
-
export {
|
665
|
+
export { APICallError, InvalidArgumentError, InvalidPromptError, InvalidToolArgumentsError, JSONParseError, LanguageModelV1, LanguageModelV1CallOptions, LanguageModelV1CallWarning, LanguageModelV1FinishReason, LanguageModelV1FunctionTool, LanguageModelV1FunctionToolCall, LanguageModelV1ImagePart, LanguageModelV1Message, LanguageModelV1Prompt, LanguageModelV1StreamPart, LanguageModelV1TextPart, LanguageModelV1ToolCallPart, LanguageModelV1ToolResultPart, LoadAPIKeyError, NoSuchToolError, NoTextGeneratedError, ParsedChunk, ResponseHandler, RetryError, RetryErrorReason, TypeValidationError, UnsupportedFunctionalityError, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, getErrorMessage, isParseableJson, loadApiKey, parseJSON, postJsonToApi, postToApi, safeParseJSON, safeValidateTypes, scale, validateTypes };
|
@@ -1,23 +1,6 @@
|
|
1
1
|
import * as zod from 'zod';
|
2
2
|
import { ZodSchema } from 'zod';
|
3
3
|
|
4
|
-
declare class AI_InvalidArgumentError extends Error {
|
5
|
-
readonly parameter: string;
|
6
|
-
readonly value: unknown;
|
7
|
-
constructor({ parameter, value, message, }: {
|
8
|
-
parameter: string;
|
9
|
-
value: unknown;
|
10
|
-
message: string;
|
11
|
-
});
|
12
|
-
toJSON(): {
|
13
|
-
name: string;
|
14
|
-
message: string;
|
15
|
-
stack: string | undefined;
|
16
|
-
parameter: string;
|
17
|
-
value: unknown;
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
4
|
declare class APICallError extends Error {
|
22
5
|
readonly url: string;
|
23
6
|
readonly requestBodyValues: unknown;
|
@@ -37,6 +20,7 @@ declare class APICallError extends Error {
|
|
37
20
|
isRetryable?: boolean;
|
38
21
|
data?: unknown;
|
39
22
|
});
|
23
|
+
static isAPICallError(error: unknown): error is APICallError;
|
40
24
|
toJSON(): {
|
41
25
|
name: string;
|
42
26
|
message: string;
|
@@ -50,6 +34,60 @@ declare class APICallError extends Error {
|
|
50
34
|
};
|
51
35
|
}
|
52
36
|
|
37
|
+
declare class InvalidArgumentError extends Error {
|
38
|
+
readonly parameter: string;
|
39
|
+
readonly value: unknown;
|
40
|
+
constructor({ parameter, value, message, }: {
|
41
|
+
parameter: string;
|
42
|
+
value: unknown;
|
43
|
+
message: string;
|
44
|
+
});
|
45
|
+
static isInvalidArgumentError(error: unknown): error is InvalidArgumentError;
|
46
|
+
toJSON(): {
|
47
|
+
name: string;
|
48
|
+
message: string;
|
49
|
+
stack: string | undefined;
|
50
|
+
parameter: string;
|
51
|
+
value: unknown;
|
52
|
+
};
|
53
|
+
}
|
54
|
+
|
55
|
+
declare class InvalidPromptError extends Error {
|
56
|
+
readonly prompt: unknown;
|
57
|
+
constructor({ prompt, message }: {
|
58
|
+
prompt: unknown;
|
59
|
+
message: string;
|
60
|
+
});
|
61
|
+
static isInvalidPromptError(error: unknown): error is InvalidPromptError;
|
62
|
+
toJSON(): {
|
63
|
+
name: string;
|
64
|
+
message: string;
|
65
|
+
stack: string | undefined;
|
66
|
+
prompt: unknown;
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
declare class InvalidToolArgumentsError extends Error {
|
71
|
+
readonly toolName: string;
|
72
|
+
readonly toolArgs: string;
|
73
|
+
readonly cause: unknown;
|
74
|
+
constructor({ toolArgs, toolName, cause, message, }: {
|
75
|
+
message?: string;
|
76
|
+
toolArgs: string;
|
77
|
+
toolName: string;
|
78
|
+
cause: unknown;
|
79
|
+
});
|
80
|
+
static isInvalidToolArgumentsError(error: unknown): error is InvalidToolArgumentsError;
|
81
|
+
toJSON(): {
|
82
|
+
name: string;
|
83
|
+
message: string;
|
84
|
+
cause: unknown;
|
85
|
+
stack: string | undefined;
|
86
|
+
toolName: string;
|
87
|
+
toolArgs: string;
|
88
|
+
};
|
89
|
+
}
|
90
|
+
|
53
91
|
declare class JSONParseError extends Error {
|
54
92
|
readonly text: string;
|
55
93
|
readonly cause: unknown;
|
@@ -57,6 +95,7 @@ declare class JSONParseError extends Error {
|
|
57
95
|
text: string;
|
58
96
|
cause: unknown;
|
59
97
|
});
|
98
|
+
static isJSONParseError(error: unknown): error is JSONParseError;
|
60
99
|
toJSON(): {
|
61
100
|
name: string;
|
62
101
|
message: string;
|
@@ -70,6 +109,7 @@ declare class LoadAPIKeyError extends Error {
|
|
70
109
|
constructor({ message }: {
|
71
110
|
message: string;
|
72
111
|
});
|
112
|
+
static isLoadAPIKeyError(error: unknown): error is LoadAPIKeyError;
|
73
113
|
toJSON(): {
|
74
114
|
name: string;
|
75
115
|
message: string;
|
@@ -79,6 +119,7 @@ declare class LoadAPIKeyError extends Error {
|
|
79
119
|
declare class NoTextGeneratedError extends Error {
|
80
120
|
readonly cause: unknown;
|
81
121
|
constructor();
|
122
|
+
static isNoTextGeneratedError(error: unknown): error is NoTextGeneratedError;
|
82
123
|
toJSON(): {
|
83
124
|
name: string;
|
84
125
|
cause: unknown;
|
@@ -87,6 +128,21 @@ declare class NoTextGeneratedError extends Error {
|
|
87
128
|
};
|
88
129
|
}
|
89
130
|
|
131
|
+
declare class NoSuchToolError extends Error {
|
132
|
+
readonly toolName: string;
|
133
|
+
constructor({ message, toolName }: {
|
134
|
+
message: string;
|
135
|
+
toolName: string;
|
136
|
+
});
|
137
|
+
static isNoSuchToolError(error: unknown): error is NoSuchToolError;
|
138
|
+
toJSON(): {
|
139
|
+
name: string;
|
140
|
+
message: string;
|
141
|
+
stack: string | undefined;
|
142
|
+
toolName: string;
|
143
|
+
};
|
144
|
+
}
|
145
|
+
|
90
146
|
type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable' | 'abort';
|
91
147
|
declare class RetryError extends Error {
|
92
148
|
readonly reason: RetryErrorReason;
|
@@ -97,6 +153,7 @@ declare class RetryError extends Error {
|
|
97
153
|
reason: RetryErrorReason;
|
98
154
|
errors: Array<unknown>;
|
99
155
|
});
|
156
|
+
static isRetryError(error: unknown): error is RetryError;
|
100
157
|
toJSON(): {
|
101
158
|
name: string;
|
102
159
|
message: string;
|
@@ -113,6 +170,7 @@ declare class TypeValidationError extends Error {
|
|
113
170
|
value: unknown;
|
114
171
|
cause: unknown;
|
115
172
|
});
|
173
|
+
static isTypeValidationError(error: unknown): error is TypeValidationError;
|
116
174
|
toJSON(): {
|
117
175
|
name: string;
|
118
176
|
message: string;
|
@@ -129,6 +187,7 @@ declare class UnsupportedFunctionalityError extends Error {
|
|
129
187
|
provider: string;
|
130
188
|
functionality: string;
|
131
189
|
});
|
190
|
+
static isUnsupportedFunctionalityError(error: unknown): error is UnsupportedFunctionalityError;
|
132
191
|
toJSON(): {
|
133
192
|
name: string;
|
134
193
|
message: string;
|
@@ -603,4 +662,4 @@ declare function safeValidateTypes<T>({ value, schema, }: {
|
|
603
662
|
error: TypeValidationError;
|
604
663
|
};
|
605
664
|
|
606
|
-
export {
|
665
|
+
export { APICallError, InvalidArgumentError, InvalidPromptError, InvalidToolArgumentsError, JSONParseError, LanguageModelV1, LanguageModelV1CallOptions, LanguageModelV1CallWarning, LanguageModelV1FinishReason, LanguageModelV1FunctionTool, LanguageModelV1FunctionToolCall, LanguageModelV1ImagePart, LanguageModelV1Message, LanguageModelV1Prompt, LanguageModelV1StreamPart, LanguageModelV1TextPart, LanguageModelV1ToolCallPart, LanguageModelV1ToolResultPart, LoadAPIKeyError, NoSuchToolError, NoTextGeneratedError, ParsedChunk, ResponseHandler, RetryError, RetryErrorReason, TypeValidationError, UnsupportedFunctionalityError, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, getErrorMessage, isParseableJson, loadApiKey, parseJSON, postJsonToApi, postToApi, safeParseJSON, safeValidateTypes, scale, validateTypes };
|