Skip to content

Conversation

@misskanagi
Copy link

@misskanagi misskanagi commented Feb 12, 2025

Description

Added an option openAiUsageCumulation to ApiHandlerOptions which handle tokens statistics when using SiliconFlow as api provider. SiliconFlow return every prompt_tokens and completion_tokens as total number but not incremental.

User can use checkbox ("Enable token usage cumulation") to change tokens statistics mode on model settings tab.
It is default checked which using original execution pass when counting tokens.
screenshot-20250212-231225

Before fix:
wrong

After fix
right

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

#959

Reviewers


Important

Add openAiUsageCumulation option to handle SiliconFlow token statistics, with UI and state management updates.

  • Behavior:
    • Added openAiUsageCumulation option to ApiHandlerOptions in api.ts to handle token statistics for SiliconFlow.
    • Updated processUsageMetrics() in openai.ts to use openAiUsageCumulation for token calculation.
    • Added checkbox in ApiOptions.tsx for enabling token usage cumulation.
  • State Management:
    • Integrated openAiUsageCumulation into global state management in ClineProvider.ts.
    • Updated getState() and updateApiConfiguration() in ClineProvider.ts to handle openAiUsageCumulation.
  • UI:
    • Added checkbox for "Enable token usage cumulation" in ApiOptions.tsx.

This description was created by Ellipsis for c8f8754. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2025

⚠️ No Changeset found

Latest commit: c8f8754

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 27, 2025
@hannesrudolph hannesrudolph linked an issue Mar 5, 2025 that may be closed by this pull request
@hannesrudolph hannesrudolph moved this to To triage in Roo Code Roadmap Mar 5, 2025
@hannesrudolph hannesrudolph moved this from To triage to PR - Needs Approval in Roo Code Roadmap Mar 6, 2025
@mrubens mrubens moved this from PR [Unverified] to PR [Greenlit] in Roo Code Roadmap Mar 10, 2025
@mrubens
Copy link
Collaborator

mrubens commented Mar 11, 2025

Hi @misskanagi, we just merged #1558 that I think will fix the issue. Thank you for your contribution!

@mrubens mrubens closed this Mar 11, 2025
@github-project-automation github-project-automation bot moved this from PR [Greenlit] to Done in Roo Code Roadmap Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provider like SiliconFlow show wrong tokens number on task header

3 participants