From 731d2dfbea39aa140ccb6d2d2cabd49186320299 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 27 Oct 2024 00:12:11 +0000 Subject: feature: Add a summarize with AI button for links --- packages/shared/prompts.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'packages/shared/prompts.ts') diff --git a/packages/shared/prompts.ts b/packages/shared/prompts.ts index 91bfba3f..d741030a 100644 --- a/packages/shared/prompts.ts +++ b/packages/shared/prompts.ts @@ -50,3 +50,17 @@ You must respond in JSON with the key "tags" and the value is an array of string const truncatedContent = truncateContent(content, contextLength - promptSize); return constructPrompt(truncatedContent); } + +export function buildSummaryPrompt( + lang: string, + content: string, + contextLength: number, +) { + const constructPrompt = (c: string) => ` + Summarize the following content in a 3-4 sentences in ${lang}: + ${c}`; + + const promptSize = calculateNumTokens(constructPrompt("")); + const truncatedContent = truncateContent(content, contextLength - promptSize); + return constructPrompt(truncatedContent); +} -- cgit v1.2.3-70-g09d2