ggfeat(extractor): expose token usage via extract_with_usage methods#1447
Merged
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom Feb 28, 2026
Merged
ggfeat(extractor): expose token usage via extract_with_usage methods#1447joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
Conversation
Add new methods that return both extracted data and token usage information, enabling users to track costs and token consumption when using extraction. Changes: - Add ExtractionResponse<T> struct containing data and total_usage fields - Add extract_with_usage() method returning ExtractionResponse - Add extract_with_chat_history_with_usage() method for chat history variant - Refactor extract_json to extract_json_with_usage to capture usage - Update existing extract() and extract_with_chat_history() to delegate internally - Export ExtractionResponse from rig-core::lib Backward compatibility: Existing APIs unchanged, they delegate to new methods and discard usage information. Usage accumulates across all retry attempts to provide complete cost picture. Includes: - Updated example demonstrating both APIs - Integration tests for backward compatibility and new usage tracking
1 task
joshua-mo-143
approved these changes
Feb 28, 2026
Contributor
joshua-mo-143
left a comment
There was a problem hiding this comment.
lgtm, thanks liam!
Merged
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.
Add new methods that return both extracted data and token usage information, enabling users to track costs and token consumption when using extraction.
Changes:
Backward compatibility: Existing APIs unchanged, they delegate to new methods and discard usage information.
Usage accumulates across all retry attempts to provide complete cost picture.
Includes: