Skip to content

Add CountTokensOperator for Google Generative AI CountTokensAPI - #41908

Merged
potiuk merged 2 commits into
apache:mainfrom
CYarros10:count-tokens-operator
Sep 1, 2024
Merged

Add CountTokensOperator for Google Generative AI CountTokensAPI#41908
potiuk merged 2 commits into
apache:mainfrom
CYarros10:count-tokens-operator

Conversation

@CYarros10

@CYarros10 CYarros10 commented Aug 30, 2024

Copy link
Copy Markdown
Contributor

The CountTokens API calculates the number of input tokens before sending a request to the Gemini API.
Use the CountTokens API to prevent requests from exceeding the model context window, and estimate potential costs based on billable characters.

Can be used as part of a larger LLM-based DAG:

Training Dataset Lands --> GCSObjectExistenceSensor --> SupervisedFineTuningTrainOperator --> Use CountTokensOperator as a pre-check to ensure prompts will run successfully and within budget --> GenerativeModelGenerateContentOperator --> RapidEvaluation API Operators (to-do)

@potiuk

potiuk commented Sep 1, 2024

Copy link
Copy Markdown
Member

Needs rebase. Also cc: @VladaZakharova

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants