Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
language_models: Send a header indicating that the client supports xAI models (#38931)
Marshall Bowersee357e898787
diff --git a/crates/cloud_llm_client/src/cloud_llm_client.rs b/crates/cloud_llm_client/src/cloud_llm_client.rsindex aeace10e6d1..4ae72ce0a4c 100644--- a/crates/cloud_llm_client/src/cloud_llm_client.rs+++ b/crates/cloud_llm_client/src/cloud_llm_client.rs@@ -55,6 +55,9 @@ pub const CLIENT_SUPPORTS_STATUS_MESSAGES_HEADER_NAME: &str =pub const SERVER_SUPPORTS_STATUS_MESSAGES_HEADER_NAME: &str ="x-zed-server-supports-status-messages";+/// The name of the header used by the client to indicate that it supports receiving xAI models.+pub const CLIENT_SUPPORTS_X_AI_HEADER_NAME: &str = "x-zed-client-supports-x-ai";+#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]#[serde(rename_all = "snake_case")]pub enum UsageLimit {diff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rsindex c6567fe0155..1c21e566d68 100644--- a/crates/language_models/src/provider/cloud.rs+++ b/crates/language_models/src/provider/cloud.rs@@ -4,12 +4,12 @@ use anyhow::{Context as _, Result, anyhow};use chrono::{DateTime, Utc};use client::{Client, ModelRequestUsage, UserStore, zed_urls};use cloud_llm_client::{- CLIENT_SUPPORTS_STATUS_MESSAGES_HEADER_NAME, CURRENT_PLAN_HEADER_NAME, CompletionBody,- CompletionEvent, CompletionRequestStatus, CountTokensBody, CountTokensResponse,- EXPIRED_LLM_TOKEN_HEADER_NAME, ListModelsResponse, MODEL_REQUESTS_RESOURCE_HEADER_VALUE, Plan,- PlanV1, PlanV2, SERVER_SUPPORTS_STATUS_MESSAGES_HEADER_NAME,- SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME, TOOL_USE_LIMIT_REACHED_HEADER_NAME,- ZED_VERSION_HEADER_NAME,+ CLIENT_SUPPORTS_STATUS_MESSAGES_HEADER_NAME, CLIENT_SUPPORTS_X_AI_HEADER_NAME,+ CURRENT_PLAN_HEADER_NAME, CompletionBody, CompletionEvent, CompletionRequestStatus,+ CountTokensBody, CountTokensResponse, EXPIRED_LLM_TOKEN_HEADER_NAME, ListModelsResponse,+ MODEL_REQUESTS_RESOURCE_HEADER_VALUE, Plan, PlanV1, PlanV2,+ SERVER_SUPPORTS_STATUS_MESSAGES_HEADER_NAME, SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME,+ TOOL_USE_LIMIT_REACHED_HEADER_NAME, ZED_VERSION_HEADER_NAME,};use futures::{AsyncBufReadExt, FutureExt, Stream, StreamExt, future::BoxFuture, stream::BoxStream,@@ -217,6 +217,7 @@ impl State {let request = http_client::Request::builder().method(Method::GET)+ .header(CLIENT_SUPPORTS_X_AI_HEADER_NAME, "true").uri(http_client.build_zed_llm_url("/models", &[])?.as_ref()).header("Authorization", format!("Bearer {token}")).body(AsyncBody::empty())?;