From 37b86a740c13563a1582db260a01bdd034ad9763 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sun, 1 Jun 2025 10:50:35 +0200 Subject: [PATCH] Add function to stream README using LLM --- main.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.js b/main.js index 8f13753..11f5000 100644 --- a/main.js +++ b/main.js @@ -841,6 +841,28 @@ async function streamLLMCommitMessages(prompt, onDataChunk, win) { // ⭐️ Stream ist zu Ende win.webContents.send('cat-end'); + return fullOutput; +} + +async function streamLLMREADME(prompt, onDataChunk, win) { + await ensureOllamaRunning(); + const selectedModel = store.get('readmeModel') || 'qwen2.5-coder:32b'; + const response = await fetch('http://localhost:11434/api/generate', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + model: selectedModel, + prompt: prompt, + stream: true, + options: { temperature: 0.4 } + }) + }); + + if (!response.body) throw new Error('No stream returned'); + const reader = response.body.getReader(); + const decoder = new TextDecoder(); + + let fullOutput = ''; let done = false; // ⭐️ Starte den Stream für die Katze!