-
Notifications
You must be signed in to change notification settings - Fork 937
Add support for token-based usage metrics. #8757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
d93ded6
41cfa7b
bb950ff
ca74f88
accb059
1b05808
61efb23
40914d7
9b8a59f
94bb826
ddb1a9a
fd5dcea
7b5193a
6aaf68c
7b043ec
ad619f5
db47a2f
2efd3fa
421ab29
a6d2201
813f682
6f90b2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@firebase/vertexai': minor | ||
'firebase': minor | ||
--- | ||
|
||
Added support for modality-based token count. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends": "../../config/api-extractor.json", | ||
// Point it to your entry point d.ts file. | ||
"mainEntryPointFilePath": "<projectFolder>/dist/rules-unit-testing/index.d.ts" | ||
} | ||
// Point it to your entry point d.ts file. | ||
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ import { | |
FinishReason, | ||
HarmCategory, | ||
HarmProbability, | ||
HarmSeverity | ||
HarmSeverity, | ||
Modality | ||
} from './enums'; | ||
|
||
/** | ||
|
@@ -83,6 +84,20 @@ export interface UsageMetadata { | |
promptTokenCount: number; | ||
candidatesTokenCount: number; | ||
totalTokenCount: number; | ||
promptTokensDetails?: ModalityTokenCount[]; | ||
candidatesTokensDetails?: ModalityTokenCount[]; | ||
} | ||
|
||
/** | ||
* Represents token counting info for a single modality. | ||
* | ||
* @public | ||
*/ | ||
export interface ModalityTokenCount { | ||
/** The modality associated with this token count. */ | ||
modality: Modality; | ||
/** The number of tokens counted. */ | ||
tokenCount: number; | ||
} | ||
|
||
/** | ||
|
@@ -213,4 +228,8 @@ export interface CountTokensResponse { | |
* from the request. | ||
*/ | ||
totalBillableCharacters?: number; | ||
/** | ||
* The breakdown, by modality, of how many tokens are consumed by the prompt. | ||
*/ | ||
promptTokensDetails?: ModalityTokenCount[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want docs on this property? If so, add it in the same comment format as the two other properties above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added, thanks! BTW, why are |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.