Caching

การแคชบริบทช่วยให้คุณบันทึกและนําโทเค็นอินพุตที่ประมวลผลล่วงหน้าซึ่งต้องการใช้ซ้ำมาใช้ซ้ำได้ เช่น เมื่อถามคําถามต่างๆ เกี่ยวกับไฟล์สื่อเดียวกัน ซึ่งอาจช่วยประหยัดค่าใช้จ่ายและเวลาได้ ทั้งนี้ขึ้นอยู่กับการใช้งาน ดูข้อมูลเบื้องต้นโดยละเอียดได้ในคู่มือการแคชบริบท

เมธอด: cachedContents.create

สร้างทรัพยากร CachedContent

ปลายทาง

โพสต์ https://generativelanguage.googleapis.com/v1beta/cachedContents

เนื้อหาของคำขอ

เนื้อความของคำขอมีอินสแตนซ์ของ CachedContent

ฟิลด์
contents[] object (Content)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ เนื้อหาที่จะแคช

tools[] object (Tool)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ รายการ Tools ที่โมเดลอาจใช้เพื่อสร้างคำตอบถัดไป

expiration Union type
ระบุเวลาที่ทรัพยากรนี้จะหมดอายุ expiration ต้องเป็นค่าใดค่าหนึ่งต่อไปนี้เท่านั้น
expireTime string (Timestamp format)

การประทับเวลาใน UTC ของเวลาที่ถือว่าทรัพยากรนี้หมดอายุ ข้อมูลนี้จะแสดงในเอาต์พุตเสมอ ไม่ว่าจะส่งข้อมูลใดในอินพุตก็ตาม

ใช้ RFC 3339 ซึ่งเอาต์พุตที่สร้างขึ้นจะเป็นรูปแบบ Z-normalized เสมอ และใช้ตัวเลขทศนิยม 0, 3, 6 หรือ 9 ระบบยังยอมรับออฟเซตอื่นๆ นอกเหนือจาก "Z" ด้วย ตัวอย่างเช่น "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" หรือ "2014-10-02T15:01:23+05:30"

ttl string (Duration format)

อินพุตเท่านั้น TTL ใหม่สำหรับทรัพยากรนี้ โปรดป้อนเท่านั้น

ระยะเวลาเป็นวินาทีที่มีเศษทศนิยมได้สูงสุด 9 หลัก โดยลงท้ายด้วย s เช่น "3.5s"

name string

ไม่บังคับ ตัวระบุ ชื่อทรัพยากรที่อ้างอิงถึงเนื้อหาที่แคชไว้ รูปแบบ: cachedContents/{id}

displayName string

ไม่บังคับ เปลี่ยนแปลงไม่ได้ ชื่อที่แสดงที่สื่อความหมายซึ่งผู้ใช้สร้างขึ้นสำหรับเนื้อหาที่แคชไว้ อักขระ Unicode สูงสุด 128 ตัว

model string

ต้องระบุ เปลี่ยนแปลงไม่ได้ ชื่อ Model ที่จะใช้สําหรับรูปแบบเนื้อหาที่แคชไว้: models/{model}

systemInstruction object (Content)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ วิธีการตั้งค่าระบบสำหรับนักพัฒนาแอป ปัจจุบันมีเฉพาะข้อความเท่านั้น

toolConfig object (ToolConfig)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ การกําหนดค่าเครื่องมือ การกำหนดค่านี้จะแชร์กับเครื่องมือทั้งหมด

ตัวอย่างคำขอ

พื้นฐาน

Python

# With Gemini-2 we're launching a new SDK, see this doc for details.
# https://ai.google.dev/gemini-api/docs/migrate

Node.js

// Make sure to include these imports:
// import { GoogleAICacheManager, GoogleAIFileManager } from "@google/generative-ai/server";
// import { GoogleGenerativeAI } from "@google/generative-ai";
const cacheManager = new GoogleAICacheManager(process.env.API_KEY);
const fileManager = new GoogleAIFileManager(process.env.API_KEY);

const uploadResult = await fileManager.uploadFile(`${mediaPath}/a11.txt`, {
  mimeType: "text/plain",
});

const cacheResult = await cacheManager.create({
  model: "models/gemini-1.5-flash-001",
  contents: [
    {
      role: "user",
      parts: [
        {
          fileData: {
            fileUri: uploadResult.file.uri,
            mimeType: uploadResult.file.mimeType,
          },
        },
      ],
    },
  ],
});

console.log(cacheResult);

const genAI = new GoogleGenerativeAI(process.env.API_KEY);
const model = genAI.getGenerativeModelFromCachedContent(cacheResult);
const result = await model.generateContent(
  "Please summarize this transcript.",
);
console.log(result.response.text());

Go

file, err := client.UploadFileFromPath(ctx,
	filepath.Join(testDataDir, "a11.txt"),
	&genai.UploadFileOptions{MIMEType: "text/plain"})
if err != nil {
	log.Fatal(err)
}
defer client.DeleteFile(ctx, file.Name)
fd := genai.FileData{URI: file.URI}

argcc := &genai.CachedContent{
	Model:             "gemini-1.5-flash-001",
	SystemInstruction: genai.NewUserContent(genai.Text("You are an expert analyzing transcripts.")),
	Contents:          []*genai.Content{genai.NewUserContent(fd)},
}
cc, err := client.CreateCachedContent(ctx, argcc)
if err != nil {
	log.Fatal(err)
}
defer client.DeleteCachedContent(ctx, cc.Name)

modelWithCache := client.GenerativeModelFromCachedContent(cc)
prompt := "Please summarize this transcript"
resp, err := modelWithCache.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
	log.Fatal(err)
}

printResponse(resp)

เปลือกหอย

wget https://storage.googleapis.com/generativeai-downloads/data/a11.txt
echo '{
  "model": "models/gemini-1.5-flash-001",
  "contents":[
    {
      "parts":[
        {
          "inline_data": {
            "mime_type":"text/plain",
            "data": "'$(base64 $B64FLAGS a11.txt)'"
          }
        }
      ],
    "role": "user"
    }
  ],
  "systemInstruction": {
    "parts": [
      {
        "text": "You are an expert at analyzing transcripts."
      }
    ]
  },
  "ttl": "300s"
}' > request.json

