Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
update inline generate prompt to leverage more explicit <|START| and |END|> spans
KCaverlye8dd412ac123
diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rsindex 55a1dfe0f6f..37d0d729fe6 100644--- a/crates/assistant/src/assistant_panel.rs+++ b/crates/assistant/src/assistant_panel.rs@@ -544,16 +544,10 @@ impl AssistantPanel {let multi_buffer = editor.read(cx).buffer().read(cx);let multi_buffer_snapshot = multi_buffer.snapshot(cx);- let snapshot = if multi_buffer.all_buffers().len() > 1 {- return;+ let snapshot = if multi_buffer.is_singleton() {+ multi_buffer.as_singleton().unwrap().read(cx).snapshot()} else {- multi_buffer- .all_buffers()- .iter()- .next()- .unwrap()- .read(cx)- .snapshot()+ return;};let range = pending_assist.codegen.read(cx).range();@@ -588,6 +582,8 @@ impl AssistantPanel {codegen_kind,);+ dbg!(&prompt);+let mut messages = Vec::new();let mut model = settings::get::<AssistantSettings>(cx).default_open_ai_modeldiff --git a/crates/assistant/src/prompts.rs b/crates/assistant/src/prompts.rsindex 272ae9eac68..00db4c1302e 100644--- a/crates/assistant/src/prompts.rs+++ b/crates/assistant/src/prompts.rs@@ -68,9 +68,13 @@ fn outline_for_prompt(intersected = false;text.extend(iter::repeat(indent.as_str()).take(intersection_indent));text.extend(buffer.text_for_range(extended_range.start..range.start));- text.push_str("<|");+ text.push_str("<|START|");text.extend(buffer.text_for_range(range.clone()));- text.push_str("|>");+ if range.start != range.end {+ text.push_str("|END|>");+ } else {+ text.push_str(">");+ }text.extend(buffer.text_for_range(range.end..extended_range.end));text.push('\n');}@@ -113,16 +117,16 @@ pub fn generate_content_prompt(// Assume for now that we are just generatingif range.clone().start == range.end {- writeln!(prompt, "In particular, the user's cursor is current on the '<||>' span in the above outline, with no text selected.").unwrap();+ writeln!(prompt, "In particular, the user's cursor is current on the '<|START|>' span in the above outline, with no text selected.").unwrap();} else {- writeln!(prompt, "In particular, the user has selected a section of the text between the '<|' and '|>' spans.").unwrap();+ writeln!(prompt, "In particular, the user has selected a section of the text between the '<|START|' and '|END|>' spans.").unwrap();}match kind {CodegenKind::Generate { position } => {writeln!(prompt,- "Assume the cursor is located where the `<|` marker is."+ "Assume the cursor is located where the `<|START|` marker is.").unwrap();writeln!(@@ -144,7 +148,7 @@ pub fn generate_content_prompt(.unwrap();writeln!(prompt,- "You MUST reply with only the adjusted code, not the entire file."+ "You MUST reply with only the adjusted code (within the '<|START|' and '|END|>' spans), not the entire file.").unwrap();}