Use a left bias for the prompt editor

This commit is contained in:
Antonio Scandurra 2023-08-25 12:25:43 +02:00
parent 66a496edd7
commit 144f5c5d41

View file

@ -276,7 +276,9 @@ impl AssistantPanel {
editor.insert_blocks( editor.insert_blocks(
[BlockProperties { [BlockProperties {
style: BlockStyle::Flex, style: BlockStyle::Flex,
position: selection.head(), position: selection
.head()
.bias_left(&editor.buffer().read(cx).snapshot(cx)),
height: 2, height: 2,
render: Arc::new({ render: Arc::new({
let inline_assistant = inline_assistant.clone(); let inline_assistant = inline_assistant.clone();
@ -506,6 +508,7 @@ impl AssistantPanel {
"Assume the cursor is located where the `<|>` marker is." "Assume the cursor is located where the `<|>` marker is."
) )
.unwrap(); .unwrap();
writeln!(prompt, "Assume your answer will be inserted at the cursor.").unwrap();
writeln!( writeln!(
prompt, prompt,
"Complete the code given the user prompt: {user_prompt}" "Complete the code given the user prompt: {user_prompt}"
@ -513,12 +516,9 @@ impl AssistantPanel {
.unwrap(); .unwrap();
} }
} }
writeln!( writeln!(prompt, "Your answer MUST always be valid {language_name}.").unwrap();
prompt,
"You MUST not return anything that isn't valid {language_name}"
)
.unwrap();
writeln!(prompt, "DO NOT wrap your response in Markdown blocks.").unwrap(); writeln!(prompt, "DO NOT wrap your response in Markdown blocks.").unwrap();
writeln!(prompt, "Never make remarks, always output code.").unwrap();
let request = OpenAIRequest { let request = OpenAIRequest {
model: "gpt-4".into(), model: "gpt-4".into(),