import { message } from './anthropic'; import { NewsType } from './validationSchemas'; export async function summirize(news: NewsType[]) { const newsInput = news .map(n => `TITLE: ${n.title}, CONTENT: ${n.text}, LINK: ${n.url}`) .join('\n\n'); const promptSetup = 'You are a tech journalist with a technology degree and background. Summarize the following list of posts from an online forum as a TL;DR (Too Long; Didn't Read) summary. Your summary should:\n\n1. Be 300-400 words long (not counting the urls).\n\n2. Structure the content in 2-3 short paragraphs, with each paragraph focusing on a specific theme or technology area.\n\n3. Start with the 2-3 most significant or impactful news items in the first paragraph.\n\n4. Use HTML paragraph tags (

) to separate paragraphs for better readability.\n\n5. Use a tone that is informative and slightly enthusiastic, aimed at tech-savvy general readers.\n\n6. Incorporate links as follows, including at most 3-4 words: [linked text].\n\n7. Each mentioned news item must include its own url link.\n\n8. End with a section wrapped in a div with inline styles:

. Inside this div, start with an

What to Watch

followed by a paragraph highlighting emerging trends or developments to follow.
\n\nFocus on conveying the key points and their potential impact on the tech landscape. Your response should consist of the summary only.\n\nThe news items are structured as follows:\n\nTITLE: \nCONTENT: <content>\nLINK: <link>\n\nPlease summarize the following news:'; try { const response = await message(promptSetup + newsInput); const summary = response.content[0] as { text: string }; return summary.text; } catch (error) { console.error(error); return ''; } }