Skip to content

Commit 34d65c3

Browse files
fix usage tracker
1 parent a9847aa commit 34d65c3

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/askui/callbacks/usage_tracking_callback.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ def __init__(
6565
self._pricing = pricing
6666
self._summary = UsageSummary()
6767

68-
@override
69-
def on_conversation_start(self, conversation: Conversation) -> None:
70-
self._summary = UsageSummary()
71-
7268
@override
7369
def on_step_end(
7470
self,
@@ -77,6 +73,10 @@ def on_step_end(
7773
result: SpeakerResult,
7874
) -> None:
7975
if result.usage:
76+
self._reporter.add_message(
77+
role="Usage Tracker",
78+
content=f"Usage for step {step_index}: {str(result.usage)}",
79+
)
8080
self._accumulate(result.usage)
8181

8282
@override

src/askui/model_providers/askui_vlm_provider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818
from askui.models.shared.prompts import SystemPrompt
1919
from askui.models.shared.tools import ToolCollection
20+
from askui.utils.model_pricing import ModelPricing
2021

2122
_DEFAULT_MODEL_ID = "claude-sonnet-4-6"
2223

@@ -69,6 +70,10 @@ def __init__(
6970
def model_id(self) -> str:
7071
return self._model_id_value
7172

73+
@property
74+
def pricing(self) -> ModelPricing | None:
75+
return ModelPricing.for_model(self._model_id_value)
76+
7277
@cached_property
7378
def _messages_api(self) -> AnthropicMessagesApi:
7479
"""Lazily initialise the AnthropicMessagesApi on first use."""

0 commit comments

Comments
 (0)