A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
fix: callback with error when summarizing
Christian Fei5afac4173058
diff --git a/lib/llm/index.js b/lib/llm/index.jsindex de3ac4f..f924027 100644--- a/lib/llm/index.js+++ b/lib/llm/index.js@@ -13,6 +13,6 @@ export async function summarize (return llm.summarize(prompt)} catch (e) {- console.error('Error summarizing video', e.message)+ return null}}diff --git a/lib/subtitles-summary.js b/lib/subtitles-summary.jsindex 6c140a7..88445ff 100644--- a/lib/subtitles-summary.js+++ b/lib/subtitles-summary.js@@ -12,7 +12,7 @@ export async function summarizeVideo (id, repo, llmSettings = {}, callback = ()repo.setVideoTranscript(id, cleanedTranscript)cleanedTranscript = cleanedTranscript.replace('\n', ' ')fs.writeFileSync(`./data/videos/${id}.en.txt`, cleanedTranscript)- callback('prompting llm') // eslint-disable-line+ callback(null, 'prompting llm') // eslint-disable-lineconst userPrompt = `Extract the key points from the following video transcript:@@ -23,11 +23,12 @@ ${cleanedTranscript}`.trim()Begin by summarizing it into a single paragraph, followed by a longer summary that expands on the key points.Do not describe or mention the video itself. Simply summarize the points it makes. Focus on the overall or underlying takeaway, cause, reason.`const summary = await llm.summarize(systemPrompt, userPrompt, llmSettings)- callback('received summary') // eslint-disable-line+ callback(null, 'received summary') // eslint-disable-linerepo.setVideoSummary(id, summary)resolve({ summary, transcript: cleanedTranscript })} catch (error) {- console.error('Error summarizing video', id, error.message)+ console.error(`Error summarizing video ${id}: ${error.message}`)+ callback(error, `Error summarizing video ${id}: ${error.message}`)reject(error)}}))diff --git a/server/router/api.js b/server/router/api.jsindex d570e54..19d1eff 100644--- a/server/router/api.js+++ b/server/router/api.js@@ -139,7 +139,6 @@ async function summarizeVideoHandler (req, res, repo, connections = [], state =summarizeVideo(id, repo, llmSettings, (err, line) => {if (err) {- console.error(err)broadcastSSE(JSON.stringify({ type: 'download-log-line', line: `Error summarizing video ${id}: ${err.message}` }), connections)} else {broadcastSSE(JSON.stringify({ type: 'download-log-line', line }), connections)