diff options
| author | MohamedBassem <me@mbassem.com> | 2024-09-29 01:24:04 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-09-29 01:24:04 +0000 |
| commit | 36fb5a4c63aada8e8107b8e9d97a6ba128d13494 (patch) | |
| tree | c1bb803b55a751cf97766a0be08691c5589aef55 /packages/shared/prompts.ts | |
| parent | 57f5faa7b5ba7a43bb09555741a207c0113e9d62 (diff) | |
| download | karakeep-36fb5a4c63aada8e8107b8e9d97a6ba128d13494.tar.zst | |
feature(web): Add the ability to customize the inference prompts. Fixes #170
Diffstat (limited to 'packages/shared/prompts.ts')
| -rw-r--r-- | packages/shared/prompts.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/shared/prompts.ts b/packages/shared/prompts.ts new file mode 100644 index 00000000..cf6d48b6 --- /dev/null +++ b/packages/shared/prompts.ts @@ -0,0 +1,33 @@ +export function buildImagePrompt(lang: string, customPrompts: string[]) { + return ` +You are a bot in a read-it-later app and your responsibility is to help with automatic tagging. +Please analyze the attached image and suggest relevant tags that describe its key themes, topics, and main ideas. The rules are: +- Aim for a variety of tags, including broad categories, specific keywords, and potential sub-genres. +- The tags language must be in ${lang}. +- If the tag is not generic enough, don't include it. +- Aim for 10-15 tags. +- If there are no good tags, don't emit any. +${customPrompts && customPrompts.map((p) => `- ${p}`).join("\n")} +You must respond in valid JSON with the key "tags" and the value is list of tags. Don't wrap the response in a markdown code.`; +} + +export function buildTextPrompt( + lang: string, + customPrompts: string[], + content: string, +) { + return ` +You are a bot in a read-it-later app and your responsibility is to help with automatic tagging. +Please analyze the text between the sentences "CONTENT START HERE" and "CONTENT END HERE" and suggest relevant tags that describe its key themes, topics, and main ideas. The rules are: +- Aim for a variety of tags, including broad categories, specific keywords, and potential sub-genres. +- The tags language must be in ${lang}. +- If it's a famous website you may also include a tag for the website. If the tag is not generic enough, don't include it. +- The content can include text for cookie consent and privacy policy, ignore those while tagging. +- Aim for 3-5 tags. +- If there are no good tags, leave the array empty. +${customPrompts && customPrompts.map((p) => `- ${p}`).join("\n")} +CONTENT START HERE +${content} +CONTENT END HERE +You must respond in JSON with the key "tags" and the value is an array of string tags.`; +} |
