@ai-sdk/google 4.0.97 → 4.0.99
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 +15 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +28 -3
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +1 -1
- package/package.json +3 -3
- package/src/google-error.ts +9 -6
- package/src/google-language-model-options.ts +3 -1
- package/src/google-language-model.ts +28 -1
package/docs/15-google.mdx
CHANGED
|
@@ -223,7 +223,7 @@ The following optional provider options are available for Google models:
|
|
|
223
223
|
- `OFF`
|
|
224
224
|
|
|
225
225
|
- **responseModalities** _string[]_
|
|
226
|
-
The modalities to use for the response.
|
|
226
|
+
The modalities to use for the response. Valid values are `TEXT`, `IMAGE`, and `AUDIO`, but support is model-dependent. When not defined or empty, the model defaults to returning only text.
|
|
227
227
|
|
|
228
228
|
- **thinkingConfig** _\{ thinkingLevel?: 'minimal' | 'low' | 'medium' | 'high'; thinkingBudget?: number; includeThoughts?: boolean \}_
|
|
229
229
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.99",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "4.0.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
38
|
+
"@ai-sdk/provider": "4.0.29",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.62"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.4",
|
package/src/google-error.ts
CHANGED
|
@@ -6,15 +6,18 @@ import {
|
|
|
6
6
|
} from '@ai-sdk/provider-utils';
|
|
7
7
|
import { z } from 'zod/v4';
|
|
8
8
|
|
|
9
|
+
export const getGoogleErrorSchema = () =>
|
|
10
|
+
z.object({
|
|
11
|
+
code: z.number().nullable(),
|
|
12
|
+
message: z.string(),
|
|
13
|
+
status: z.string(),
|
|
14
|
+
details: z.array(z.unknown()).nullish(),
|
|
15
|
+
});
|
|
16
|
+
|
|
9
17
|
const googleErrorDataSchema = lazySchema(() =>
|
|
10
18
|
zodSchema(
|
|
11
19
|
z.object({
|
|
12
|
-
error:
|
|
13
|
-
code: z.number().nullable(),
|
|
14
|
-
message: z.string(),
|
|
15
|
-
status: z.string(),
|
|
16
|
-
details: z.array(z.unknown()).nullish(),
|
|
17
|
-
}),
|
|
20
|
+
error: getGoogleErrorSchema(),
|
|
18
21
|
}),
|
|
19
22
|
),
|
|
20
23
|
);
|
|
@@ -61,7 +61,9 @@ export type GoogleModelId =
|
|
|
61
61
|
export const googleLanguageModelOptions = lazySchema(() =>
|
|
62
62
|
zodSchema(
|
|
63
63
|
z.object({
|
|
64
|
-
responseModalities: z
|
|
64
|
+
responseModalities: z
|
|
65
|
+
.array(z.enum(['TEXT', 'IMAGE', 'AUDIO']))
|
|
66
|
+
.optional(),
|
|
65
67
|
|
|
66
68
|
thinkingConfig: z
|
|
67
69
|
.object({
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
createToolNameMapping,
|
|
19
19
|
createEventSourceResponseHandler,
|
|
20
20
|
createJsonResponseHandler,
|
|
21
|
+
createProviderStreamError,
|
|
21
22
|
generateId,
|
|
22
23
|
isCustomReasoning,
|
|
23
24
|
lazySchema,
|
|
@@ -45,7 +46,10 @@ import {
|
|
|
45
46
|
import { convertToGoogleMessages } from './convert-to-google-messages';
|
|
46
47
|
import { downloadToolResultFiles } from './download-tool-result-files';
|
|
47
48
|
import { getModelPath } from './get-model-path';
|
|
48
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
getGoogleErrorSchema,
|
|
51
|
+
googleFailedResponseHandler,
|
|
52
|
+
} from './google-error';
|
|
49
53
|
import { sanitizeResponseJsonSchema } from './sanitize-response-json-schema';
|
|
50
54
|
import {
|
|
51
55
|
googleLanguageModelOptions,
|
|
@@ -995,6 +999,28 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
995
999
|
|
|
996
1000
|
const value = chunk.value;
|
|
997
1001
|
|
|
1002
|
+
if (value.error != null) {
|
|
1003
|
+
finishReason = { unified: 'error', raw: undefined };
|
|
1004
|
+
const error = value.error;
|
|
1005
|
+
controller.enqueue({
|
|
1006
|
+
type: 'error',
|
|
1007
|
+
error: createProviderStreamError({
|
|
1008
|
+
message: error.message,
|
|
1009
|
+
type: error.status,
|
|
1010
|
+
code: error.code ?? undefined,
|
|
1011
|
+
statusCode: error.code ?? undefined,
|
|
1012
|
+
isRetryable:
|
|
1013
|
+
error.code != null &&
|
|
1014
|
+
(error.code === 408 ||
|
|
1015
|
+
error.code === 409 ||
|
|
1016
|
+
error.code === 429 ||
|
|
1017
|
+
error.code >= 500),
|
|
1018
|
+
data: error,
|
|
1019
|
+
}),
|
|
1020
|
+
});
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
998
1024
|
if (!hasEmittedResponseMetadata && value.responseId != null) {
|
|
999
1025
|
hasEmittedResponseMetadata = true;
|
|
1000
1026
|
controller.enqueue({
|
|
@@ -2012,6 +2038,7 @@ export type UsageMetadataSchema = NonNullable<
|
|
|
2012
2038
|
const chunkSchema = lazySchema(() =>
|
|
2013
2039
|
zodSchema(
|
|
2014
2040
|
z.object({
|
|
2041
|
+
error: getGoogleErrorSchema().nullish(),
|
|
2015
2042
|
responseId: z.string().nullish(),
|
|
2016
2043
|
candidates: z
|
|
2017
2044
|
.array(
|