const twentyFiveMinutesAgo = Date.now() - (25 * 60 * 1000); const YOUR_OPENAI_API_KEY = '' const blocks = window.roamAlphaAPI.q(`[ :find ?text :where [?e :block/string ?text] [?e :edit/time ?time] [(> ?time ${twentyFiveMinutesAgo})] ]`); async function generateSummary(blocks) { const content = blocks.map(block => block[0]).join("\n"); const prompt = `Given the following updates from the last 25 minutes, generate a summary in the style of an intermittent journal, pointing out completed tasks, pending tasks in bullet list, and provide some encouragement: ${content} --- Summary:`; const response = await fetch("https://api.openai.com/v1/completions", { method: "POST", headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${YOUR_OPENAI_API_KEY}` }, body: JSON.stringify({ model: 'gpt-3.5-turbo-instruct', prompt: prompt, max_tokens: 200 }) }); const data = await response.json(); return data.choices[0].text.trim(); } const summary = await generateSummary(blocks); console.log(summary);