Skip to content

Commit 00306d8

Browse files
committed
♻️ Refactor: Preprocess type adapt frontend consts refactor #1037
1 parent 2f03eb6 commit 00306d8

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

frontend/app/[locale]/chat/streaming/chatStreamHandler.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const handleStreamResponse = async (
7373
| typeof chatConfig.contentTypes.SEARCH_CONTENT
7474
| typeof chatConfig.contentTypes.CARD
7575
| typeof chatConfig.contentTypes.MEMORY_SEARCH
76-
| "preprocess"
76+
| typeof chatConfig.contentTypes.PREPROCESS
7777
| null = null;
7878
let lastModelOutputIndex = -1; // Track the index of the last model output in currentStep.contents
7979
let searchResultsContent: any[] = [];
@@ -749,7 +749,7 @@ export const handleStreamResponse = async (
749749
lastContentType = "memory_search";
750750
break;
751751

752-
case "preprocess":
752+
case chatConfig.contentTypes.PREPROCESS:
753753
// If there's no currentStep, create one
754754
if (!currentStep) {
755755
currentStep = {
@@ -767,7 +767,7 @@ export const handleStreamResponse = async (
767767

768768
const normalizedPreprocessData = {
769769
id: `preprocess-${Date.now()}-${Math.random().toString(36).substring(2, 7)}`,
770-
type: "preprocess" as const,
770+
type: chatConfig.contentTypes.PREPROCESS,
771771
content: messageContent,
772772
expanded: true,
773773
timestamp: Date.now()
@@ -776,7 +776,7 @@ export const handleStreamResponse = async (
776776
currentStep.contents.push(normalizedPreprocessData);
777777

778778
// Update the last processed content type
779-
lastContentType = "preprocess";
779+
lastContentType = chatConfig.contentTypes.PREPROCESS;
780780
break;
781781

782782
default:

frontend/const/chatConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ messageTypes: {
105105
TOKEN_COUNT: "token_count" as const,
106106
SEARCH_CONTENT_PLACEHOLDER: "search_content_placeholder" as const,
107107
VIRTUAL: "virtual" as const,
108+
PREPROCESS: "preprocess" as const,
108109
},
109110

110111
// Content type constants for last content type tracking
@@ -117,6 +118,7 @@ contentTypes: {
117118
SEARCH_CONTENT: "search_content" as const,
118119
CARD: "card" as const,
119120
MEMORY_SEARCH: "memory_search" as const,
121+
PREPROCESS: "preprocess" as const,
120122
},
121123

122124
// TTS status constants

frontend/types/chat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export interface StepContent {
1919
typeof chatConfig.messageTypes.CARD |
2020
typeof chatConfig.messageTypes.SEARCH_CONTENT_PLACEHOLDER |
2121
typeof chatConfig.messageTypes.VIRTUAL |
22-
typeof chatConfig.messageTypes.MEMORY_SEARCH
22+
typeof chatConfig.messageTypes.MEMORY_SEARCH |
23+
typeof chatConfig.messageTypes.PREPROCESS
2324
content: string
2425
expanded: boolean
2526
timestamp: number

0 commit comments

Comments
 (0)