Skip to content

Conversation

@Sxnan
Copy link
Contributor

@Sxnan Sxnan commented Dec 25, 2025

Linked issue: #390

Purpose of change

This PR adds built-in token usage metrics for chat model connections. The metrics are automatically recorded when chat models are invoked, tracking promptTokens and completionTokens per model.

Tests

  • Added BaseChatModelConnectionTokenMetricsTest.java for Java unit tests
  • Added test_token_metrics.py for Python unit tests

API

Yes, this change adds new built-in metrics

Documentation

  • doc-needed
  • doc-not-needed

@github-actions github-actions bot added priority/major Default priority of the PR or issue. fixVersion/0.2.0 The feature or bug should be implemented/fixed in the 0.2.0 version. doc-needed Your PR changes impact docs. labels Dec 25, 2025
@Sxnan
Copy link
Contributor Author

Sxnan commented Dec 25, 2025

@xintongsong @GreatEugenius Can you review this PR?

Copy link
Contributor

@xintongsong xintongsong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sxnan Sxnan merged commit 6bc5f58 into apache:main Dec 26, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-needed Your PR changes impact docs. fixVersion/0.2.0 The feature or bug should be implemented/fixed in the 0.2.0 version. priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants