Include outline when predicting edits with Zeta (#22895)
Release Notes: - N/A Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
341972c79c
commit
a8ef0f2426
4 changed files with 28 additions and 12 deletions
|
@ -459,7 +459,15 @@ async fn predict_edits(
|
||||||
.prediction_model
|
.prediction_model
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.context("no PREDICTION_MODEL configured on the server")?;
|
.context("no PREDICTION_MODEL configured on the server")?;
|
||||||
|
|
||||||
|
let outline_prefix = params
|
||||||
|
.outline
|
||||||
|
.as_ref()
|
||||||
|
.map(|outline| format!("### Outline for current file:\n{}\n", outline))
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
let prompt = include_str!("./llm/prediction_prompt.md")
|
let prompt = include_str!("./llm/prediction_prompt.md")
|
||||||
|
.replace("<outline>", &outline_prefix)
|
||||||
.replace("<events>", ¶ms.input_events)
|
.replace("<events>", ¶ms.input_events)
|
||||||
.replace("<excerpt>", ¶ms.input_excerpt);
|
.replace("<excerpt>", ¶ms.input_excerpt);
|
||||||
let mut response = open_ai::complete_text(
|
let mut response = open_ai::complete_text(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<outline>## Task
|
||||||
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
||||||
|
|
||||||
### Instruction:
|
### Instruction:
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub struct PerformCompletionParams {
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct PredictEditsParams {
|
pub struct PredictEditsParams {
|
||||||
|
pub outline: Option<String>,
|
||||||
pub input_events: String,
|
pub input_events: String,
|
||||||
pub input_excerpt: String,
|
pub input_excerpt: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,29 +300,35 @@ impl Zeta {
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
let request_sent_at = Instant::now();
|
let request_sent_at = Instant::now();
|
||||||
|
|
||||||
let input_events = cx
|
let (input_events, input_excerpt, input_outline) = cx
|
||||||
.background_executor()
|
.background_executor()
|
||||||
.spawn(async move {
|
.spawn({
|
||||||
let mut input_events = String::new();
|
let snapshot = snapshot.clone();
|
||||||
for event in events {
|
let excerpt_range = excerpt_range.clone();
|
||||||
if !input_events.is_empty() {
|
async move {
|
||||||
input_events.push('\n');
|
let mut input_events = String::new();
|
||||||
input_events.push('\n');
|
for event in events {
|
||||||
|
if !input_events.is_empty() {
|
||||||
|
input_events.push('\n');
|
||||||
|
input_events.push('\n');
|
||||||
|
}
|
||||||
|
input_events.push_str(&event.to_prompt());
|
||||||
}
|
}
|
||||||
input_events.push_str(&event.to_prompt());
|
|
||||||
|
let input_excerpt = prompt_for_excerpt(&snapshot, &excerpt_range, offset);
|
||||||
|
let input_outline = prompt_for_outline(&snapshot);
|
||||||
|
|
||||||
|
(input_events, input_excerpt, input_outline)
|
||||||
}
|
}
|
||||||
input_events
|
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let input_excerpt = prompt_for_excerpt(&snapshot, &excerpt_range, offset);
|
|
||||||
let input_outline = prompt_for_outline(&snapshot);
|
|
||||||
|
|
||||||
log::debug!("Events:\n{}\nExcerpt:\n{}", input_events, input_excerpt);
|
log::debug!("Events:\n{}\nExcerpt:\n{}", input_events, input_excerpt);
|
||||||
|
|
||||||
let body = PredictEditsParams {
|
let body = PredictEditsParams {
|
||||||
input_events: input_events.clone(),
|
input_events: input_events.clone(),
|
||||||
input_excerpt: input_excerpt.clone(),
|
input_excerpt: input_excerpt.clone(),
|
||||||
|
outline: Some(input_outline.clone()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = perform_predict_edits(client, llm_token, body).await?;
|
let response = perform_predict_edits(client, llm_token, body).await?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue