language_models: Allow overriding Zed completions URL via environment variable (#28323)

This PR adds support for overriding the Zed completions URL via the
`ZED_COMPLETIONS_URL` environment variable.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-04-08 10:46:15 -04:00 committed by GitHub
parent cc15598e09
commit 61b7a05792
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -504,10 +504,14 @@ impl CloudLanguageModel {
let mut retry_delay = Duration::from_secs(1); let mut retry_delay = Duration::from_secs(1);
loop { loop {
let request_builder = http_client::Request::builder(); let request_builder = http_client::Request::builder().method(Method::POST);
let request_builder = if let Ok(completions_url) = std::env::var("ZED_COMPLETIONS_URL")
{
request_builder.uri(completions_url)
} else {
request_builder.uri(http_client.build_zed_llm_url("/completion", &[])?.as_ref())
};
let request = request_builder let request = request_builder
.method(Method::POST)
.uri(http_client.build_zed_llm_url("/completion", &[])?.as_ref())
.header("Content-Type", "application/json") .header("Content-Type", "application/json")
.header("Authorization", format!("Bearer {token}")) .header("Authorization", format!("Bearer {token}"))
.body(serde_json::to_string(&body)?.into())?; .body(serde_json::to_string(&body)?.into())?;