diff --git a/src/lib/components/notes/NoteEditor.svelte b/src/lib/components/notes/NoteEditor.svelte
index 95aea9c9fb..bbb27311f4 100644
--- a/src/lib/components/notes/NoteEditor.svelte
+++ b/src/lib/components/notes/NoteEditor.svelte
@@ -29,7 +29,7 @@
import { compressImage, copyToClipboard, splitStream } from '$lib/utils';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { uploadFile } from '$lib/apis/files';
- import { chatCompletion } from '$lib/apis/openai';
+ import { chatCompletion, generateOpenAIChatCompletion } from '$lib/apis/openai';
import { config, models, settings, showSidebar, socket, user } from '$lib/stores';
@@ -121,6 +121,9 @@
let showDeleteConfirm = false;
let showAccessControlModal = false;
+ let titleInputFocused = false;
+ let titleGenerating = false;
+
let dragged = false;
let loading = false;
@@ -196,6 +199,81 @@
editor.commands.setContent(note.data.content.html);
};
+ const generateTitleHandler = async () => {
+ const content = note.data.content.md;
+ const DEFAULT_TITLE_GENERATION_PROMPT_TEMPLATE = `### Task:
+Generate a concise, 3-5 word title with an emoji summarizing the content.
+### Guidelines:
+- The title should clearly represent the main theme or subject of the content.
+- Use emojis that enhance understanding of the topic, but avoid quotation marks or special formatting.
+- Write the title in the chat's primary language; default to English if multilingual.
+- Prioritize accuracy over excessive creativity; keep it clear and simple.
+- Your entire response must consist solely of the JSON object, without any introductory or concluding text.
+- The output must be a single, raw JSON object, without any markdown code fences or other encapsulating text.
+- Ensure no conversational text, affirmations, or explanations precede or follow the raw JSON output, as this will cause direct parsing failure.
+### Output:
+JSON format: { "title": "your concise title here" }
+### Examples:
+- { "title": "📉 Stock Market Trends" },
+- { "title": "🍪 Perfect Chocolate Chip Recipe" },
+- { "title": "Evolution of Music Streaming" },
+- { "title": "Remote Work Productivity Tips" },
+- { "title": "Artificial Intelligence in Healthcare" },
+- { "title": "🎮 Video Game Development Insights" }
+### Content:
+