fix: use the internal token usage tracker when using litellm

This commit is contained in:
Thiago Moretto
2026-01-06 12:06:25 -03:00
parent 25c0c030ce
commit 2df8973658
2 changed files with 5 additions and 0 deletions

View File

@@ -1185,6 +1185,8 @@ class LLM(BaseLLM):
start_time=0,
end_time=0,
)
self._track_token_usage_internal(usage_info)
# --- 4) Check for tool calls
tool_calls = getattr(response_message, "tool_calls", [])

View File

@@ -72,6 +72,9 @@ def test_llm_call_with_string_input_and_callbacks():
assert len(result.strip()) > 0
assert usage_metrics.successful_requests == 1
usage_metrics_internal = llm.get_token_usage_summary()
assert usage_metrics_internal == usage_metrics
@pytest.mark.vcr()
def test_llm_call_with_message_list():