Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Log errors when a prediction fails (#22961)

Antonio Scandurrac3301077af68
diff --git a/Cargo.lock b/Cargo.lock
index df669c8d8a7..8029cf7538b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -16517,6 +16517,7 @@ dependencies = [
"tree-sitter-go",
"tree-sitter-rust",
"ui",
+ "util",
"uuid",
"workspace",
"worktree",
diff --git a/crates/collab/src/llm.rs b/crates/collab/src/llm.rs
index 9cdbad66341..2ece0480647 100644
--- a/crates/collab/src/llm.rs
+++ b/crates/collab/src/llm.rs
@@ -477,7 +477,7 @@ async fn predict_edits(
open_ai::CompletionRequest {
model: model.to_string(),
prompt: prompt.clone(),
- max_tokens: 1024,
+ max_tokens: 2048,
temperature: 0.,
prediction: Some(open_ai::Prediction::Content {
content: params.input_excerpt,
diff --git a/crates/zeta/Cargo.toml b/crates/zeta/Cargo.toml
index 5db6fddbbb8..d7ea7db078b 100644
--- a/crates/zeta/Cargo.toml
+++ b/crates/zeta/Cargo.toml
@@ -39,6 +39,7 @@ telemetry.workspace = true
telemetry_events.workspace = true
theme.workspace = true
ui.workspace = true
+util.workspace = true
uuid.workspace = true
workspace.workspace = true
diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs
index bcd638aa126..546f6a25490 100644
--- a/crates/zeta/src/zeta.rs
+++ b/crates/zeta/src/zeta.rs
@@ -30,6 +30,7 @@ use std::{
time::{Duration, Instant},
};
use telemetry_events::InlineCompletionRating;
+use util::ResultExt;
use uuid::Uuid;
const CURSOR_MARKER: &'static str = "<|user_cursor_is_here|>";
@@ -975,7 +976,7 @@ impl CurrentInlineCompletion {
struct PendingCompletion {
id: usize,
- _task: Task<Result<()>>,
+ _task: Task<()>,
}
pub struct ZetaInlineCompletionProvider {
@@ -1053,13 +1054,16 @@ impl inline_completion::InlineCompletionProvider for ZetaInlineCompletionProvide
})
});
- let mut completion = None;
- if let Ok(completion_request) = completion_request {
- completion = Some(CurrentInlineCompletion {
- buffer_id: buffer.entity_id(),
- completion: completion_request.await?,
- });
- }
+ let completion = match completion_request {
+ Ok(completion_request) => {
+ let completion_request = completion_request.await;
+ completion_request.map(|completion| CurrentInlineCompletion {
+ buffer_id: buffer.entity_id(),
+ completion,
+ })
+ }
+ Err(error) => Err(error),
+ };
this.update(&mut cx, |this, cx| {
if this.pending_completions[0].id == pending_completion_id {
@@ -1068,7 +1072,8 @@ impl inline_completion::InlineCompletionProvider for ZetaInlineCompletionProvide
this.pending_completions.clear();
}
- if let Some(new_completion) = completion {
+ if let Some(new_completion) = completion.context("zeta prediction failed").log_err()
+ {
if let Some(old_completion) = this.current_completion.as_ref() {
let snapshot = buffer.read(cx).snapshot();
if new_completion.should_replace_completion(&old_completion, &snapshot) {
@@ -1083,12 +1088,11 @@ impl inline_completion::InlineCompletionProvider for ZetaInlineCompletionProvide
});
this.current_completion = Some(new_completion);
}
- } else {
- this.current_completion = None;
}
cx.notify();
})
+ .ok();
});
// We always maintain at most two pending completions. When we already