refactor: Use `UrlPrefix` enum for data stream parsing

This commit is contained in:
Aleksander Grygier 2026-02-03 16:31:04 +01:00
parent 6489c33dd5
commit 983b279724
1 changed files with 8 additions and 2 deletions

View File

@ -4,7 +4,13 @@ import {
ATTACHMENT_LABEL_PDF_FILE,
ATTACHMENT_LABEL_MCP_PROMPT
} from '$lib/constants/attachment-labels';
import { AttachmentType, ContentPartType, MessageRole, ReasoningFormat } from '$lib/enums';
import {
AttachmentType,
ContentPartType,
MessageRole,
ReasoningFormat,
UrlPrefix
} from '$lib/enums';
import type { ApiChatMessageContentPart, ApiChatCompletionToolCall } from '$lib/types/api';
import type { DatabaseMessageExtraMcpPrompt } from '$lib/types';
import { modelsStore } from '$lib/stores/models.svelte';
@ -427,7 +433,7 @@ export class ChatService {
for (const line of lines) {
if (abortSignal?.aborted) break;
if (line.startsWith('data: ')) {
if (line.startsWith(UrlPrefix.DATA)) {
const data = line.slice(6);
if (data === '[DONE]') {
streamFinished = true;