fix: type errors

This commit is contained in:
tomasz-io 2024-11-26 14:26:15 -08:00
parent 7ee4d8db50
commit cdc9600e68
4 changed files with 12 additions and 8 deletions

View file

@ -87,7 +87,7 @@ const getDiffSnippets = async (
): Promise<AutocompleteDiffSnippet[]> => {
const diff = await ide.getDiff(true);
return [diff].map((item) => {
return diff.map((item) => {
return {
content: item,
type: AutocompleteSnippetType.Diff,

View file

@ -8,15 +8,16 @@ const CommitMessageCommand: SlashCommand = {
const includeUnstaged = params?.includeUnstaged ?? false;
const diff = await ide.getDiff(includeUnstaged);
if (!diff || diff.trim() === "") {
if (diff.length === 0) {
yield "No changes detected. Make sure you are in a git repository with current changes.";
return;
}
const prompt = `${diff}\n\nGenerate a commit message for the above set of changes. First, give a single sentence, no more than 80 characters. Then, after 2 line breaks, give a list of no more than 5 short bullet points, each no more than 40 characters. Output nothing except for the commit message, and don't surround it in quotes.`;
for await (const chunk of llm.streamChat([
{ role: "user", content: prompt },
], new AbortController().signal)) {
for await (const chunk of llm.streamChat(
[{ role: "user", content: prompt }],
new AbortController().signal,
)) {
yield stripImages(chunk.content);
}
},

View file

@ -125,7 +125,10 @@ export function slashCommandFromPromptFile(
systemMessage,
);
for await (const chunk of context.llm.streamChat(messages, new AbortController().signal)) {
for await (const chunk of context.llm.streamChat(
messages,
new AbortController().signal,
)) {
yield stripImages(chunk.content);
}
@ -173,7 +176,7 @@ async function renderPrompt(
const diff = await context.ide.getDiff(false);
const currentFile = await context.ide.getCurrentFile();
const inputData: Record<string, string> = {
diff,
diff: diff.join("\n"),
input: userInput,
};
if (currentFile) {

View file

@ -22,7 +22,7 @@ class DiffContextProvider extends BaseContextProvider {
{
description: "The current git diff",
content:
diff.trim() === ""
diff.length === 0
? "Git shows no current changes."
: `\`\`\`git diff\n${diff}\n\`\`\``,
name: "Git Diff",