aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/prompts.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2024-10-27 00:12:11 +0000
committerMohamed Bassem <me@mbassem.com>2024-10-27 00:12:11 +0000
commit731d2dfbea39aa140ccb6d2d2cabd49186320299 (patch)
tree2311d04b5dc61102c63d4e4ec9c7c97b359faad6 /packages/shared/prompts.ts
parent3e727f7ba3ad157ca1ccc6100711266cae1bde23 (diff)
downloadkarakeep-731d2dfbea39aa140ccb6d2d2cabd49186320299.tar.zst
feature: Add a summarize with AI button for links
Diffstat (limited to 'packages/shared/prompts.ts')
-rw-r--r--packages/shared/prompts.ts14
1 files changed, 14 insertions, 0 deletions
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);
+}