diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-01-12 15:31:30 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-01-12 15:31:30 +0000 |
| commit | b8bd7d7eb27aaaadae728599f64a0874f66196ea (patch) | |
| tree | d2b9ac7f4324ffe7e1659a7e509635c74c9a1c57 /apps/web | |
| parent | 1ec21b67df64992bf472fc17bc3842369aa313a7 (diff) | |
| download | karakeep-b8bd7d7eb27aaaadae728599f64a0874f66196ea.tar.zst | |
feat: Support customizing the summarization prompt. Fixes #731
Diffstat (limited to 'apps/web')
| -rw-r--r-- | apps/web/components/settings/AISettings.tsx | 57 | ||||
| -rw-r--r-- | apps/web/lib/i18n/locales/en/translation.json | 7 |
2 files changed, 53 insertions, 11 deletions
diff --git a/apps/web/components/settings/AISettings.tsx b/apps/web/components/settings/AISettings.tsx index 79a9e558..1987f763 100644 --- a/apps/web/components/settings/AISettings.tsx +++ b/apps/web/components/settings/AISettings.tsx @@ -27,7 +27,11 @@ import { Plus, Save, Trash2 } from "lucide-react"; import { useForm } from "react-hook-form"; import { z } from "zod"; -import { buildImagePrompt, buildTextPrompt } from "@hoarder/shared/prompts"; +import { + buildImagePrompt, + buildSummaryPrompt, + buildTextPrompt, +} from "@hoarder/shared/prompts"; import { zNewPromptSchema, ZPrompt, @@ -42,7 +46,7 @@ export function PromptEditor() { resolver: zodResolver(zNewPromptSchema), defaultValues: { text: "", - appliesTo: "all", + appliesTo: "all_tagging", }, }); @@ -100,9 +104,18 @@ export function PromptEditor() { </SelectTrigger> <SelectContent> <SelectGroup> - <SelectItem value="all">All</SelectItem> - <SelectItem value="text">Text</SelectItem> - <SelectItem value="images">Images</SelectItem> + <SelectItem value="all_tagging"> + {t("settings.ai.all_tagging")} + </SelectItem> + <SelectItem value="text"> + {t("settings.ai.text_tagging")} + </SelectItem> + <SelectItem value="images"> + {t("settings.ai.image_tagging")} + </SelectItem> + <SelectItem value="summary"> + {t("settings.ai.summarization")} + </SelectItem> </SelectGroup> </SelectContent> </Select> @@ -214,9 +227,18 @@ export function PromptRow({ prompt }: { prompt: ZPrompt }) { </SelectTrigger> <SelectContent> <SelectGroup> - <SelectItem value="all">All</SelectItem> - <SelectItem value="text">Text</SelectItem> - <SelectItem value="images">Images</SelectItem> + <SelectItem value="all_tagging"> + {t("settings.ai.all_tagging")} + </SelectItem> + <SelectItem value="text"> + {t("settings.ai.text_tagging")} + </SelectItem> + <SelectItem value="images"> + {t("settings.ai.image_tagging")} + </SelectItem> + <SelectItem value="summary"> + {t("settings.ai.summarization")} + </SelectItem> </SelectGroup> </SelectContent> </Select> @@ -289,7 +311,9 @@ export function PromptDemo() { {buildTextPrompt( clientConfig.inference.inferredTagLang, (prompts ?? []) - .filter((p) => p.appliesTo == "text" || p.appliesTo == "all") + .filter( + (p) => p.appliesTo == "text" || p.appliesTo == "all_tagging", + ) .map((p) => p.text), "\n<CONTENT_HERE>\n", /* context length */ 1024 /* The value here doesn't matter */, @@ -300,10 +324,23 @@ export function PromptDemo() { {buildImagePrompt( clientConfig.inference.inferredTagLang, (prompts ?? []) - .filter((p) => p.appliesTo == "images" || p.appliesTo == "all") + .filter( + (p) => p.appliesTo == "images" || p.appliesTo == "all_tagging", + ) .map((p) => p.text), ).trim()} </code> + <p>{t("settings.ai.summarization_prompt")}</p> + <code className="whitespace-pre-wrap rounded-md bg-muted p-3 text-sm text-muted-foreground"> + {buildSummaryPrompt( + clientConfig.inference.inferredTagLang, + (prompts ?? []) + .filter((p) => p.appliesTo == "summary") + .map((p) => p.text), + "\n<CONTENT_HERE>\n", + /* context length */ 1024 /* The value here doesn't matter */, + ).trim()} + </code> </div> ); } diff --git a/apps/web/lib/i18n/locales/en/translation.json b/apps/web/lib/i18n/locales/en/translation.json index e1bd443a..d23d5a96 100644 --- a/apps/web/lib/i18n/locales/en/translation.json +++ b/apps/web/lib/i18n/locales/en/translation.json @@ -87,7 +87,12 @@ "tagging_rule_description": "Prompts that you add here will be included as rules to the model during tag generation. You can view the final prompts in the prompt preview section.", "prompt_preview": "Prompt Preview", "text_prompt": "Text Prompt", - "images_prompt": "Image Prompt" + "images_prompt": "Image Prompt", + "summarization_prompt": "Summarization Prompt", + "all_tagging": "All Tagging", + "text_tagging": "Text Tagging", + "image_tagging": "Image Tagging", + "summarization": "Summarization" }, "feeds": { "rss_subscriptions": "RSS Subscriptions", |
