Merge pull request #106 from IDLe-Engineering/patch-2

Build prompt dynamically
This commit is contained in:
Andrew Pareles 2024-10-17 00:10:54 -07:00 committed by GitHub
commit 4ecbd998bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,21 +23,43 @@ ${content}
}
const userInstructionsStr = (instructions: string, files: File[], selection: CodeSelection | null) => {
return `
${filesStr(files)}
let str = '';
${!selection ? '' : `
if (files.length > 0) {
str += filesStr(files);
}
if (selection) {
str += `
I am currently selecting this code:
\`\`\`${selection.selectionStr}\`\`\`
`}
\t\`\`\`${selection.selectionStr}\`\`\`
`;
}
Please edit the code following these instructions (or, if appropriate, answer my question instead):
${instructions}
If you make a change, rewrite the entire file.
if (files.length > 0 && selection) {
str += `
Please edit the selected code or the entire file following these instructions:
`;
} else if (files.length > 0) {
str += `
Please edit the file following these instructions:
`;
} else if (selection) {
str += `
Please edit the selected code following these instructions:
`;
}
str += `
\t${instructions}
`;
if (files.length > 0) {
str += `
\tIf you make a change, rewrite the entire file.
`; // TODO don't rewrite the whole file on prompt, instead rewrite it when click Apply
}
}
return str;
};
const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => {