Skip to content

Commit

Permalink
Log errors when a prediction fails (#22961)
Browse files Browse the repository at this point in the history
Release Notes:

- N/A

---------

Co-authored-by: Thorsten <[email protected]>
  • Loading branch information
as-cii and mrnugget authored Jan 10, 2025
1 parent 9e113bc commit c330107
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/collab/src/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/zeta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 15 additions & 11 deletions crates/zeta/src/zeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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|>";
Expand Down Expand Up @@ -975,7 +976,7 @@ impl CurrentInlineCompletion {

struct PendingCompletion {
id: usize,
_task: Task<Result<()>>,
_task: Task<()>,
}

pub struct ZetaInlineCompletionProvider {
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit c330107

Please sign in to comment.