From b8bd7d7eb27aaaadae728599f64a0874f66196ea Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 12 Jan 2025 15:31:30 +0000 Subject: feat: Support customizing the summarization prompt. Fixes #731 --- apps/web/components/settings/AISettings.tsx | 57 ++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 10 deletions(-) (limited to 'apps/web/components/settings') 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() { - All - Text - Images + + {t("settings.ai.all_tagging")} + + + {t("settings.ai.text_tagging")} + + + {t("settings.ai.image_tagging")} + + + {t("settings.ai.summarization")} + @@ -214,9 +227,18 @@ export function PromptRow({ prompt }: { prompt: ZPrompt }) { - All - Text - Images + + {t("settings.ai.all_tagging")} + + + {t("settings.ai.text_tagging")} + + + {t("settings.ai.image_tagging")} + + + {t("settings.ai.summarization")} + @@ -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\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()} +

{t("settings.ai.summarization_prompt")}

+ + {buildSummaryPrompt( + clientConfig.inference.inferredTagLang, + (prompts ?? []) + .filter((p) => p.appliesTo == "summary") + .map((p) => p.text), + "\n\n", + /* context length */ 1024 /* The value here doesn't matter */, + ).trim()} + ); } -- cgit v1.2.3-70-g09d2