feat: Add token metrics and OpenAI-compatible response format to text generation #445
+612
−35
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.
Summary
This PR adds timing metrics and opt-in OpenAI-compatible response formats to Bumblebee's text generation serving, making it easier to integrate with
existing OpenAI-compatible tooling and monitor generation performance.
This will help bumblebee to integrated easier with other libs without writing custom middlewares .
New Options
Three new options for
Bumblebee.Text.generation/4::include_timing- Whentrue, includes performance metrics in results:output_format- Supports:bumblebee(default),:openai, and:openai_chat:model_name- Model identifier for OpenAI format responsesFeatures
Timing Metrics
When
include_timing: true:generation_time_us- Total generation time in microsecondstokens_per_second- Generation throughputtime_to_first_token_us- Time to first token (streaming only)Finish Reason Tracking
Tracks why generation stopped:
"stop"- EOS token reached"length"- Max length reachedOpenAI-Compatible Formats
Text Completions (
:openai):