- {field.help || SETTING_CONFIG_INFO[field.key]} + {@html field.help || SETTING_CONFIG_INFO[field.key]}
{/if} {:else if field.type === 'textarea'} @@ -112,13 +112,28 @@ value={String(localConfig[field.key] ?? '')} onchange={(e) => onConfigChange(field.key, e.currentTarget.value)} placeholder={`Default: ${SETTING_CONFIG_DEFAULT[field.key] ?? 'none'}`} - class="min-h-[100px] w-full md:max-w-2xl" + class="min-h-[10rem] w-full md:max-w-2xl" /> + {#if field.help || SETTING_CONFIG_INFO[field.key]}{field.help || SETTING_CONFIG_INFO[field.key]}
{/if} + + {#if field.key === 'systemMessage'} +--api-key option for the server.',
systemMessage: 'The starting message that defines how model should behave.',
+ showSystemMessage: 'Display the system message at the top of each conversation.',
theme:
'Choose the color theme for the interface. You can choose between System (follows your device settings), Light, or Dark.',
pasteLongTextToFileLen:
diff --git a/tools/server/webui/src/lib/services/chat.ts b/tools/server/webui/src/lib/services/chat.ts
index a6a6812403..c03b764419 100644
--- a/tools/server/webui/src/lib/services/chat.ts
+++ b/tools/server/webui/src/lib/services/chat.ts
@@ -89,7 +89,6 @@ export class ChatService {
custom,
timings_per_token,
// Config options
- systemMessage,
disableReasoningFormat
} = options;
@@ -103,6 +102,7 @@ export class ChatService {
}
})
.filter((msg) => {
+ // Filter out empty system messages
if (msg.role === 'system') {
const content = typeof msg.content === 'string' ? msg.content : '';
@@ -112,10 +112,8 @@ export class ChatService {
return true;
});
- const processedMessages = ChatService.injectSystemMessage(normalizedMessages, systemMessage);
-
const requestBody: ApiChatCompletionRequest = {
- messages: processedMessages.map((msg: ApiChatMessageData) => ({
+ messages: normalizedMessages.map((msg: ApiChatMessageData) => ({
role: msg.role,
content: msg.content
})),
@@ -677,46 +675,6 @@ export class ChatService {
// Utilities
// ─────────────────────────────────────────────────────────────────────────────
- /**
- * Injects a system message at the beginning of the conversation if provided.
- * Checks for existing system messages to avoid duplication.
- *
- * @param messages - Array of chat messages to process
- * @param systemMessage - Optional system message to inject
- * @returns Array of messages with system message injected at the beginning if provided
- * @private
- */
- private static injectSystemMessage(
- messages: ApiChatMessageData[],
- systemMessage?: string
- ): ApiChatMessageData[] {
- const trimmedSystemMessage = systemMessage?.trim();
-
- if (!trimmedSystemMessage) {
- return messages;
- }
-
- if (messages.length > 0 && messages[0].role === 'system') {
- if (messages[0].content !== trimmedSystemMessage) {
- const updatedMessages = [...messages];
- updatedMessages[0] = {
- role: 'system',
- content: trimmedSystemMessage
- };
- return updatedMessages;
- }
-
- return messages;
- }
-
- const systemMsg: ApiChatMessageData = {
- role: 'system',
- content: trimmedSystemMessage
- };
-
- return [systemMsg, ...messages];
- }
-
/**
* Parses error response and creates appropriate error with context information
* @param response - HTTP response object
diff --git a/tools/server/webui/src/lib/services/database.ts b/tools/server/webui/src/lib/services/database.ts
index 185a598c3b..3b24628cff 100644
--- a/tools/server/webui/src/lib/services/database.ts
+++ b/tools/server/webui/src/lib/services/database.ts
@@ -166,6 +166,49 @@ export class DatabaseService {
return rootMessage.id;
}
+ /**
+ * Creates a system prompt message for a conversation.
+ *
+ * @param convId - Conversation ID
+ * @param systemPrompt - The system prompt content (must be non-empty)
+ * @param parentId - Parent message ID (typically the root message)
+ * @returns The created system message
+ * @throws Error if systemPrompt is empty
+ */
+ static async createSystemMessage(
+ convId: string,
+ systemPrompt: string,
+ parentId: string
+ ): Promise