Skip to content

Commit

Permalink
Add explanatory comment to countTokens samples (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Jul 30, 2024
1 parent 71905ad commit 4ee32e5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions samples/count_tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ async function tokensSystemInstruction() {
const resultWithInstructions =
await modelWithInstructions.countTokens(prompt);

// The total token count includes everything sent to the
// generateContent() request. When you use system instructions, the
// total token count increases.
console.log(resultWithInstructions);
// { totalTokens: 23 }
// [END tokens_system_instruction]
Expand Down Expand Up @@ -379,6 +382,9 @@ async function tokensTools() {

const resultWithTools = await modelWithTools.countTokens(prompt);

// The total token count includes everything sent to the
// generateContent() request. When you use tools (like function calling),
// the total token count increases.
console.log(resultWithTools);
// { totalTokens: 99 }
// [END tokens_tools]
Expand Down

0 comments on commit 4ee32e5

Please sign in to comment.