@ai-sdk/google 3.0.13 → 3.0.14
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 +7 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/15-google-generative-ai.mdx +20 -17
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
30
30
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.14" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
package/dist/index.mjs
CHANGED
|
@@ -362,7 +362,7 @@ const { text: meatLasagna, providerMetadata } = await generateText({
|
|
|
362
362
|
});
|
|
363
363
|
|
|
364
364
|
// Check cached token count in usage metadata
|
|
365
|
-
console.log('Cached tokens:', providerMetadata.google
|
|
365
|
+
console.log('Cached tokens:', providerMetadata.google);
|
|
366
366
|
// e.g.
|
|
367
367
|
// {
|
|
368
368
|
// groundingMetadata: null,
|
|
@@ -389,42 +389,45 @@ For guaranteed cost savings, you can still use explicit caching with Gemini 2.5
|
|
|
389
389
|
|
|
390
390
|
```ts
|
|
391
391
|
import { google } from '@ai-sdk/google';
|
|
392
|
-
import {
|
|
392
|
+
import { GoogleGenAI } from '@google/genai';
|
|
393
393
|
import { generateText } from 'ai';
|
|
394
394
|
|
|
395
|
-
const
|
|
396
|
-
process.env.GOOGLE_GENERATIVE_AI_API_KEY,
|
|
397
|
-
);
|
|
395
|
+
const ai = new GoogleGenAI({
|
|
396
|
+
apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY,
|
|
397
|
+
});
|
|
398
398
|
|
|
399
399
|
const model = 'gemini-2.5-pro';
|
|
400
400
|
|
|
401
|
-
|
|
401
|
+
// Create a cache with the content you want to reuse
|
|
402
|
+
const cache = await ai.caches.create({
|
|
402
403
|
model,
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
404
|
+
config: {
|
|
405
|
+
contents: [
|
|
406
|
+
{
|
|
407
|
+
role: 'user',
|
|
408
|
+
parts: [{ text: '1000 Lasagna Recipes...' }],
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
ttl: '300s', // Cache expires after 5 minutes
|
|
412
|
+
},
|
|
410
413
|
});
|
|
411
414
|
|
|
412
|
-
const { text:
|
|
415
|
+
const { text: veggieLasagnaRecipe } = await generateText({
|
|
413
416
|
model: google(model),
|
|
414
417
|
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
415
418
|
providerOptions: {
|
|
416
419
|
google: {
|
|
417
|
-
cachedContent,
|
|
420
|
+
cachedContent: cache.name,
|
|
418
421
|
},
|
|
419
422
|
},
|
|
420
423
|
});
|
|
421
424
|
|
|
422
|
-
const { text:
|
|
425
|
+
const { text: meatLasagnaRecipe } = await generateText({
|
|
423
426
|
model: google(model),
|
|
424
427
|
prompt: 'Write a meat lasagna recipe for 12 people.',
|
|
425
428
|
providerOptions: {
|
|
426
429
|
google: {
|
|
427
|
-
cachedContent,
|
|
430
|
+
cachedContent: cache.name,
|
|
428
431
|
},
|
|
429
432
|
},
|
|
430
433
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.14",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@ai-sdk/provider": "3.0.5",
|
|
40
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
40
|
+
"@ai-sdk/provider-utils": "4.0.10"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|