diff --git a/tools/server/webui/src/lib/services/chat.service.ts b/tools/server/webui/src/lib/services/chat.service.ts index 06f961155e..9696beffb4 100644 --- a/tools/server/webui/src/lib/services/chat.service.ts +++ b/tools/server/webui/src/lib/services/chat.service.ts @@ -1,5 +1,4 @@ -import { getJsonHeaders } from '$lib/utils'; -import { formatAttachmentText } from '$lib/utils/attachment-display'; +import { getJsonHeaders, formatAttachmentText } from '$lib/utils'; import { AGENTIC_REGEX } from '$lib/constants/agentic'; import { AttachmentType, MessageRole, ReasoningFormat } from '$lib/enums'; import type { ApiChatMessageContentPart } from '$lib/types/api'; diff --git a/tools/server/webui/src/lib/utils/attachment-display.ts b/tools/server/webui/src/lib/utils/attachment-display.ts index f10662704b..c02c4ab5d3 100644 --- a/tools/server/webui/src/lib/utils/attachment-display.ts +++ b/tools/server/webui/src/lib/utils/attachment-display.ts @@ -6,26 +6,6 @@ import type { DatabaseMessageExtra } from '$lib/types'; -/** - * Formats attachment content for API requests with consistent header style. - * Used when converting message attachments to text content parts. - * - * @param label - Type label (e.g., 'File', 'PDF File', 'MCP Prompt') - * @param name - File or attachment name - * @param content - The actual content to include - * @param extra - Optional extra info to append to name (e.g., server name for MCP) - * @returns Formatted string with header and content - */ -export function formatAttachmentText( - label: string, - name: string, - content: string, - extra?: string -): string { - const header = extra ? `${name} (${extra})` : name; - return `\n\n--- ${label}: ${header} ---\n${content}`; -} - /** * Check if an uploaded file is an MCP prompt */ diff --git a/tools/server/webui/src/lib/utils/formatters.ts b/tools/server/webui/src/lib/utils/formatters.ts index bdf2ca26fd..4e4a7c1aae 100644 --- a/tools/server/webui/src/lib/utils/formatters.ts +++ b/tools/server/webui/src/lib/utils/formatters.ts @@ -123,3 +123,23 @@ export function formatPerformanceTime(ms: number): string { return parts.join(' '); } + +/** + * Formats attachment content for API requests with consistent header style. + * Used when converting message attachments to text content parts. + * + * @param label - Type label (e.g., 'File', 'PDF File', 'MCP Prompt') + * @param name - File or attachment name + * @param content - The actual content to include + * @param extra - Optional extra info to append to name (e.g., server name for MCP) + * @returns Formatted string with header and content + */ +export function formatAttachmentText( + label: string, + name: string, + content: string, + extra?: string +): string { + const header = extra ? `${name} (${extra})` : name; + return `\n\n--- ${label}: ${header} ---\n${content}`; +} diff --git a/tools/server/webui/src/lib/utils/index.ts b/tools/server/webui/src/lib/utils/index.ts index 280dc9a821..5f53c25b45 100644 --- a/tools/server/webui/src/lib/utils/index.ts +++ b/tools/server/webui/src/lib/utils/index.ts @@ -64,7 +64,8 @@ export { formatNumber, formatJsonPretty, formatTime, - formatPerformanceTime + formatPerformanceTime, + formatAttachmentText } from './formatters'; // IME utilities