predicted completions for Edit and Apply

This commit is contained in:
Nate 2024-11-07 15:13:23 -08:00
parent aca7a7a4f0
commit 0fac5aad1f
2 changed files with 11 additions and 9 deletions

View file

@ -8,12 +8,7 @@ import {
} from "../autocomplete/streamTransforms/lineStream.js";
import { streamDiff } from "../diff/streamDiff.js";
import { streamLines } from "../diff/util.js";
import {
ChatMessage,
DiffLine,
ILLM,
LLMFullCompletionOptions,
} from "../index.js";
import { ChatMessage, DiffLine, ILLM, Prediction } from "../index.js";
import { gptEditPrompt } from "../llm/templates/edit.js";
import { Telemetry } from "../util/posthog.js";
@ -94,10 +89,17 @@ export async function* streamDiffLines(
);
const inept = modelIsInept(llm.model);
const prediction: Prediction = {
type: "content",
content: highlighted,
};
const completion =
typeof prompt === "string"
? llm.streamComplete(prompt, { raw: true })
: llm.streamChat(prompt);
? llm.streamComplete(prompt, { raw: true, prediction })
: llm.streamChat(prompt, {
prediction,
});
let lines = streamLines(completion);

View file

@ -12599,4 +12599,4 @@
}
}
}
}
}