mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Use split token display for xAI models (#48719)
### Split token display for xAI Extends the split input/output token display (introduced in #46829 for OpenAI) to all xAI models. Instead of the combined `48k / 1M` token counter, xAI models now show: - **↑** input tokens used / input token limit - **↓** output tokens used / output token limit #### Before <img width="513" height="128" alt="Screenshot 2026-02-08 at 11 07 13 AM" src="https://github.com/user-attachments/assets/14e5cb4a-9b5c-4081-bbfb-407a737bf234" /> #### After <img width="610" height="126" alt="Screenshot 2026-02-08 at 11 05 36 AM" src="https://github.com/user-attachments/assets/92396dcb-8905-4f87-9b9e-d8b0f63225ba" /> #### Changes - **x_ai.rs** — Override `supports_split_token_display()` to return `true` on `XAiLanguageModel`. All built-in Grok models already implement `max_output_tokens()`, so no additional plumbing was needed. - **cloud.rs** — Add `XAi` to the `matches!` pattern in `CloudLanguageModel::supports_split_token_display()` so cloud-routed xAI models also get the split display. #### Tests - `test_xai_supports_split_token_display` — Verifies all built-in Grok model variants return `true` for split token display. - `test_xai_models_have_max_output_tokens` — Validates all built-in Grok models report `max_output_tokens` that is `Some`, positive, and less than `max_token_count` (required for the UI to compute the input token limit). - `test_split_token_display_supported_providers` — Confirms the cloud provider match pattern includes `OpenAi` and `XAi` while excluding `Anthropic` and `Google`. Release Notes: - Changed the display of tokens for xAI models to reflect the input/output limits. --------- Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
parent
a80b0195bb
commit
a777605ec5
2 changed files with 5 additions and 1 deletions
|
|
@ -631,7 +631,7 @@ impl LanguageModel for CloudLanguageModel {
|
|||
|
||||
fn supports_split_token_display(&self) -> bool {
|
||||
use cloud_llm_client::LanguageModelProvider::*;
|
||||
matches!(self.model.provider, OpenAi)
|
||||
matches!(self.model.provider, OpenAi | XAi)
|
||||
}
|
||||
|
||||
fn telemetry_id(&self) -> String {
|
||||
|
|
|
|||
|
|
@ -288,6 +288,10 @@ impl LanguageModel for XAiLanguageModel {
|
|||
self.model.max_output_tokens()
|
||||
}
|
||||
|
||||
fn supports_split_token_display(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn count_tokens(
|
||||
&self,
|
||||
request: LanguageModelRequest,
|
||||
|
|
|
|||
Loading…
Reference in a new issue