-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support cost estimation for LLM calls.
Usage: ``` import pyglove as pg import langfun as lf class Answer(pg.Object): result: str with lf.track_usages() as usage: lf.query('compute 1 + 1', Answer, lm=lf.llms.VertexAIGeminiPro1_5_002()) lf.query('compute 1 + 1', Answer, lm=lf.llms.Gpt4o()) print(usage) ``` Sample output: ``` UsageSummary( cached = AggregatedUsage( total = LMSamplingUsage( prompt_tokens = 0, completion_tokens = 0, total_tokens = 0, num_requests = 0, estimated_cost = 0.0 ), breakdown = {} ), uncached = AggregatedUsage( total = LMSamplingUsage( prompt_tokens = 239, completion_tokens = 28, total_tokens = 267, num_requests = 2, estimated_cost = 0.00064 ), breakdown = { VertexAI(gemini-1.5-pro-002) = LMSamplingUsage( prompt_tokens = 126, completion_tokens = 16, total_tokens = 142, num_requests = 1, estimated_cost = 0.0002375 ), OpenAI(gpt-4o) = LMSamplingUsage( prompt_tokens = 113, completion_tokens = 12, total_tokens = 125, num_requests = 1, estimated_cost = 0.0004025 ) } ) ) ``` We also add a few Groq models. PiperOrigin-RevId: 684927276
- Loading branch information
Showing
18 changed files
with
1,020 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.