curl -X POST "https://generativelanguage.googleapis.com/v1beta/cachedContents?key=$GOOGLE_API_KEY" \
 -H 'Content-Type: application/json' \
 -d @request.json \
 > cache.json

CACHE_NAME=$(cat cache.json | grep '"name":' | cut -d '"' -f 4 | head -n 1)

curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-001:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
      "contents": [
        {
          "parts":[{
            "text": "Please summarize this transcript"
          }],
          "role": "user"
        },
      ],
      "cachedContent": "'$CACHE_NAME'"
    }'

จากชื่อ

Python

# With Gemini-2 we're launching a new SDK, see this doc for details.
# https://ai.google.dev/gemini-api/docs/migrate

Node.js

// Make sure to include these imports:
// import { GoogleAICacheManager, GoogleAIFileManager } from "@google/generative-ai/server";
// import { GoogleGenerativeAI } from "@google/generative-ai";
const cacheManager = new GoogleAICacheManager(process.env.API_KEY);
const fileManager = new GoogleAIFileManager(process.env.API_KEY);

const uploadResult = await fileManager.uploadFile(`${mediaPath}/a11.txt`, {
  mimeType: "text/plain",
});

const cacheResult = await cacheManager.create({
  model: "models/gemini-1.5-flash-001",
  contents: [
    {
      role: "user",
      parts: [
        {
          fileData: {
            fileUri: uploadResult.file.uri,
            mimeType: uploadResult.file.mimeType,
          },
        },
      ],
    },
  ],
});
const cacheName = cacheResult.name; // Save the name for later.

// Later
const getCacheResult = await cacheManager.get(cacheName);
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
const model = genAI.getGenerativeModelFromCachedContent(getCacheResult);
model.generateContent("Please summarize this transcript.");

Go

file, err := client.UploadFileFromPath(ctx, filepath.Join(testDataDir, "a11.txt"), nil)
if err != nil {
	log.Fatal(err)
}
defer client.DeleteFile(ctx, file.Name)
fd := genai.FileData{URI: file.URI}

argcc := &genai.CachedContent{
	Model:             "gemini-1.5-flash-001",
	SystemInstruction: genai.NewUserContent(genai.Text("You are an expert analyzing transcripts.")),
	Contents:          []*genai.Content{genai.NewUserContent(fd)},
}
cc, err := client.CreateCachedContent(ctx, argcc)
if err != nil {
	log.Fatal(err)
}
defer client.DeleteCachedContent(ctx, cc.Name)

// Save the name for later
cacheName := cc.Name

// ... Later
cc2, err := client.GetCachedContent(ctx, cacheName)
if err != nil {
	log.Fatal(err)
}
modelWithCache := client.GenerativeModelFromCachedContent(cc2)
prompt := "Find a lighthearted moment from this transcript"
resp, err := modelWithCache.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
	log.Fatal(err)
}

printResponse(resp)

จากแชท

Python

# With Gemini-2 we're launching a new SDK, see this doc for details.
# https://ai.google.dev/gemini-api/docs/migrate

Node.js

// Make sure to include these imports:
// import { GoogleGenerativeAI } from "@google/generative-ai";
// import { GoogleAICacheManager, GoogleAIFileManager } from "@google/generative-ai/server";
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
const cacheManager = new GoogleAICacheManager(process.env.API_KEY);
const fileManager = new GoogleAIFileManager(process.env.API_KEY);

const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-001" });
const chat = model.startChat();

const uploadResult = await fileManager.uploadFile(`${mediaPath}/a11.txt`, {
  mimeType: "text/plain",
});

let result = await chat.sendMessage([
  "Hi, could you summarize this transcript?",
  {
    fileData: {
      fileUri: uploadResult.file.uri,
      mimeType: uploadResult.file.mimeType,
    },
  },
]);
console.log(`\n\nmodel: ${result.response.text()}`);
result = await chat.sendMessage(
  "Okay, could you tell me more about the trans-lunar injection",
);
console.log(`\n\nmodel: ${result.response.text()}`);

const cacheResult = await cacheManager.create({
  model: "models/gemini-1.5-flash-001",
  contents: await chat.getHistory(),
});

const newModel = genAI.getGenerativeModelFromCachedContent(cacheResult);

const newChat = newModel.startChat();
result = await newChat.sendMessage(
  "I didn't understand that last part, could you explain it in simpler language?",
);
console.log(`\n\nmodel: ${result.response.text()}`);

Go

file, err := client.UploadFileFromPath(ctx, filepath.Join(testDataDir, "a11.txt"), nil)
if err != nil {
	log.Fatal(err)
}
defer client.DeleteFile(ctx, file.Name)
fd := genai.FileData{URI: file.URI}

modelName := "gemini-1.5-flash-001"
model := client.GenerativeModel(modelName)
model.SystemInstruction = genai.NewUserContent(genai.Text("You are an expert analyzing transcripts."))

cs := model.StartChat()
resp, err := cs.SendMessage(ctx, genai.Text("Hi, could you summarize this transcript?"), fd)
if err != nil {
	log.Fatal(err)
}

resp, err = cs.SendMessage(ctx, genai.Text("Okay, could you tell me more about the trans-lunar injection"))
if err != nil {
	log.Fatal(err)
}

// To cache the conversation so far, pass the chat history as the list of
// contents.

argcc := &genai.CachedContent{
	Model:             modelName,
	SystemInstruction: model.SystemInstruction,
	Contents:          cs.History,
}
cc, err := client.CreateCachedContent(ctx, argcc)
if err != nil {
	log.Fatal(err)
}
defer client.DeleteCachedContent(ctx, cc.Name)

modelWithCache := client.GenerativeModelFromCachedContent(cc)
cs = modelWithCache.StartChat()
resp, err = cs.SendMessage(ctx, genai.Text("I didn't understand that last part, could you please explain it in simpler language?"))
if err != nil {
	log.Fatal(err)
}
printResponse(resp)

เนื้อหาการตอบกลับ

หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ CachedContent ที่สร้างขึ้นใหม่

เมธอด: cachedContents.list

แสดงรายการ CachedContents

ปลายทาง

get https://generativelanguage.googleapis.com/v1beta/cachedContents

พารามิเตอร์การค้นหา

pageSize integer

ไม่บังคับ จำนวนเนื้อหาที่แคชไว้สูงสุดที่จะแสดง บริการอาจแสดงผลน้อยกว่าค่านี้ หากไม่ระบุ ระบบจะแสดงผลจำนวนรายการเริ่มต้น (ต่ำกว่าจำนวนสูงสุด) ค่าสูงสุดคือ 1,000 ระบบจะบังคับให้ค่าที่มากกว่า 1,000 เป็น 1,000

pageToken string

ไม่บังคับ โทเค็นหน้าเว็บที่ได้รับจากการเรียกใช้ cachedContents.list ก่อนหน้านี้ ระบุข้อมูลนี้เพื่อเรียกข้อมูลหน้าถัดไป

เมื่อแบ่งหน้าเว็บ พารามิเตอร์อื่นๆ ทั้งหมดที่ระบุให้กับ cachedContents.list ต้องตรงกับการเรียกที่ให้โทเค็นหน้าเว็บ

เนื้อหาของคำขอ

เนื้อหาของคำขอต้องว่างเปล่า

เนื้อหาการตอบกลับ

การตอบกลับพร้อมรายการ CachedContents

หากทำสำเร็จ เนื้อหาการตอบกลับจะมีข้อมูลซึ่งมีโครงสร้างดังต่อไปนี้

ฟิลด์
cachedContents[] object (CachedContent)

รายการเนื้อหาที่แคชไว้

nextPageToken string

โทเค็น ซึ่งสามารถส่งเป็น pageToken เพื่อเรียกข้อมูลหน้าถัดไป หากละเว้นช่องนี้ จะไม่มีหน้าถัดไป

การแสดง JSON
{
  "cachedContents": [
    {
      object (CachedContent)
    }
  ],
  "nextPageToken": string
}

เมธอด: cachedContents.get

อ่านทรัพยากร CachedContent

ปลายทาง

get https://generativelanguage.googleapis.com/v1beta/{name=cachedContents/*}

พารามิเตอร์เส้นทาง

name string

ต้องระบุ ชื่อทรัพยากรที่อ้างอิงถึงรายการแคชเนื้อหา รูปแบบ: cachedContents/{id} อยู่ในรูปแบบ cachedContents/{cachedcontent}

เนื้อหาของคำขอ

เนื้อหาของคำขอต้องว่างเปล่า

ตัวอย่างคำขอ

Python

# With Gemini-2 we're launching a new SDK, see this doc for details.
# https://ai.google.dev/gemini-api/docs/migrate

Node.js

// Make sure to include these imports:
// import { GoogleAICacheManager, GoogleAIFileManager } from "@google/generative-ai/server";
const cacheManager = new GoogleAICacheManager(process.env.API_KEY);
const fileManager = new GoogleAIFileManager(process.env.API_KEY);

const uploadResult = await fileManager.uploadFile(`${mediaPath}/a11.txt`, {
  mimeType: "text/plain",
});

const cacheResult = await cacheManager.create({
  model: "models/gemini-1.5-flash-001",
  contents: [
    {
      role: "user",
      parts: [
        {
          fileData: {
            fileUri: uploadResult.file.uri,
            mimeType: uploadResult.file.mimeType,
          },
        },
      ],
    },
  ],
});
const cacheGetResult = await cacheManager.get(cacheResult.name);
console.log(cacheGetResult);

Go

file, err := client.UploadFileFromPath(ctx, filepath.Join(testDataDir, "a11.txt"), nil)
if err != nil {
	log.Fatal(err)
}
defer client.DeleteFile(ctx, file.Name)
fd := genai.FileData{URI: file.URI}

argcc := &genai.CachedContent{
	Model:             "gemini-1.5-flash-001",
	SystemInstruction: genai.NewUserContent(genai.Text("You are an expert analyzing transcripts.")),
	Contents:          []*genai.Content{genai.NewUserContent(fd)},
}
cc, err := client.CreateCachedContent(ctx, argcc)
if err != nil {
	log.Fatal(err)
}
defer client.DeleteCachedContent(ctx, cc.Name)

// Save the name for later
cacheName := cc.Name

// ... Later
cc2, err := client.GetCachedContent(ctx, cacheName)
if err != nil {
	log.Fatal(err)
}
modelWithCache := client.GenerativeModelFromCachedContent(cc2)
prompt := "Find a lighthearted moment from this transcript"
resp, err := modelWithCache.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
	log.Fatal(err)
}

printResponse(resp)

เปลือกหอย

curl "https://generativelanguage.googleapis.com/v1beta/$CACHE_NAME?key=$GOOGLE_API_KEY"

เนื้อหาการตอบกลับ

หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ CachedContent

เมธอด: cachedContents.patch

อัปเดตทรัพยากร CachedContent (อัปเดตได้เฉพาะวันหมดอายุ)

ปลายทาง

patch https://generativelanguage.googleapis.com/v1beta/{cachedContent.name=cachedContents/*}

PATCH https://generativelanguage.googleapis.com/v1beta/{cachedContent.name=cachedContents/*}

พารามิเตอร์เส้นทาง

cachedContent.name string

ไม่บังคับ ตัวระบุ ชื่อทรัพยากรที่อ้างอิงถึงเนื้อหาที่แคชไว้ รูปแบบ: cachedContents/{id} อยู่ในรูปแบบ cachedContents/{cachedcontent}

พารามิเตอร์การค้นหา

updateMask string (FieldMask format)

รายการช่องที่จะอัปเดต

ซึ่งเป็นรายการชื่อฟิลด์ที่สมบูรณ์ในตัวเองที่คั่นด้วยคอมมา ตัวอย่าง: "user.displayName,photo"

เนื้อหาของคำขอ

เนื้อความของคำขอมีอินสแตนซ์ของ CachedContent

ช่อง
expiration Union type
ระบุเวลาที่ทรัพยากรนี้จะหมดอายุ expiration ต้องเป็นค่าใดค่าหนึ่งต่อไปนี้เท่านั้น
expireTime string (Timestamp format)

การประทับเวลาใน UTC ของเวลาที่ถือว่าทรัพยากรนี้หมดอายุ ข้อมูลนี้จะแสดงในเอาต์พุตเสมอ ไม่ว่าจะส่งข้อมูลใดในอินพุตก็ตาม

