From 022c602496646b56a6b1a5fc516fa6c6b1d79ab9 Mon Sep 17 00:00:00 2001 From: Gregor Adams <1148334+pixelass@users.noreply.github.com> Date: Sat, 8 Jun 2024 16:11:19 +0200 Subject: [PATCH] fix: incomplete images in first run are not cropped (#333) ## Motivation ## Issues closed --- src/electron/helpers/ipc/sdk/assistant.ts | 27 ++--------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/electron/helpers/ipc/sdk/assistant.ts b/src/electron/helpers/ipc/sdk/assistant.ts index bae88916d..3b6269387 100644 --- a/src/electron/helpers/ipc/sdk/assistant.ts +++ b/src/electron/helpers/ipc/sdk/assistant.ts @@ -39,29 +39,6 @@ export const assistantStore = new Store>({ name: buildKey([KEY.STORE, KEY.ASSISTANT]), }); -interface RAGDocument { - id: string; - filePath: string | undefined; - content: string; - type: string; - label: string; - score: number; -} - -export function optimizeContext(context: RAGDocument[]) { - if (context.length === 0) { - return "\n\n"; - } - - let result = "\n\n"; - for (const entry of context) { - result += `${context.indexOf(entry) + 1}. ${entry.label}\n - Type: ${entry.type}\n - Path: ${entry.filePath}\n - Score (0-1): ${entry.score.toFixed(2)}\n - Content: \`\`\`\n${entry.content}\n\`\`\`\n`; - } - - result += "\n\n"; - return result; -} - export const PATH_PLACEHOLDER = "c:/users/anon/"; export function cropCaptainData(filePath: string) { @@ -278,7 +255,7 @@ export function createWorkflow({ width, cfg = 7, loraWeight = 1, - checkpointName = "stabilityai\\stable-diffusion-xl-base-1.0\\sd_xl_base_1.0_0.9vae.safetensors", + checkpointName = String.raw`stabilityai\stable-diffusion-xl-base-1.0\sd_xl_base_1.0_0.9vae.safetensors`, loraName, }: { prompt?: string; @@ -706,7 +683,7 @@ export async function streamWithTools>( case "text-delta": { fullResponse += delta.textDelta; - onStream(fullResponse); + onStream(cropIncompleteImageTag(fullResponse)); break; }