@ai-sdk/google 1.0.9 → 1.0.11
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 +14 -0
- package/dist/index.d.mts +124 -10
- package/dist/index.d.ts +124 -10
- package/dist/index.js +42 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -10
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +119 -13
- package/internal/dist/index.d.ts +119 -13
- package/internal/dist/index.js +46 -12
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +44 -11
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @ai-sdk/google
|
2
2
|
|
3
|
+
## 1.0.11
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- db31e74: feat: adding audioTimestamp support to GoogleGenerativeAISettings
|
8
|
+
|
9
|
+
## 1.0.10
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- e07439a: feat (provider/google): Include safety ratings response detail.
|
14
|
+
- 4017b0f: feat (provider/google-vertex): Enhance grounding metadata response detail.
|
15
|
+
- a9df182: feat (provider/google): Add support for search grounding.
|
16
|
+
|
3
17
|
## 1.0.9
|
4
18
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -26,6 +26,18 @@ interface GoogleGenerativeAISettings {
|
|
26
26
|
category: 'HARM_CATEGORY_UNSPECIFIED' | 'HARM_CATEGORY_HATE_SPEECH' | 'HARM_CATEGORY_DANGEROUS_CONTENT' | 'HARM_CATEGORY_HARASSMENT' | 'HARM_CATEGORY_SEXUALLY_EXPLICIT' | 'HARM_CATEGORY_CIVIC_INTEGRITY';
|
27
27
|
threshold: 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' | 'BLOCK_LOW_AND_ABOVE' | 'BLOCK_MEDIUM_AND_ABOVE' | 'BLOCK_ONLY_HIGH' | 'BLOCK_NONE';
|
28
28
|
}>;
|
29
|
+
/**
|
30
|
+
* Optional. Enables timestamp understanding for audio-only files.
|
31
|
+
*
|
32
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
33
|
+
*/
|
34
|
+
audioTimestamp?: boolean;
|
35
|
+
/**
|
36
|
+
Optional. When enabled, the model will use Google search to ground the response.
|
37
|
+
|
38
|
+
@see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview
|
39
|
+
*/
|
40
|
+
useSearchGrounding?: boolean;
|
29
41
|
}
|
30
42
|
|
31
43
|
type GoogleGenerativeAIEmbeddingModelId = 'text-embedding-004' | (string & {});
|
@@ -91,6 +103,7 @@ declare const google: GoogleGenerativeAIProvider;
|
|
91
103
|
|
92
104
|
declare const groundingMetadataSchema: z.ZodObject<{
|
93
105
|
webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
106
|
+
retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
94
107
|
searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
95
108
|
renderedContent: z.ZodString;
|
96
109
|
}, "strip", z.ZodTypeAny, {
|
@@ -98,6 +111,46 @@ declare const groundingMetadataSchema: z.ZodObject<{
|
|
98
111
|
}, {
|
99
112
|
renderedContent: string;
|
100
113
|
}>>>;
|
114
|
+
groundingChunks: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
115
|
+
web: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
116
|
+
uri: z.ZodString;
|
117
|
+
title: z.ZodString;
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
119
|
+
uri: string;
|
120
|
+
title: string;
|
121
|
+
}, {
|
122
|
+
uri: string;
|
123
|
+
title: string;
|
124
|
+
}>>>;
|
125
|
+
retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
126
|
+
uri: z.ZodString;
|
127
|
+
title: z.ZodString;
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
129
|
+
uri: string;
|
130
|
+
title: string;
|
131
|
+
}, {
|
132
|
+
uri: string;
|
133
|
+
title: string;
|
134
|
+
}>>>;
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
136
|
+
web?: {
|
137
|
+
uri: string;
|
138
|
+
title: string;
|
139
|
+
} | null | undefined;
|
140
|
+
retrievedContext?: {
|
141
|
+
uri: string;
|
142
|
+
title: string;
|
143
|
+
} | null | undefined;
|
144
|
+
}, {
|
145
|
+
web?: {
|
146
|
+
uri: string;
|
147
|
+
title: string;
|
148
|
+
} | null | undefined;
|
149
|
+
retrievedContext?: {
|
150
|
+
uri: string;
|
151
|
+
title: string;
|
152
|
+
} | null | undefined;
|
153
|
+
}>, "many">>>;
|
101
154
|
groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
102
155
|
segment: z.ZodObject<{
|
103
156
|
startIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
@@ -112,24 +165,33 @@ declare const groundingMetadataSchema: z.ZodObject<{
|
|
112
165
|
endIndex?: number | null | undefined;
|
113
166
|
text?: string | null | undefined;
|
114
167
|
}>;
|
115
|
-
|
116
|
-
|
168
|
+
segment_text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
169
|
+
groundingChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
170
|
+
supportChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
171
|
+
confidenceScores: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
172
|
+
confidenceScore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
117
173
|
}, "strip", z.ZodTypeAny, {
|
118
174
|
segment: {
|
119
175
|
startIndex?: number | null | undefined;
|
120
176
|
endIndex?: number | null | undefined;
|
121
177
|
text?: string | null | undefined;
|
122
178
|
};
|
123
|
-
|
124
|
-
|
179
|
+
segment_text?: string | null | undefined;
|
180
|
+
groundingChunkIndices?: number[] | null | undefined;
|
181
|
+
supportChunkIndices?: number[] | null | undefined;
|
182
|
+
confidenceScores?: number[] | null | undefined;
|
183
|
+
confidenceScore?: number[] | null | undefined;
|
125
184
|
}, {
|
126
185
|
segment: {
|
127
186
|
startIndex?: number | null | undefined;
|
128
187
|
endIndex?: number | null | undefined;
|
129
188
|
text?: string | null | undefined;
|
130
189
|
};
|
131
|
-
|
132
|
-
|
190
|
+
segment_text?: string | null | undefined;
|
191
|
+
groundingChunkIndices?: number[] | null | undefined;
|
192
|
+
supportChunkIndices?: number[] | null | undefined;
|
193
|
+
confidenceScores?: number[] | null | undefined;
|
194
|
+
confidenceScore?: number[] | null | undefined;
|
133
195
|
}>, "many">>>;
|
134
196
|
retrievalMetadata: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
135
197
|
webDynamicRetrievalScore: z.ZodNumber;
|
@@ -140,43 +202,95 @@ declare const groundingMetadataSchema: z.ZodObject<{
|
|
140
202
|
}>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
141
203
|
}, "strip", z.ZodTypeAny, {
|
142
204
|
webSearchQueries?: string[] | null | undefined;
|
205
|
+
retrievalQueries?: string[] | null | undefined;
|
143
206
|
searchEntryPoint?: {
|
144
207
|
renderedContent: string;
|
145
208
|
} | null | undefined;
|
209
|
+
groundingChunks?: {
|
210
|
+
web?: {
|
211
|
+
uri: string;
|
212
|
+
title: string;
|
213
|
+
} | null | undefined;
|
214
|
+
retrievedContext?: {
|
215
|
+
uri: string;
|
216
|
+
title: string;
|
217
|
+
} | null | undefined;
|
218
|
+
}[] | null | undefined;
|
146
219
|
groundingSupports?: {
|
147
220
|
segment: {
|
148
221
|
startIndex?: number | null | undefined;
|
149
222
|
endIndex?: number | null | undefined;
|
150
223
|
text?: string | null | undefined;
|
151
224
|
};
|
152
|
-
|
153
|
-
|
225
|
+
segment_text?: string | null | undefined;
|
226
|
+
groundingChunkIndices?: number[] | null | undefined;
|
227
|
+
supportChunkIndices?: number[] | null | undefined;
|
228
|
+
confidenceScores?: number[] | null | undefined;
|
229
|
+
confidenceScore?: number[] | null | undefined;
|
154
230
|
}[] | null | undefined;
|
155
231
|
retrievalMetadata?: {
|
156
232
|
webDynamicRetrievalScore: number;
|
157
233
|
} | {} | null | undefined;
|
158
234
|
}, {
|
159
235
|
webSearchQueries?: string[] | null | undefined;
|
236
|
+
retrievalQueries?: string[] | null | undefined;
|
160
237
|
searchEntryPoint?: {
|
161
238
|
renderedContent: string;
|
162
239
|
} | null | undefined;
|
240
|
+
groundingChunks?: {
|
241
|
+
web?: {
|
242
|
+
uri: string;
|
243
|
+
title: string;
|
244
|
+
} | null | undefined;
|
245
|
+
retrievedContext?: {
|
246
|
+
uri: string;
|
247
|
+
title: string;
|
248
|
+
} | null | undefined;
|
249
|
+
}[] | null | undefined;
|
163
250
|
groundingSupports?: {
|
164
251
|
segment: {
|
165
252
|
startIndex?: number | null | undefined;
|
166
253
|
endIndex?: number | null | undefined;
|
167
254
|
text?: string | null | undefined;
|
168
255
|
};
|
169
|
-
|
170
|
-
|
256
|
+
segment_text?: string | null | undefined;
|
257
|
+
groundingChunkIndices?: number[] | null | undefined;
|
258
|
+
supportChunkIndices?: number[] | null | undefined;
|
259
|
+
confidenceScores?: number[] | null | undefined;
|
260
|
+
confidenceScore?: number[] | null | undefined;
|
171
261
|
}[] | null | undefined;
|
172
262
|
retrievalMetadata?: {
|
173
263
|
webDynamicRetrievalScore: number;
|
174
264
|
} | {} | null | undefined;
|
175
265
|
}>;
|
266
|
+
declare const safetyRatingSchema: z.ZodObject<{
|
267
|
+
category: z.ZodString;
|
268
|
+
probability: z.ZodString;
|
269
|
+
probabilityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
270
|
+
severity: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
271
|
+
severityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
272
|
+
blocked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
274
|
+
category: string;
|
275
|
+
probability: string;
|
276
|
+
probabilityScore?: number | null | undefined;
|
277
|
+
severity?: string | null | undefined;
|
278
|
+
severityScore?: number | null | undefined;
|
279
|
+
blocked?: boolean | null | undefined;
|
280
|
+
}, {
|
281
|
+
category: string;
|
282
|
+
probability: string;
|
283
|
+
probabilityScore?: number | null | undefined;
|
284
|
+
severity?: string | null | undefined;
|
285
|
+
severityScore?: number | null | undefined;
|
286
|
+
blocked?: boolean | null | undefined;
|
287
|
+
}>;
|
176
288
|
|
177
289
|
type GoogleGenerativeAIGroundingMetadata = z.infer<typeof groundingMetadataSchema>;
|
290
|
+
type GoogleGenerativeAISafetyRating = z.infer<typeof safetyRatingSchema>;
|
178
291
|
interface GoogleGenerativeAIProviderMetadata {
|
179
292
|
groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
|
293
|
+
safetyRatings: GoogleGenerativeAISafetyRating[] | null;
|
180
294
|
}
|
181
295
|
|
182
296
|
export { type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
|
package/dist/index.d.ts
CHANGED
@@ -26,6 +26,18 @@ interface GoogleGenerativeAISettings {
|
|
26
26
|
category: 'HARM_CATEGORY_UNSPECIFIED' | 'HARM_CATEGORY_HATE_SPEECH' | 'HARM_CATEGORY_DANGEROUS_CONTENT' | 'HARM_CATEGORY_HARASSMENT' | 'HARM_CATEGORY_SEXUALLY_EXPLICIT' | 'HARM_CATEGORY_CIVIC_INTEGRITY';
|
27
27
|
threshold: 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' | 'BLOCK_LOW_AND_ABOVE' | 'BLOCK_MEDIUM_AND_ABOVE' | 'BLOCK_ONLY_HIGH' | 'BLOCK_NONE';
|
28
28
|
}>;
|
29
|
+
/**
|
30
|
+
* Optional. Enables timestamp understanding for audio-only files.
|
31
|
+
*
|
32
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
33
|
+
*/
|
34
|
+
audioTimestamp?: boolean;
|
35
|
+
/**
|
36
|
+
Optional. When enabled, the model will use Google search to ground the response.
|
37
|
+
|
38
|
+
@see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview
|
39
|
+
*/
|
40
|
+
useSearchGrounding?: boolean;
|
29
41
|
}
|
30
42
|
|
31
43
|
type GoogleGenerativeAIEmbeddingModelId = 'text-embedding-004' | (string & {});
|
@@ -91,6 +103,7 @@ declare const google: GoogleGenerativeAIProvider;
|
|
91
103
|
|
92
104
|
declare const groundingMetadataSchema: z.ZodObject<{
|
93
105
|
webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
106
|
+
retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
94
107
|
searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
95
108
|
renderedContent: z.ZodString;
|
96
109
|
}, "strip", z.ZodTypeAny, {
|
@@ -98,6 +111,46 @@ declare const groundingMetadataSchema: z.ZodObject<{
|
|
98
111
|
}, {
|
99
112
|
renderedContent: string;
|
100
113
|
}>>>;
|
114
|
+
groundingChunks: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
115
|
+
web: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
116
|
+
uri: z.ZodString;
|
117
|
+
title: z.ZodString;
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
119
|
+
uri: string;
|
120
|
+
title: string;
|
121
|
+
}, {
|
122
|
+
uri: string;
|
123
|
+
title: string;
|
124
|
+
}>>>;
|
125
|
+
retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
126
|
+
uri: z.ZodString;
|
127
|
+
title: z.ZodString;
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
129
|
+
uri: string;
|
130
|
+
title: string;
|
131
|
+
}, {
|
132
|
+
uri: string;
|
133
|
+
title: string;
|
134
|
+
}>>>;
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
136
|
+
web?: {
|
137
|
+
uri: string;
|
138
|
+
title: string;
|
139
|
+
} | null | undefined;
|
140
|
+
retrievedContext?: {
|
141
|
+
uri: string;
|
142
|
+
title: string;
|
143
|
+
} | null | undefined;
|
144
|
+
}, {
|
145
|
+
web?: {
|
146
|
+
uri: string;
|
147
|
+
title: string;
|
148
|
+
} | null | undefined;
|
149
|
+
retrievedContext?: {
|
150
|
+
uri: string;
|
151
|
+
title: string;
|
152
|
+
} | null | undefined;
|
153
|
+
}>, "many">>>;
|
101
154
|
groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
102
155
|
segment: z.ZodObject<{
|
103
156
|
startIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
@@ -112,24 +165,33 @@ declare const groundingMetadataSchema: z.ZodObject<{
|
|
112
165
|
endIndex?: number | null | undefined;
|
113
166
|
text?: string | null | undefined;
|
114
167
|
}>;
|
115
|
-
|
116
|
-
|
168
|
+
segment_text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
169
|
+
groundingChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
170
|
+
supportChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
171
|
+
confidenceScores: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
172
|
+
confidenceScore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>>;
|
117
173
|
}, "strip", z.ZodTypeAny, {
|
118
174
|
segment: {
|
119
175
|
startIndex?: number | null | undefined;
|
120
176
|
endIndex?: number | null | undefined;
|
121
177
|
text?: string | null | undefined;
|
122
178
|
};
|
123
|
-
|
124
|
-
|
179
|
+
segment_text?: string | null | undefined;
|
180
|
+
groundingChunkIndices?: number[] | null | undefined;
|
181
|
+
supportChunkIndices?: number[] | null | undefined;
|
182
|
+
confidenceScores?: number[] | null | undefined;
|
183
|
+
confidenceScore?: number[] | null | undefined;
|
125
184
|
}, {
|
126
185
|
segment: {
|
127
186
|
startIndex?: number | null | undefined;
|
128
187
|
endIndex?: number | null | undefined;
|
129
188
|
text?: string | null | undefined;
|
130
189
|
};
|
131
|
-
|
132
|
-
|
190
|
+
segment_text?: string | null | undefined;
|
191
|
+
groundingChunkIndices?: number[] | null | undefined;
|
192
|
+
supportChunkIndices?: number[] | null | undefined;
|
193
|
+
confidenceScores?: number[] | null | undefined;
|
194
|
+
confidenceScore?: number[] | null | undefined;
|
133
195
|
}>, "many">>>;
|
134
196
|
retrievalMetadata: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
135
197
|
webDynamicRetrievalScore: z.ZodNumber;
|
@@ -140,43 +202,95 @@ declare const groundingMetadataSchema: z.ZodObject<{
|
|
140
202
|
}>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
141
203
|
}, "strip", z.ZodTypeAny, {
|
142
204
|
webSearchQueries?: string[] | null | undefined;
|
205
|
+
retrievalQueries?: string[] | null | undefined;
|
143
206
|
searchEntryPoint?: {
|
144
207
|
renderedContent: string;
|
145
208
|
} | null | undefined;
|
209
|
+
groundingChunks?: {
|
210
|
+
web?: {
|
211
|
+
uri: string;
|
212
|
+
title: string;
|
213
|
+
} | null | undefined;
|
214
|
+
retrievedContext?: {
|
215
|
+
uri: string;
|
216
|
+
title: string;
|
217
|
+
} | null | undefined;
|
218
|
+
}[] | null | undefined;
|
146
219
|
groundingSupports?: {
|
147
220
|
segment: {
|
148
221
|
startIndex?: number | null | undefined;
|
149
222
|
endIndex?: number | null | undefined;
|
150
223
|
text?: string | null | undefined;
|
151
224
|
};
|
152
|
-
|
153
|
-
|
225
|
+
segment_text?: string | null | undefined;
|
226
|
+
groundingChunkIndices?: number[] | null | undefined;
|
227
|
+
supportChunkIndices?: number[] | null | undefined;
|
228
|
+
confidenceScores?: number[] | null | undefined;
|
229
|
+
confidenceScore?: number[] | null | undefined;
|
154
230
|
}[] | null | undefined;
|
155
231
|
retrievalMetadata?: {
|
156
232
|
webDynamicRetrievalScore: number;
|
157
233
|
} | {} | null | undefined;
|
158
234
|
}, {
|
159
235
|
webSearchQueries?: string[] | null | undefined;
|
236
|
+
retrievalQueries?: string[] | null | undefined;
|
160
237
|
searchEntryPoint?: {
|
161
238
|
renderedContent: string;
|
162
239
|
} | null | undefined;
|
240
|
+
groundingChunks?: {
|
241
|
+
web?: {
|
242
|
+
uri: string;
|
243
|
+
title: string;
|
244
|
+
} | null | undefined;
|
245
|
+
retrievedContext?: {
|
246
|
+
uri: string;
|
247
|
+
title: string;
|
248
|
+
} | null | undefined;
|
249
|
+
}[] | null | undefined;
|
163
250
|
groundingSupports?: {
|
164
251
|
segment: {
|
165
252
|
startIndex?: number | null | undefined;
|
166
253
|
endIndex?: number | null | undefined;
|
167
254
|
text?: string | null | undefined;
|
168
255
|
};
|
169
|
-
|
170
|
-
|
256
|
+
segment_text?: string | null | undefined;
|
257
|
+
groundingChunkIndices?: number[] | null | undefined;
|
258
|
+
supportChunkIndices?: number[] | null | undefined;
|
259
|
+
confidenceScores?: number[] | null | undefined;
|
260
|
+
confidenceScore?: number[] | null | undefined;
|
171
261
|
}[] | null | undefined;
|
172
262
|
retrievalMetadata?: {
|
173
263
|
webDynamicRetrievalScore: number;
|
174
264
|
} | {} | null | undefined;
|
175
265
|
}>;
|
266
|
+
declare const safetyRatingSchema: z.ZodObject<{
|
267
|
+
category: z.ZodString;
|
268
|
+
probability: z.ZodString;
|
269
|
+
probabilityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
270
|
+
severity: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
271
|
+
severityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
272
|
+
blocked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
274
|
+
category: string;
|
275
|
+
probability: string;
|
276
|
+
probabilityScore?: number | null | undefined;
|
277
|
+
severity?: string | null | undefined;
|
278
|
+
severityScore?: number | null | undefined;
|
279
|
+
blocked?: boolean | null | undefined;
|
280
|
+
}, {
|
281
|
+
category: string;
|
282
|
+
probability: string;
|
283
|
+
probabilityScore?: number | null | undefined;
|
284
|
+
severity?: string | null | undefined;
|
285
|
+
severityScore?: number | null | undefined;
|
286
|
+
blocked?: boolean | null | undefined;
|
287
|
+
}>;
|
176
288
|
|
177
289
|
type GoogleGenerativeAIGroundingMetadata = z.infer<typeof groundingMetadataSchema>;
|
290
|
+
type GoogleGenerativeAISafetyRating = z.infer<typeof safetyRatingSchema>;
|
178
291
|
interface GoogleGenerativeAIProviderMetadata {
|
179
292
|
groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
|
293
|
+
safetyRatings: GoogleGenerativeAISafetyRating[] | null;
|
180
294
|
}
|
181
295
|
|
182
296
|
export { type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
|
package/dist/index.js
CHANGED
@@ -251,13 +251,13 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
|
|
251
251
|
|
252
252
|
// src/google-prepare-tools.ts
|
253
253
|
var import_provider2 = require("@ai-sdk/provider");
|
254
|
-
function prepareTools(mode, useSearchGrounding) {
|
254
|
+
function prepareTools(mode, useSearchGrounding, isGemini2) {
|
255
255
|
var _a, _b;
|
256
256
|
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
|
257
257
|
const toolWarnings = [];
|
258
258
|
if (useSearchGrounding) {
|
259
259
|
return {
|
260
|
-
tools: { googleSearchRetrieval: {} },
|
260
|
+
tools: isGemini2 ? { googleSearch: {} } : { googleSearchRetrieval: {} },
|
261
261
|
toolConfig: void 0,
|
262
262
|
toolWarnings
|
263
263
|
};
|
@@ -398,14 +398,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
398
398
|
responseMimeType: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? "application/json" : void 0,
|
399
399
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
400
400
|
// so this is needed as an escape hatch:
|
401
|
-
this.supportsStructuredOutputs ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0
|
401
|
+
this.supportsStructuredOutputs ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
402
|
+
...this.settings.audioTimestamp && {
|
403
|
+
audioTimestamp: this.settings.audioTimestamp
|
404
|
+
}
|
402
405
|
};
|
403
406
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(prompt);
|
404
407
|
switch (type) {
|
405
408
|
case "regular": {
|
406
409
|
const { tools, toolConfig, toolWarnings } = prepareTools(
|
407
410
|
mode,
|
408
|
-
(_a = this.settings.useSearchGrounding) != null ? _a : false
|
411
|
+
(_a = this.settings.useSearchGrounding) != null ? _a : false,
|
412
|
+
this.modelId.includes("gemini-2")
|
409
413
|
);
|
410
414
|
return {
|
411
415
|
args: {
|
@@ -471,7 +475,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
471
475
|
return url.toString().startsWith("https://generativelanguage.googleapis.com/v1beta/files/");
|
472
476
|
}
|
473
477
|
async doGenerate(options) {
|
474
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
478
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
475
479
|
const { args, warnings } = await this.getArgs(options);
|
476
480
|
const body = JSON.stringify(args);
|
477
481
|
const mergedHeaders = (0, import_provider_utils3.combineHeaders)(
|
@@ -512,7 +516,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
512
516
|
warnings,
|
513
517
|
providerMetadata: {
|
514
518
|
google: {
|
515
|
-
groundingMetadata: (_g = candidate.groundingMetadata) != null ? _g : null
|
519
|
+
groundingMetadata: (_g = candidate.groundingMetadata) != null ? _g : null,
|
520
|
+
safetyRatings: (_h = candidate.safetyRatings) != null ? _h : null
|
516
521
|
}
|
517
522
|
},
|
518
523
|
request: { body }
|
@@ -549,7 +554,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
549
554
|
stream: response.pipeThrough(
|
550
555
|
new TransformStream({
|
551
556
|
transform(chunk, controller) {
|
552
|
-
var _a, _b, _c, _d;
|
557
|
+
var _a, _b, _c, _d, _e;
|
553
558
|
if (!chunk.success) {
|
554
559
|
controller.enqueue({ type: "error", error: chunk.error });
|
555
560
|
return;
|
@@ -573,7 +578,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
573
578
|
});
|
574
579
|
providerMetadata = {
|
575
580
|
google: {
|
576
|
-
groundingMetadata: (_d = candidate.groundingMetadata) != null ? _d : null
|
581
|
+
groundingMetadata: (_d = candidate.groundingMetadata) != null ? _d : null,
|
582
|
+
safetyRatings: (_e = candidate.safetyRatings) != null ? _e : null
|
577
583
|
}
|
578
584
|
};
|
579
585
|
}
|
@@ -665,9 +671,22 @@ var contentSchema = import_zod2.z.object({
|
|
665
671
|
});
|
666
672
|
var groundingMetadataSchema = import_zod2.z.object({
|
667
673
|
webSearchQueries: import_zod2.z.array(import_zod2.z.string()).nullish(),
|
674
|
+
retrievalQueries: import_zod2.z.array(import_zod2.z.string()).nullish(),
|
668
675
|
searchEntryPoint: import_zod2.z.object({
|
669
676
|
renderedContent: import_zod2.z.string()
|
670
677
|
}).nullish(),
|
678
|
+
groundingChunks: import_zod2.z.array(
|
679
|
+
import_zod2.z.object({
|
680
|
+
web: import_zod2.z.object({
|
681
|
+
uri: import_zod2.z.string(),
|
682
|
+
title: import_zod2.z.string()
|
683
|
+
}).nullish(),
|
684
|
+
retrievedContext: import_zod2.z.object({
|
685
|
+
uri: import_zod2.z.string(),
|
686
|
+
title: import_zod2.z.string()
|
687
|
+
}).nullish()
|
688
|
+
})
|
689
|
+
).nullish(),
|
671
690
|
groundingSupports: import_zod2.z.array(
|
672
691
|
import_zod2.z.object({
|
673
692
|
segment: import_zod2.z.object({
|
@@ -675,8 +694,11 @@ var groundingMetadataSchema = import_zod2.z.object({
|
|
675
694
|
endIndex: import_zod2.z.number().nullish(),
|
676
695
|
text: import_zod2.z.string().nullish()
|
677
696
|
}),
|
678
|
-
|
679
|
-
|
697
|
+
segment_text: import_zod2.z.string().nullish(),
|
698
|
+
groundingChunkIndices: import_zod2.z.array(import_zod2.z.number()).nullish(),
|
699
|
+
supportChunkIndices: import_zod2.z.array(import_zod2.z.number()).nullish(),
|
700
|
+
confidenceScores: import_zod2.z.array(import_zod2.z.number()).nullish(),
|
701
|
+
confidenceScore: import_zod2.z.array(import_zod2.z.number()).nullish()
|
680
702
|
})
|
681
703
|
).nullish(),
|
682
704
|
retrievalMetadata: import_zod2.z.union([
|
@@ -686,11 +708,20 @@ var groundingMetadataSchema = import_zod2.z.object({
|
|
686
708
|
import_zod2.z.object({})
|
687
709
|
]).nullish()
|
688
710
|
});
|
711
|
+
var safetyRatingSchema = import_zod2.z.object({
|
712
|
+
category: import_zod2.z.string(),
|
713
|
+
probability: import_zod2.z.string(),
|
714
|
+
probabilityScore: import_zod2.z.number().nullish(),
|
715
|
+
severity: import_zod2.z.string().nullish(),
|
716
|
+
severityScore: import_zod2.z.number().nullish(),
|
717
|
+
blocked: import_zod2.z.boolean().nullish()
|
718
|
+
});
|
689
719
|
var responseSchema = import_zod2.z.object({
|
690
720
|
candidates: import_zod2.z.array(
|
691
721
|
import_zod2.z.object({
|
692
722
|
content: contentSchema.nullish(),
|
693
723
|
finishReason: import_zod2.z.string().nullish(),
|
724
|
+
safetyRatings: import_zod2.z.array(safetyRatingSchema).nullish(),
|
694
725
|
groundingMetadata: groundingMetadataSchema.nullish()
|
695
726
|
})
|
696
727
|
),
|
@@ -705,6 +736,7 @@ var chunkSchema = import_zod2.z.object({
|
|
705
736
|
import_zod2.z.object({
|
706
737
|
content: contentSchema.nullish(),
|
707
738
|
finishReason: import_zod2.z.string().nullish(),
|
739
|
+
safetyRatings: import_zod2.z.array(safetyRatingSchema).nullish(),
|
708
740
|
groundingMetadata: groundingMetadataSchema.nullish()
|
709
741
|
})
|
710
742
|
).nullish(),
|