ใช้ RFC 3339 ซึ่งเอาต์พุตที่สร้างขึ้นจะเป็นรูปแบบ Z-normalized เสมอ และใช้ตัวเลขทศนิยม 0, 3, 6 หรือ 9 ระบบยังยอมรับออฟเซตอื่นๆ นอกเหนือจาก "Z" ด้วย ตัวอย่างเช่น "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" หรือ "2014-10-02T15:01:23+05:30"

ttl string (Duration format)

อินพุตเท่านั้น TTL ใหม่สำหรับทรัพยากรนี้ โปรดป้อนเท่านั้น

ระยะเวลาเป็นวินาทีที่มีเศษทศนิยมได้สูงสุด 9 หลัก โดยลงท้ายด้วย s เช่น "3.5s"

name string

ไม่บังคับ ตัวระบุ ชื่อทรัพยากรที่อ้างอิงถึงเนื้อหาที่แคชไว้ รูปแบบ: cachedContents/{id}

ตัวอย่างคำขอ

Python

# With Gemini-2 we're launching a new SDK, see this doc for details.
# https://ai.google.dev/gemini-api/docs/migrate

Node.js

// Make sure to include these imports:
// import { GoogleAICacheManager, GoogleAIFileManager } from "@google/generative-ai/server";
const cacheManager = new GoogleAICacheManager(process.env.API_KEY);
const fileManager = new GoogleAIFileManager(process.env.API_KEY);

const uploadResult = await fileManager.uploadFile(`${mediaPath}/a11.txt`, {
  mimeType: "text/plain",
});

const cacheResult = await cacheManager.create({
  model: "models/gemini-1.5-flash-001",
  contents: [
    {
      role: "user",
      parts: [
        {
          fileData: {
            fileUri: uploadResult.file.uri,
            mimeType: uploadResult.file.mimeType,
          },
        },
      ],
    },
  ],
});
console.log("initial cache data:", cacheResult);
const cacheUpdateResult = await cacheManager.update(cacheResult.name, {
  cachedContent: {
    // 2 hours
    ttlSeconds: 60 * 60 * 2,
  },
});
console.log("updated cache data:", cacheUpdateResult);

Go

file, err := client.UploadFileFromPath(ctx,
	filepath.Join(testDataDir, "a11.txt"),
	&genai.UploadFileOptions{MIMEType: "text/plain"})
if err != nil {
	log.Fatal(err)
}
defer client.DeleteFile(ctx, file.Name)

เปลือกหอย

curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/$CACHE_NAME?key=$GOOGLE_API_KEY" \
 -H 'Content-Type: application/json' \
 -d '{"ttl": "600s"}'

เนื้อหาการตอบกลับ

หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ CachedContent

วิธีการ: cachedContents.delete

ลบทรัพยากร CachedContent

ปลายทาง

ลบ https://generativelanguage.googleapis.com/v1beta/{name=cachedContents/*}

พารามิเตอร์เส้นทาง

name string

ต้องระบุ ชื่อทรัพยากรที่อ้างอิงถึงรูปแบบรายการแคชเนื้อหา: cachedContents/{id} รูปแบบคือ cachedContents/{cachedcontent}

เนื้อหาของคำขอ

เนื้อหาของคำขอต้องว่างเปล่า

ตัวอย่างคำขอ

Python

# With Gemini-2 we're launching a new SDK, see this doc for details.
# https://ai.google.dev/gemini-api/docs/migrate

Node.js

// Make sure to include these imports:
// import { GoogleAICacheManager, GoogleAIFileManager } from "@google/generative-ai/server";
const cacheManager = new GoogleAICacheManager(process.env.API_KEY);
const fileManager = new GoogleAIFileManager(process.env.API_KEY);

const uploadResult = await fileManager.uploadFile(`${mediaPath}/a11.txt`, {
  mimeType: "text/plain",
});

const cacheResult = await cacheManager.create({
  model: "models/gemini-1.5-flash-001",
  contents: [
    {
      role: "user",
      parts: [
        {
          fileData: {
            fileUri: uploadResult.file.uri,
            mimeType: uploadResult.file.mimeType,
          },
        },
      ],
    },
  ],
});
await cacheManager.delete(cacheResult.name);

Go

file, err := client.UploadFileFromPath(ctx,
	filepath.Join(testDataDir, "a11.txt"),
	&genai.UploadFileOptions{MIMEType: "text/plain"})
if err != nil {
	log.Fatal(err)
}
defer client.DeleteFile(ctx, file.Name)

เปลือกหอย

curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/$CACHE_NAME?key=$GOOGLE_API_KEY"

เนื้อหาการตอบกลับ

หากทำสำเร็จ เนื้อหาการตอบกลับจะเป็นออบเจ็กต์ JSON ว่าง

ทรัพยากร REST: cachedContents

ทรัพยากร: CachedContent

เนื้อหาที่ประมวลผลล่วงหน้าแล้วและสามารถใช้ในคำขอที่ส่งไปยัง GenerativeService ในภายหลัง

เนื้อหาที่แคชไว้จะใช้ได้กับโมเดลที่สร้างไว้เท่านั้น

ฟิลด์
contents[] object (Content)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ เนื้อหาที่จะแคช

tools[] object (Tool)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ รายการ Tools ที่โมเดลอาจใช้เพื่อสร้างคำตอบถัดไป

createTime string (Timestamp format)

เอาต์พุตเท่านั้น เวลาสร้างรายการแคช

ใช้ RFC 3339 ซึ่งเอาต์พุตที่สร้างขึ้นจะเป็นรูปแบบ Z-normalized เสมอ และใช้ตัวเลขทศนิยม 0, 3, 6 หรือ 9 ระบบยังยอมรับออฟเซตอื่นๆ นอกเหนือจาก "Z" ด้วย ตัวอย่างเช่น "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" หรือ "2014-10-02T15:01:23+05:30"

updateTime string (Timestamp format)

เอาต์พุตเท่านั้น เวลาอัปเดตรายการแคชครั้งล่าสุดตามเขตเวลา UTC

