update inline generate prompt to leverage more explicit <|START| and |END|> spans

KCaverly created

Change summary

crates/assistant/src/assistant_panel.rs | 14 +++++---------
crates/assistant/src/prompts.rs         | 16 ++++++++++------
2 files changed, 15 insertions(+), 15 deletions(-)

Detailed changes

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_model

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 generating
     if 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();
         }