Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a newline when the first message from the LLM is either a code fence or markdown block #13

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ export abstract class AbstractProvider implements ProviderInterface {

const onData = (data: string) => {
try {
if (!data) {
console.log("No data received from LLM");
return;
}
if (stillLoading) {
if (["`", "-", "*"].includes(data.charAt(0))) {
// Sometimes we get a response that is _only_ a code block, or a markdown list/etc
// To let SB parse them better, we just add a new line before rendering it
console.log("First character of response is:", data.charAt(0));
data = "\n" + data;
}
editor.replaceRange(
cursorPos,
cursorPos + loadingMessage.length,
Expand Down
Loading