ใช้ RFC 3339 ซึ่งเอาต์พุตที่สร้างขึ้นจะเป็นรูปแบบ Z-normalized เสมอ และใช้ตัวเลขทศนิยม 0, 3, 6 หรือ 9 ระบบยังยอมรับออฟเซตอื่นๆ นอกเหนือจาก "Z" ด้วย ตัวอย่างเช่น "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" หรือ "2014-10-02T15:01:23+05:30"

usageMetadata object (UsageMetadata)

เอาต์พุตเท่านั้น ข้อมูลเมตาเกี่ยวกับการใช้เนื้อหาที่แคชไว้

expiration Union type
ระบุเวลาที่ทรัพยากรนี้จะหมดอายุ expiration ต้องเป็นค่าใดค่าหนึ่งต่อไปนี้เท่านั้น
expireTime string (Timestamp format)

การประทับเวลาใน UTC ของเวลาที่ถือว่าทรัพยากรนี้หมดอายุ ข้อมูลนี้จะแสดงในเอาต์พุตเสมอ ไม่ว่าจะส่งข้อมูลใดในอินพุตก็ตาม

ใช้ RFC 3339 ซึ่งเอาต์พุตที่สร้างขึ้นจะเป็นรูปแบบ Z-normalized เสมอ และใช้ตัวเลขทศนิยม 0, 3, 6 หรือ 9 ระบบยังยอมรับออฟเซตอื่นๆ นอกเหนือจาก "Z" ด้วย ตัวอย่างเช่น "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" หรือ "2014-10-02T15:01:23+05:30"

ttl string (Duration format)

อินพุตเท่านั้น TTL ใหม่สำหรับทรัพยากรนี้ โปรดป้อนเท่านั้น

ระยะเวลาเป็นวินาทีที่มีเศษทศนิยมได้สูงสุด 9 หลัก โดยลงท้ายด้วย s เช่น "3.5s"

name string

ไม่บังคับ ตัวระบุ ชื่อทรัพยากรที่อ้างอิงถึงเนื้อหาที่แคชไว้ รูปแบบ: cachedContents/{id}

displayName string

ไม่บังคับ เปลี่ยนแปลงไม่ได้ ชื่อที่แสดงที่สื่อความหมายซึ่งผู้ใช้สร้างขึ้นสำหรับเนื้อหาที่แคชไว้ อักขระ Unicode สูงสุด 128 ตัว

model string

ต้องระบุ เปลี่ยนแปลงไม่ได้ ชื่อ Model ที่จะใช้สําหรับรูปแบบเนื้อหาที่แคชไว้: models/{model}

systemInstruction object (Content)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ วิธีการตั้งค่าระบบสำหรับนักพัฒนาแอป ปัจจุบันมีเฉพาะข้อความเท่านั้น

toolConfig object (ToolConfig)

ไม่บังคับ อินพุตเท่านั้น เปลี่ยนแปลงไม่ได้ การกําหนดค่าเครื่องมือ การกำหนดค่านี้จะแชร์กับเครื่องมือทั้งหมด

การแสดง JSON
{
  "contents": [
    {
      object (Content)
    }
  ],
  "tools": [
    {
      object (Tool)
    }
  ],
  "createTime": string,
  "updateTime": string,
  "usageMetadata": {
    object (UsageMetadata)
  },

  // expiration
  "expireTime": string,
  "ttl": string
  // Union type
  "name": string,
  "displayName": string,
  "model": string,
  "systemInstruction": {
    object (Content)
  },
  "toolConfig": {
    object (ToolConfig)
  }
}

เนื้อหา

ประเภท Structured Data พื้นฐานที่มีเนื้อหาหลายส่วนของข้อความ

Content มีช่อง role ที่ระบุผู้ผลิต Content และช่อง parts ที่มีข้อมูลหลายส่วนซึ่งมีเนื้อหาของการเปลี่ยนข้อความ

ฟิลด์
parts[] object (Part)

Parts ที่มีลําดับซึ่งประกอบกันเป็นข้อความเดียว ชิ้นส่วนต่างๆ อาจมีประเภท MIME แตกต่างกัน

role string

ไม่บังคับ ผู้สร้างเนื้อหา ต้องเป็น "user" หรือ "model"

มีประโยชน์สำหรับการตั้งค่าการสนทนาแบบหลายรอบ หรือจะเว้นว่างไว้หรือไม่ตั้งค่าก็ได้

การแสดง JSON
{
  "parts": [
    {
      object (Part)
    }
  ],
  "role": string
}

ส่วน

ประเภทข้อมูลที่มีสื่อซึ่งเป็นส่วนหนึ่งของข้อความ Content ที่มีหลายส่วน

Part ประกอบด้วยข้อมูลที่มีค่าประเภทข้อมูลที่เกี่ยวข้อง Part ต้องมีประเภทที่ยอมรับใน Part.data เพียงประเภทเดียวเท่านั้น

Part ต้องมีประเภท MIME ของ IANA แบบคงที่ซึ่งระบุประเภทและประเภทย่อยของสื่อ หากช่อง inlineData เต็มไปด้วยไบต์ดิบ

ช่อง
data Union type
data ต้องเป็นค่าใดค่าหนึ่งต่อไปนี้เท่านั้น
text string

ข้อความในบรรทัด

inlineData object (Blob)

ไบต์ของสื่อในบรรทัด

functionCall object (FunctionCall)

FunctionCall ที่คาดการณ์ซึ่งแสดงผลจากโมเดลซึ่งมีสตริงที่แสดงถึง FunctionDeclaration.name พร้อมอาร์กิวเมนต์และค่าของอาร์กิวเมนต์

functionResponse object (FunctionResponse)

ระบบจะใช้เอาต์พุตผลลัพธ์ของ FunctionCall ที่มีสตริงแสดงถึง FunctionDeclaration.name และออบเจ็กต์ JSON ที่มีโครงสร้างซึ่งมีเอาต์พุตจากฟังก์ชันเป็นบริบทของโมเดล

fileData object (FileData)

ข้อมูลตาม URI

executableCode object (ExecutableCode)

โค้ดที่โมเดลสร้างขึ้นเพื่อเรียกใช้

codeExecutionResult object (CodeExecutionResult)

ผลลัพธ์ของการดำเนินการ ExecutableCode

