Skip to content

Conversation

tingwai
Copy link
Collaborator

@tingwai tingwai commented Aug 28, 2025

Description

[ What changed? Feel free to be brief. ]

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-general-review or @continue-detailed-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Adds token usage reporting (prompt, completion, total) to Gemini and Relace adapters for both streaming and non‑stream responses, enabling cost and quota tracking. Tests updated to expect usage for supported providers.

  • New Features

    • Gemini: collect usageMetadata during stream and emit a final usageChatChunk; include usage in non‑stream ChatCompletion.
    • Relace: emit a final usageChatChunk after apply; include usage in non‑stream ChatCompletion.
    • Safer stream parsing when choices may be empty.
  • Migration

    • No breaking changes. usage is optional but now populated when available in both streaming chunks and non‑stream results.

@tingwai tingwai requested a review from a team as a code owner August 28, 2025 18:46
@tingwai tingwai requested review from Patrick-Erichsen and removed request for a team August 28, 2025 18:46
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 28, 2025
Copy link

⚠️ AI review completed but no review output was generated. Check the action logs for details.


💡 To request a new review, comment @continue-general-review

@tingwai
Copy link
Collaborator Author

tingwai commented Aug 28, 2025

PR not ready yet, putting it up to run tests

@chezsmithy
Copy link
Contributor

Is this planned to have a plugin to the UI at some point in time, or is it a hook to backend processes. More curious than anything...

Copy link
Collaborator

@Patrick-Erichsen Patrick-Erichsen left a comment

Choose a reason for hiding this comment

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

Thanks for updating the tests! Lmk your thoughts on UsageInfo.

Comment on lines 41 to 46
type UsageInfo = {
total_tokens: number;
completion_tokens: number;
prompt_tokens: number;
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think both of the UsageInfo types in this PR are actually from CompletionUsage in openai/resources/index ? If we just need a subset of the properties we could use an Omit or Pick.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Aug 29, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 3, 2025
@tingwai tingwai merged commit fcc3bdd into main Sep 5, 2025
82 of 86 checks passed
@tingwai tingwai deleted the tingwai/con-3668 branch September 5, 2025 17:13
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Sep 5, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2025
@github-actions github-actions bot added the tier 2 Important feature that adds new capabilities to the platform or improves critical user journeys label Sep 5, 2025
@tingwai
Copy link
Collaborator Author

tingwai commented Sep 5, 2025

Is this planned to have a plugin to the UI at some point in time, or is it a hook to backend processes. More curious than anything...

@chezsmithy This is going to be used for our updated billing system, coming very soon!

@sestinj
Copy link
Contributor

sestinj commented Sep 11, 2025

🎉 This PR is included in version 1.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer released size:L This PR changes 100-499 lines, ignoring generated files. tier 2 Important feature that adds new capabilities to the platform or improves critical user journeys
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants