Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lmg-anon committed May 21, 2024
1 parent 4690e54 commit 979839c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions mikupad.html
Original file line number Diff line number Diff line change
Expand Up @@ -3800,15 +3800,15 @@
// split the chunk in 2
const left = { content: chunk.content.substring(0, chunk.content.indexOf(fillPlaceholder)), type: "user" };
const right = { content: chunk.content.substring(chunk.content.indexOf(fillPlaceholder) + fillPlaceholder.length), type: "user" };
fillIdx = i + 1;
leftPromptChunks = [
...promptChunks.slice(0, Math.max(0, i - 1)),
...[left]
...promptChunks.slice(0, i),
left
];
rightPromptChunks = [
...[right],
right,
...promptChunks.slice(i + 1, promptChunks.length - 1),
];
fillIdx = i + 1;
break;
}
}
Expand All @@ -3822,9 +3822,9 @@
const finalPrompt = assembleFinalPrompt(additionalContextPrompt);

predict(finalPrompt, leftPromptChunks.length, (chunk) => {
console.log(chunk);
if (rightPromptChunks[0]) {
if (chunk.content.trim().startsWith(rightPromptChunks[0].content[0])) {
const trimmedChunk = chunk.content.replace(/^ +| +$/gm, "")
if (trimmedChunk.startsWith(rightPromptChunks[0].content[0])) {
if (chunk.content[0] == ' ' && rightPromptChunks[0].content[0] != ' ') {
rightPromptChunks[0].content = ' ' + rightPromptChunks[0].content;
setPromptChunks(p => [
Expand Down Expand Up @@ -3902,8 +3902,10 @@
while (undoStack.current.at(-1) >= chunkCount)
undoStack.current.pop();
undoStack.current.push(chunkCount);
redoStack.current = [];
} else {
undoStack.current = [];
}
redoStack.current = [];
setUndoHovered(false);
setRejectedAPIKey(false);
promptArea.current.scrollTarget = undefined;
Expand Down

0 comments on commit 979839c

Please sign in to comment.