การแสดง JSON
{

  // data
  "text": string,
  "inlineData": {
    object (Blob)
  },
  "functionCall": {
    object (FunctionCall)
  },
  "functionResponse": {
    object (FunctionResponse)
  },
  "fileData": {
    object (FileData)
  },
  "executableCode": {
    object (ExecutableCode)
  },
  "codeExecutionResult": {
    object (CodeExecutionResult)
  }
  // Union type
}

Blob

ไบต์ของสื่อดิบ

ไม่ควรส่งข้อความเป็นไบต์ดิบ ให้ใช้ฟิลด์ "text"

ฟิลด์
mimeType string

ประเภท MIME มาตรฐาน IANA ของข้อมูลต้นทาง ตัวอย่างเช่น - image/png - image/jpeg หากระบุประเภท MIME ที่ระบบไม่รองรับ ระบบจะแสดงข้อผิดพลาด โปรดดูรายการประเภททั้งหมดที่รองรับที่หัวข้อรูปแบบไฟล์ที่รองรับ

data string (bytes format)

ไบต์ดิบสำหรับรูปแบบสื่อ

สตริงที่เข้ารหัส Base64

การแสดง JSON
{
  "mimeType": string,
  "data": string
}

FunctionCall

FunctionCall ที่คาดการณ์ซึ่งแสดงผลจากโมเดลซึ่งมีสตริงที่แสดงถึง FunctionDeclaration.name พร้อมอาร์กิวเมนต์และค่าของอาร์กิวเมนต์

ฟิลด์
id string

ไม่บังคับ รหัสที่ไม่ซ้ำกันของคําเรียกฟังก์ชัน หากป้อนข้อมูลแล้ว ลูกค้าจะเรียกใช้ functionCall และแสดงผลลัพธ์ที่มี id ที่ตรงกัน

name string

ต้องระบุ ชื่อของฟังก์ชันที่จะเรียกใช้ ต้องประกอบด้วย a-z, A-Z, 0-9 หรือมีขีดล่างและขีดกลาง โดยมีความยาวสูงสุด 63

args object (Struct format)

ไม่บังคับ พารามิเตอร์และค่าของฟังก์ชันในรูปแบบออบเจ็กต์ JSON

การแสดง JSON
{
  "id": string,
  "name": string,
  "args": {
    object
  }
}

FunctionResponse

ระบบจะใช้เอาต์พุตผลลัพธ์จาก FunctionCall ที่มีสตริงแสดงถึง FunctionDeclaration.name และออบเจ็กต์ JSON ที่มีโครงสร้างซึ่งมีเอาต์พุตจากฟังก์ชันเป็นบริบทของโมเดล ซึ่งควรมีผลการค้นหาFunctionCallที่สร้างขึ้นตามการคาดการณ์ของโมเดล

ฟิลด์
id string

ไม่บังคับ รหัสของการเรียกฟังก์ชันที่คำตอบนี้ใช้ ไคลเอ็นต์เป็นผู้ป้อนข้อมูลเพื่อจับคู่กับคําเรียกฟังก์ชัน id ที่เกี่ยวข้อง

name string

ต้องระบุ ชื่อของฟังก์ชันที่จะเรียกใช้ ต้องประกอบด้วย a-z, A-Z, 0-9 หรือมีขีดล่างและขีดกลาง โดยมีความยาวสูงสุด 63

response object (Struct format)

ต้องระบุ การตอบกลับของฟังก์ชันในรูปแบบออบเจ็กต์ JSON

การแสดง JSON
{
  "id": string,
  "name": string,
  "response": {
    object
  }
}

FileData

ข้อมูลตาม URI

ฟิลด์
mimeType string

ไม่บังคับ ประเภท MIME มาตรฐาน IANA ของข้อมูลต้นทาง

fileUri string

ต้องระบุ URI

การแสดง JSON
{
  "mimeType": string,
  "fileUri": string
}

ExecutableCode

โค้ดที่โมเดลสร้างขึ้นซึ่งมีไว้เพื่อเรียกใช้ และผลลัพธ์ที่ส่งกลับไปยังโมเดล

สร้างขึ้นเมื่อใช้เครื่องมือ CodeExecution เท่านั้น ซึ่งระบบจะเรียกใช้โค้ดโดยอัตโนมัติและสร้าง CodeExecutionResult ที่เกี่ยวข้องด้วย

ฟิลด์
language enum (Language)

ต้องระบุ ภาษาโปรแกรมของ code

code string

ต้องระบุ โค้ดที่จะเรียกใช้

การแสดง JSON
{
  "language": enum (Language),
  "code": string
}

ภาษา

ภาษาโปรแกรมที่รองรับสําหรับโค้ดที่สร้างขึ้น

Enum
LANGUAGE_UNSPECIFIED ไม่ได้ระบุภาษา ไม่ควรใช้ค่านี้
PYTHON Python >= 3.10 ที่มี numpy และ simpy

CodeExecutionResult

ผลลัพธ์ของการดำเนินการ ExecutableCode

สร้างขึ้นเมื่อใช้ CodeExecution เท่านั้น และจะตามหลัง part ที่มี ExecutableCode เสมอ

ฟิลด์
outcome enum (Outcome)

ต้องระบุ ผลลัพธ์ของการเรียกใช้โค้ด

output string

ไม่บังคับ มี stdout เมื่อการเรียกใช้โค้ดสำเร็จ stderr หรือคำอธิบายอื่นๆ หากไม่สำเร็จ

การแสดง JSON
{
  "outcome": enum (Outcome),
  "output": string
}

ผลลัพธ์

การแจกแจงผลลัพธ์ที่เป็นไปได้ของการดำเนินการโค้ด

Enum
OUTCOME_UNSPECIFIED สถานะที่ไม่ระบุ ไม่ควรใช้ค่านี้
OUTCOME_OK การดำเนินการกับโค้ดเสร็จสมบูรณ์แล้ว
OUTCOME_FAILED การเรียกใช้โค้ดเสร็จสมบูรณ์แต่ดำเนินการไม่สำเร็จ stderr ควรมีเหตุผล
OUTCOME_DEADLINE_EXCEEDED การดำเนินการกับโค้ดใช้เวลานานเกินไปและถูกยกเลิก อาจมีหรือไม่มีเอาต์พุตบางส่วน

เครื่องมือ

รายละเอียดเครื่องมือที่โมเดลอาจใช้สร้างคำตอบ

