-
Notifications
You must be signed in to change notification settings - Fork 58
fix usage tracker #252
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
fix usage tracker #252
Changes from all commits
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 |
|---|---|---|
|
|
@@ -65,10 +65,6 @@ def __init__( | |
| self._pricing = pricing | ||
| self._summary = UsageSummary() | ||
|
|
||
| @override | ||
| def on_conversation_start(self, conversation: Conversation) -> None: | ||
| self._summary = UsageSummary() | ||
|
|
||
| @override | ||
| def on_step_end( | ||
| self, | ||
|
|
@@ -77,6 +73,10 @@ def on_step_end( | |
| result: SpeakerResult, | ||
| ) -> None: | ||
| if result.usage: | ||
| self._reporter.add_message( | ||
| role="Usage Tracker", | ||
| content=f"Usage for step {step_index}: {str(result.usage)}", | ||
| ) | ||
|
Comment on lines
+76
to
+79
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. Is this only for debugging?
Contributor
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. |
||
| self._accumulate(result.usage) | ||
|
|
||
| @override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,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" | ||
|
|
||
|
|
@@ -69,6 +70,10 @@ def __init__( | |
| def model_id(self) -> str: | ||
| return self._model_id_value | ||
|
|
||
| @property | ||
|
Contributor
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. This will lead to the html reports showing cost when using the askui API. This is something that we do not want as the cost for the users can be completely different when using our API (e.g. when they use free credits.
Contributor
Author
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. was used for debugging |
||
| def pricing(self) -> ModelPricing | None: | ||
| return ModelPricing.for_model(self._model_id_value) | ||
|
|
||
| @cached_property | ||
| def _messages_api(self) -> AnthropicMessagesApi: | ||
| """Lazily initialise the AnthropicMessagesApi on first use.""" | ||
|
|
||

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.
This was resetting the Usage Summery?