zeta2: Add labeled sections prompt format (#38828)

Release Notes:

- N/A

Co-authored-by: Agus <agus@zed.dev>
This commit is contained in:
Michael Sloan
2025-09-25 00:07:43 +00:00
committed by GitHub
co-authored by Agus
parent 7167be5889
commit 8fc7bd9ae8
8 changed files with 199 additions and 120 deletions
+15 -7
View File
@@ -2,6 +2,7 @@ mod headless;
use anyhow::{Result, anyhow};
use clap::{Args, Parser, Subcommand};
use cloud_llm_client::predict_edits_v3::PromptFormat;
use edit_prediction_context::EditPredictionExcerptOptions;
use futures::channel::mpsc;
use futures::{FutureExt as _, StreamExt as _};
@@ -74,6 +75,16 @@ struct Zeta2Args {
target_before_cursor_over_total_bytes: f32,
#[arg(long, default_value_t = 1024)]
max_diagnostic_bytes: usize,
#[arg(long, value_parser = parse_format)]
format: PromptFormat,
}
fn parse_format(s: &str) -> Result<PromptFormat> {
match s {
"marked_excerpt" => Ok(PromptFormat::MarkedExcerpt),
"labeled_sections" => Ok(PromptFormat::LabeledSections),
_ => Err(anyhow!("Invalid format: {}", s)),
}
}
#[derive(Debug, Clone)]
@@ -228,6 +239,7 @@ async fn get_context(
},
max_diagnostic_bytes: zeta2_args.max_diagnostic_bytes,
max_prompt_bytes: zeta2_args.max_prompt_bytes,
prompt_format: zeta2_args.format,
})
});
// TODO: Actually wait for indexing.
@@ -240,13 +252,9 @@ async fn get_context(
zeta.cloud_request_for_zeta_cli(&project, &buffer, cursor, cx)
})?
.await?;
let planned_prompt = cloud_zeta2_prompt::PlannedPrompt::populate(
&request,
&cloud_zeta2_prompt::PlanOptions {
max_bytes: zeta2_args.max_prompt_bytes,
},
)?;
anyhow::Ok(planned_prompt.to_prompt_string())
let planned_prompt = cloud_zeta2_prompt::PlannedPrompt::populate(&request)?;
// TODO: Output the section label ranges
anyhow::Ok(planned_prompt.to_prompt_string()?.0)
})
})?
.await?,