Skip to content

Commit 8ee349b

Browse files
authored
Update measureInputUsage() docs to include multimodal input array
Closes #126.
1 parent af717e8 commit 8ee349b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,18 @@ A given language model session will have a maximum number of tokens it can proce
555555
console.log(`${session.inputUsage} tokens used, out of ${session.inputQuota} tokens available.`);
556556
```
557557

558-
To know how many tokens a string will consume, without actually processing it, developers can use the `measureInputUsage()` method:
558+
To know how many tokens a prompt will consume, without actually processing it, developers can use the `measureInputUsage()` method. This method accepts the same input types as `prompt()`, including strings and multimodal input arrays:
559559

560560
```js
561-
const usage = await session.measureInputUsage(promptString);
561+
const stringUsage = await session.measureInputUsage(promptString);
562+
563+
const audioUsage = await session.measureInputUsage([{
564+
role: "user",
565+
content: [
566+
{ type: "text", value: "My response to your critique:" },
567+
{ type: "audio", value: audioBlob }
568+
]
569+
}]);
562570
```
563571

564572
Some notes on this API:

0 commit comments

Comments
 (0)