Tool คือโค้ดที่ช่วยให้ระบบโต้ตอบกับระบบภายนอกเพื่อดําเนินการหรือชุดการดําเนินการนอกความรู้และขอบเขตของโมเดล

ฟิลด์
functionDeclarations[] object (FunctionDeclaration)

ไม่บังคับ รายการ FunctionDeclarations ที่พร้อมใช้งานสำหรับโมเดลซึ่งสามารถใช้สำหรับการเรียกใช้ฟังก์ชัน

โมเดลหรือระบบไม่ดําเนินการฟังก์ชัน แต่ระบบอาจแสดงผลฟังก์ชันที่กําหนดเป็น FunctionCall พร้อมอาร์กิวเมนต์ไปยังฝั่งไคลเอ็นต์สําหรับการดําเนินการแทน โมเดลอาจเลือกเรียกใช้ฟังก์ชันย่อยเหล่านี้โดยป้อนข้อมูล FunctionCall ในการตอบกลับ วลีถัดไปในการสนทนาอาจมี FunctionResponse ที่มีบริบทการสร้าง "ฟังก์ชัน" Content.role สําหรับวลีถัดไปของโมเดล

googleSearchRetrieval object (GoogleSearchRetrieval)

ไม่บังคับ เครื่องมือดึงข้อมูลซึ่งทำงานด้วย Google Search

codeExecution object (CodeExecution)

ไม่บังคับ ช่วยให้โมเดลเรียกใช้โค้ดได้เป็นส่วนหนึ่งของการสร้าง

การแสดง JSON
{
  "functionDeclarations": [
    {
      object (FunctionDeclaration)
    }
  ],
  "googleSearchRetrieval": {
    object (GoogleSearchRetrieval)
  },
  "codeExecution": {
    object (CodeExecution)
  },
  "googleSearch": {
    object (GoogleSearch)
  }
}

FunctionDeclaration

การนําเสนอแบบมีโครงสร้างของการประกาศฟังก์ชันตามที่ระบุไว้ในข้อกําหนด OpenAPI 3.03 การประกาศนี้ประกอบด้วยชื่อฟังก์ชันและพารามิเตอร์ FunctionDeclaration นี้แสดงบล็อกโค้ดที่โมเดลสามารถใช้เป็น Tool และไคลเอ็นต์สามารถเรียกใช้ได้

ฟิลด์
name string

ต้องระบุ ชื่อของฟังก์ชัน ต้องประกอบด้วย a-z, A-Z, 0-9 หรือมีขีดล่างและขีดกลาง โดยมีความยาวสูงสุด 63

description string

ต้องระบุ คำอธิบายฟังก์ชันโดยย่อ

parameters object (Schema)

ไม่บังคับ อธิบายพารามิเตอร์ของฟังก์ชันนี้ แสดงคีย์สตริงออบเจ็กต์พารามิเตอร์ Open API 3.03: ชื่อพารามิเตอร์ ชื่อพารามิเตอร์จะคำนึงถึงตัวพิมพ์เล็กและตัวพิมพ์ใหญ่ ค่าสคีมา: สคีมาที่กำหนดประเภทที่ใช้สำหรับพารามิเตอร์

response object (Schema)

ไม่บังคับ อธิบายเอาต์พุตจากฟังก์ชันนี้ในรูปแบบสคีมา JSON แสดงออบเจ็กต์การตอบกลับ Open API 3.03 สคีมาจะกําหนดประเภทที่ใช้สําหรับค่าการตอบกลับของฟังก์ชัน

การแสดง JSON
{
  "name": string,
  "description": string,
  "parameters": {
    object (Schema)
  },
  "response": {
    object (Schema)
  }
}

สคีมา

ออบเจ็กต์ Schema อนุญาตให้กำหนดประเภทข้อมูลอินพุตและเอาต์พุต ประเภทเหล่านี้อาจเป็นออบเจ็กต์ รวมถึงอาจเป็นประเภทพื้นฐานและอาร์เรย์ก็ได้ แสดงชุดย่อยที่เลือกของออบเจ็กต์สคีมา OpenAPI 3.0

ฟิลด์
type enum (Type)

ต้องระบุ ประเภทข้อมูล

format string

ไม่บังคับ รูปแบบของข้อมูล ใช้กับประเภทข้อมูลพื้นฐานเท่านั้น รูปแบบที่รองรับ: สำหรับประเภทตัวเลข: float, double สำหรับประเภทจำนวนเต็ม: int32, int64 สำหรับประเภทสตริง: enum, วันที่และเวลา

description string

ไม่บังคับ คำอธิบายสั้นๆ เกี่ยวกับพารามิเตอร์ ซึ่งอาจรวมถึงตัวอย่างการใช้งาน คำอธิบายพารามิเตอร์อาจอยู่ในรูปแบบ Markdown

nullable boolean

ไม่บังคับ ระบุว่าค่าอาจเป็นค่า Null ได้หรือไม่

enum[] string

ไม่บังคับ ค่าที่เป็นไปได้ขององค์ประกอบ Type.STRING ที่มีรูปแบบ enum เช่น เราอาจกำหนด Enum Direction เป็น {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]}

maxItems string (int64 format)

ไม่บังคับ จํานวนองค์ประกอบสูงสุดสําหรับ Type.ARRAY

minItems string (int64 format)

ไม่บังคับ จํานวนองค์ประกอบขั้นต่ำสําหรับ Type.ARRAY

properties map (key: string, value: object (Schema))

ไม่บังคับ พร็อพเพอร์ตี้ของ Type.OBJECT

ออบเจ็กต์ที่มีรายการคู่ "key": value ตัวอย่าง: { "name": "wrench", "mass": "1.3kg", "count": "3" }

required[] string

ไม่บังคับ พร็อพเพอร์ตี้ที่จำเป็นของ Type.OBJECT

propertyOrdering[] string

ไม่บังคับ ลําดับของพร็อพเพอร์ตี้ ไม่ใช่ช่องมาตรฐานในข้อกำหนดของ Open API ใช้เพื่อกำหนดลําดับของพร็อพเพอร์ตี้ในการตอบกลับ

items object (Schema)

ไม่บังคับ สคีมาขององค์ประกอบ Type.ARRAY

การแสดง JSON
{
  "type": enum (Type),
  "format": string,
  "description": string,
  "nullable": boolean,
  "enum": [
    string
  ],
  "maxItems": string,
  "minItems": string,
  "properties": {
    string: {
      object (Schema)
    },
    ...
  },
  "required": [
    string
  ],
  "propertyOrdering": [
    string
  ],
  "items": {
    object (Schema)
  }
}

ประเภท

Type มีรายการประเภทข้อมูล OpenAPI ตามที่ระบุไว้ใน https://spec.openapis.org/oas/v3.0.3#data-types

Enum
TYPE_UNSPECIFIED ไม่ได้ระบุไว้ ไม่ควรใช้
STRING ประเภทสตริง
NUMBER ประเภทตัวเลข
INTEGER ประเภทจำนวนเต็ม
BOOLEAN ประเภทบูลีน
ARRAY ประเภทอาร์เรย์
OBJECT ประเภทออบเจ็กต์

GoogleSearchRetrieval

เครื่องมือดึงข้อมูลเว็บสาธารณะเพื่อใช้อ้างอิง ซึ่งทำงานด้วยระบบของ Google

ฟิลด์
dynamicRetrievalConfig object (DynamicRetrievalConfig)

ระบุการกําหนดค่าการดึงข้อมูลแบบไดนามิกสําหรับแหล่งที่มาที่ระบุ

การแสดง JSON
{
  "dynamicRetrievalConfig": {
    object (DynamicRetrievalConfig)
  }
}

DynamicRetrievalConfig

อธิบายตัวเลือกในการปรับแต่งการดึงข้อมูลแบบไดนามิก

ฟิลด์
mode enum (Mode)

โหมดของตัวทำนายที่จะใช้ในการดึงข้อมูลแบบไดนามิก

dynamicThreshold number

เกณฑ์ที่จะใช้ในการดึงข้อมูลแบบไดนามิก หากไม่ได้ตั้งค่า ระบบจะใช้ค่าเริ่มต้นของระบบ

การแสดง JSON
{
  "mode": enum (Mode),
  "dynamicThreshold": number
}

โหมด

โหมดของตัวทำนายที่จะใช้ในการดึงข้อมูลแบบไดนามิก

Enum
MODE_UNSPECIFIED ทริกเกอร์การดึงข้อมูลเสมอ
MODE_DYNAMIC เรียกใช้การดึงข้อมูลเฉพาะเมื่อระบบพิจารณาว่าจําเป็นเท่านั้น

CodeExecution

ประเภทนี้ไม่มีช่อง

เครื่องมือที่เรียกใช้โค้ดที่โมเดลสร้างขึ้น และแสดงผลลัพธ์ไปยังโมเดลโดยอัตโนมัติ

โปรดดูหัวข้อExecutableCodeและCodeExecutionResult ซึ่งสร้างขึ้นเมื่อใช้เครื่องมือนี้เท่านั้น

GoogleSearch

ประเภทนี้ไม่มีช่อง

ประเภทเครื่องมือ GoogleSearch เครื่องมือที่รองรับ Google Search ในโมเดล ขับเคลื่อนโดย Google

ToolConfig

การกําหนดค่าเครื่องมือซึ่งมีพารามิเตอร์สําหรับระบุการใช้ Tool ในคําขอ

ฟิลด์
functionCallingConfig object (FunctionCallingConfig)

ไม่บังคับ การกําหนดค่าการเรียกใช้ฟังก์ชัน

การแสดง JSON
{
  "functionCallingConfig": {
    object (FunctionCallingConfig)
  }
}

FunctionCallingConfig

การกําหนดค่าสําหรับการระบุลักษณะการเรียกฟังก์ชัน

ฟิลด์
mode enum (Mode)

ไม่บังคับ ระบุโหมดที่การเรียกใช้ฟังก์ชันควรดำเนินการ หากไม่ระบุ ค่าเริ่มต้นจะเป็น AUTO

allowedFunctionNames[] string

ไม่บังคับ ชุดชื่อฟังก์ชันที่เมื่อระบุแล้ว จะจํากัดฟังก์ชันที่โมเดลจะเรียกใช้

คุณควรตั้งค่านี้เมื่อโหมดเป็น "ใดก็ได้" เท่านั้น ชื่อฟังก์ชันควรตรงกับ [FunctionDeclaration.name] เมื่อตั้งค่าโหมดเป็น "ใดก็ได้" โมเดลจะคาดคะเนการเรียกใช้ฟังก์ชันจากชุดชื่อฟังก์ชันที่ระบุ

การแสดง JSON
{
  "mode": enum (Mode),
  "allowedFunctionNames": [
    string
  ]
}

โหมด

กําหนดลักษณะการดําเนินการสําหรับการเรียกใช้ฟังก์ชันโดยกําหนดโหมดการดําเนินการ

Enum
MODE_UNSPECIFIED โหมดการเรียกใช้ฟังก์ชันที่ไม่ระบุ ไม่ควรใช้ค่านี้
AUTO ลักษณะการทํางานเริ่มต้นของโมเดล โมเดลจะตัดสินใจว่าจะคาดการณ์การเรียกใช้ฟังก์ชันหรือการตอบกลับด้วยภาษาธรรมชาติ
ANY โมเดลถูกจํากัดให้คาดการณ์การเรียกฟังก์ชันเท่านั้นเสมอ หากตั้งค่า "allowedFunctionNames" การเรียกใช้ฟังก์ชันที่คาดการณ์จะจํากัดอยู่ที่ "allowedFunctionNames" รายการใดรายการหนึ่ง มิเช่นนั้นการเรียกใช้ฟังก์ชันที่คาดการณ์จะเป็น "functionDeclarations" รายการใดรายการหนึ่งที่ให้ไว้
NONE โมเดลจะไม่คาดคะเนการเรียกใช้ฟังก์ชัน ลักษณะการทํางานของโมเดลจะเหมือนกับเมื่อไม่ได้ส่งการประกาศฟังก์ชันใดๆ

UsageMetadata

ข้อมูลเมตาเกี่ยวกับการใช้เนื้อหาที่แคชไว้

ฟิลด์
totalTokenCount integer

จํานวนโทเค็นทั้งหมดที่เนื้อหาที่แคชไว้ใช้

การแสดง JSON
{
  "totalTokenCount": integer
}