To retrieve the current token consumption during the reasoning process, assign a value to ChatUsage in ReasoningChunkEvent.accumulated#935
Open
MrYang-Jia wants to merge 4 commits intoagentscope-ai:mainfrom
Conversation
To retrieve the current token consumption during the reasoning process, assign a value to `ChatUsage` in `ReasoningChunkEvent.accumulated`: 1. Add the `getChatUsage()` method to `ReasoningContext`. 2. In `ReActAgent.notifyReasoningChunk`, assign `ReasoningContext.getChatUsage()` to `accumulated.metadata._chat_usage`. This allows real-time retrieval of consumed tokens during the reasoning process, facilitating interrupted billing recovery or token replenishment for missing billing records. chinese: 为了在思考过程中获取到当前的tokens损耗,所以在 ReasoningChunkEvent.accumulated 里为 ChatUsage 赋值 1、ReasoningContext 增加 getChatUsage() 方法 2、ReActAgent.notifyReasoningChunk 将 ReasoningContext.getChatUsage() 赋予 accumulated.metadata._chat_usage ,这样子思考过程就可以实时获取到损耗的tokens,方便中断计费或丢失计费补充tokens
|
|
1 similar comment
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Add test cases for ReasoningContext.getChatUsage() to cover the partial uncovered line, fix patch coverage from 85.71% to 100%
Author
|
我已补签了CLA协议,请继续 |
…eve full coverage testing for accumulated message metadata chat usage test: 新增 testChatUsageInAccumulatedMessageMetadata 测试案例,进行覆盖测试
…Test.testFixedDelayReschedulesAndRunsMultipleTimes to prevent test failures due to slower execution speed in CI environment test: Modify the timeout configuration in QuartzFixedDelayIntegrationTest.testFixedDelayReschedulesAndRunsMultipleTimes to prevent test failures due to slower execution speed in CI environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To retrieve the current token consumption during the reasoning process, assign a value to
ChatUsageinReasoningChunkEvent.accumulated:getChatUsage()method toReasoningContext.ReActAgent.notifyReasoningChunk, assignReasoningContext.getChatUsage()toaccumulated.metadata._chat_usage. This allows real-time retrieval of consumed tokens during the reasoning process, facilitating interrupted billing recovery or token replenishment for missing billing records.chinese:
为了在思考过程中获取到当前的tokens损耗,所以在 ReasoningChunkEvent.accumulated 里为 ChatUsage 赋值 1、ReasoningContext 增加 getChatUsage() 方法
2、ReActAgent.notifyReasoningChunk 将 ReasoningContext.getChatUsage() 赋予 accumulated.metadata._chat_usage ,这样子思考过程就可以实时获取到损耗的tokens,方便中断计费或丢失计费补充tokens
AgentScope-Java Version
AgentScope-Java 1.0.11-SNAPSHOT
Description
To retrieve the current token consumption during the reasoning process, assign a value to
ChatUsageinReasoningChunkEvent.accumulatedChecklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)