-
Notifications
You must be signed in to change notification settings - Fork 57
Add Execution Cost to Html Reports #243
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f65a79c
feat: add pricing to html reports
philipph-askui 0e6aca6
feat: add hint to estimated cost in html report that actual cost migh…
philipph-askui 49273a6
chore: update docs on pricing
philipph-askui 5a752cf
fix: tests on model pricing
philipph-askui aa2cf3c
chore: cleanup new pricing sections in docs
philipph-askui 6e1ea26
chore: move `resolve_default_pricing` to `ModelPricing`
philipph-askui b7225e7
Merge remote-tracking branch 'origin/main' into feat/execution_cost
philipph-askui a86e5e2
Merge remote-tracking branch 'origin/main' into feat/execution_cost
philipph-askui d90a3ac
fix: minor formatting issue
philipph-askui cdadaad
chore: change return type of `on_conversation_end` from `UsageTrackin…
philipph-askui 9b506b8
Update src/askui/utils/model_pricing.py
philipph-askui bac8638
chore: improve description of currency parameter in docstring
philipph-askui ad10a3e
add online comment on model price source
philipph-askui 962fe71
chore: rewrite model_pricing checks as parameterized tests
philipph-askui a871a97
chore: cleanup usage_tracking_callback
philipph-askui 47f78b2
fix: remove pricing from askui_vlm_provider
philipph-askui a002697
chore: return early if pricing values are not set in usage tacking ca…
philipph-askui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| ) | ||
| from askui.models.shared.prompts import SystemPrompt | ||
| from askui.models.shared.tools import ToolCollection | ||
| from askui.utils.model_pricing import ModelPricing | ||
|
|
||
| _DEFAULT_MODEL_ID = "claude-sonnet-4-6" | ||
|
|
||
|
|
@@ -38,6 +39,11 @@ class AnthropicVlmProvider(VlmProvider): | |
| `\"claude-sonnet-4-6\"`. | ||
| client (Anthropic | None, optional): Pre-configured Anthropic client. | ||
| If provided, other connection parameters are ignored. | ||
| input_cost_per_million_tokens (float | None, optional): Override | ||
| cost in USD per 1M input tokens. Both cost params must be set | ||
| to override the built-in defaults. | ||
| output_cost_per_million_tokens (float | None, optional): Override | ||
| cost in USD per 1M output tokens. | ||
|
|
||
| Example: | ||
| ```python | ||
|
|
@@ -60,6 +66,8 @@ def __init__( | |
| auth_token: str | None = None, | ||
| model_id: str | None = None, | ||
| client: Anthropic | None = None, | ||
| input_cost_per_million_tokens: float | None = None, | ||
| output_cost_per_million_tokens: float | None = None, | ||
| ) -> None: | ||
| self._model_id_value = ( | ||
| model_id or os.environ.get("VLM_PROVIDER_MODEL_ID") or _DEFAULT_MODEL_ID | ||
|
Collaborator
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. @mlikasam-askui and @philipph-askui , we need to discuaa what is the proper way of Reading and Validating Env Variables. |
||
|
|
@@ -72,12 +80,22 @@ def __init__( | |
| base_url=base_url, | ||
| auth_token=auth_token, | ||
| ) | ||
| self._pricing = ModelPricing.for_model( | ||
| self._model_id_value, | ||
| input_cost_per_million_tokens=input_cost_per_million_tokens, | ||
| output_cost_per_million_tokens=output_cost_per_million_tokens, | ||
| ) | ||
|
|
||
| @property | ||
| @override | ||
| def model_id(self) -> str: | ||
| return self._model_id_value | ||
|
|
||
| @property | ||
| @override | ||
| def pricing(self) -> ModelPricing | None: | ||
| return self._pricing | ||
|
|
||
| @cached_property | ||
| def _messages_api(self) -> AnthropicMessagesApi: | ||
| """Lazily initialise the AnthropicMessagesApi on first use.""" | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.