Skip to content

Commit edfbd5a

Browse files
author
Guiners
committed
adding samples, test, lints
1 parent 73153f6 commit edfbd5a

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

genai/content-cache/content-cache-create-with-txt-gcs-pdf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function generateContent(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
@@ -59,7 +59,7 @@ async function generateContent(
5959
},
6060
];
6161

62-
const contentCache = await ai.caches.create({
62+
const contentCache = await client.caches.create({
6363
model: 'gemini-2.5-flash',
6464
config: {
6565
contents: contents,

genai/content-cache/content-cache-delete.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function generateContent(
2525
location = GOOGLE_CLOUD_LOCATION,
2626
cacheName = 'example-cache'
2727
) {
28-
const ai = new GoogleGenAI({
28+
const client = new GoogleGenAI({
2929
vertexai: true,
3030
project: projectId,
3131
location: location,
@@ -35,7 +35,7 @@ async function generateContent(
3535
});
3636

3737
console.log('Removing cache');
38-
const contentCache = await ai.caches.delete({
38+
const contentCache = await client.caches.delete({
3939
name: cacheName,
4040
});
4141

genai/content-cache/content-cache-list.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function generateContent(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
@@ -33,7 +33,7 @@ async function generateContent(
3333
},
3434
});
3535

36-
const contentCacheList = await ai.caches.list();
36+
const contentCacheList = await client.caches.list();
3737

3838
// Access individual properties of a ContentCache object(s)
3939
const contentCacheNames = [];

genai/content-cache/content-cache-update.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function generateContent(
2626
location = GOOGLE_CLOUD_LOCATION,
2727
cacheName = 'example-cache'
2828
) {
29-
const ai = new GoogleGenAI({
29+
const client = new GoogleGenAI({
3030
vertexai: true,
3131
project: projectId,
3232
location: location,
@@ -35,13 +35,13 @@ async function generateContent(
3535
},
3636
});
3737

38-
let contentCache = await ai.caches.get({
38+
let contentCache = await client.caches.get({
3939
name: cacheName,
4040
});
4141

4242
console.log('Expire time', contentCache.expireTime);
4343

44-
contentCache = await ai.caches.update({
44+
contentCache = await client.caches.update({
4545
name: cacheName,
4646
config: {
4747
ttl: '36000s',
@@ -58,7 +58,7 @@ async function generateContent(
5858
const nextWeekUtc = DateTime.utc().plus({days: 7});
5959
console.log('Next week (UTC):', nextWeekUtc.toISO());
6060

61-
contentCache = await ai.caches.update({
61+
contentCache = await client.caches.update({
6262
name: cacheName,
6363
config: {
6464
expireTime: nextWeekUtc,

genai/content-cache/content-cache-use-with-txt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function generateContent(
2626
location = GOOGLE_CLOUD_LOCATION,
2727
cacheName = 'example-cache'
2828
) {
29-
const ai = new GoogleGenAI({
29+
const client = new GoogleGenAI({
3030
vertexai: true,
3131
project: projectId,
3232
location: location,
@@ -35,7 +35,7 @@ async function generateContent(
3535
},
3636
});
3737

38-
const response = await ai.models.generateContent({
38+
const response = await client.models.generateContent({
3939
model: 'gemini-2.5-flash',
4040
contents: 'Summarize the pdfs',
4141
config: {

0 commit comments

Comments
 (0)