Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Provider like SiliconFlow show wrong tokens number on task header #962

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant