Skip to content

Commit 8603a90

Browse files
authored
zeta: Send staff edit predictions through Cloudflare Workers (zed-industries#23847)
This PR makes it so staff edit predictions now go through Cloudflare Workers instead of going to the LLM service. This will allow us to dogfood the new LLM worker to make sure it is working as expected. Release Notes: - N/A
1 parent e594397 commit 8603a90

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

crates/zeta/src/zeta.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use anyhow::{anyhow, Context as _, Result};
88
use arrayvec::ArrayVec;
99
use client::{Client, UserStore};
1010
use collections::{HashMap, HashSet, VecDeque};
11+
use feature_flags::FeatureFlagAppExt as _;
1112
use futures::AsyncReadExt;
1213
use gpui::{
1314
actions, App, AppContext as _, AsyncApp, Context, Entity, EntityId, Global, Subscription, Task,
@@ -298,7 +299,7 @@ impl Zeta {
298299
perform_predict_edits: F,
299300
) -> Task<Result<Option<InlineCompletion>>>
300301
where
301-
F: FnOnce(Arc<Client>, LlmApiToken, PredictEditsParams) -> R + 'static,
302+
F: FnOnce(Arc<Client>, LlmApiToken, bool, PredictEditsParams) -> R + 'static,
302303
R: Future<Output = Result<PredictEditsResponse>> + Send + 'static,
303304
{
304305
let snapshot = self.report_changes_for_buffer(buffer, cx);
@@ -313,6 +314,7 @@ impl Zeta {
313314

314315
let client = self.client.clone();
315316
let llm_token = self.llm_token.clone();
317+
let is_staff = cx.is_staff();
316318

317319
cx.spawn(|_, cx| async move {
318320
let request_sent_at = Instant::now();
@@ -348,7 +350,7 @@ impl Zeta {
348350
outline: Some(input_outline.clone()),
349351
};
350352

351-
let response = perform_predict_edits(client, llm_token, body).await?;
353+
let response = perform_predict_edits(client, llm_token, is_staff, body).await?;
352354

353355
let output_excerpt = response.output_excerpt;
354356
log::debug!("completion response: {}", output_excerpt);
@@ -515,7 +517,7 @@ and then another
515517
) -> Task<Result<Option<InlineCompletion>>> {
516518
use std::future::ready;
517519

518-
self.request_completion_impl(buffer, position, cx, |_, _, _| ready(Ok(response)))
520+
self.request_completion_impl(buffer, position, cx, |_, _, _, _| ready(Ok(response)))
519521
}
520522

521523
pub fn request_completion(
@@ -530,6 +532,7 @@ and then another
530532
fn perform_predict_edits(
531533
client: Arc<Client>,
532534
llm_token: LlmApiToken,
535+
is_staff: bool,
533536
body: PredictEditsParams,
534537
) -> impl Future<Output = Result<PredictEditsResponse>> {
535538
async move {
@@ -538,14 +541,19 @@ and then another
538541
let mut did_retry = false;
539542

540543
loop {
541-
let request_builder = http_client::Request::builder();
542-
let request = request_builder
543-
.method(Method::POST)
544-
.uri(
544+
let request_builder = http_client::Request::builder().method(Method::POST);
545+
let request_builder = if is_staff {
546+
request_builder.uri(
547+
"https://llm-worker-production.zed-industries.workers.dev/predict_edits",
548+
)
549+
} else {
550+
request_builder.uri(
545551
http_client
546552
.build_zed_llm_url("/predict_edits", &[])?
547553
.as_ref(),
548554
)
555+
};
556+
let request = request_builder
549557
.header("Content-Type", "application/json")
550558
.header("Authorization", format!("Bearer {}", token))
551559
.body(serde_json::to_string(&body)?.into())?;

0 commit comments

Comments
 (0)