diff --git a/frontend/app/[locale]/chat/internal/chatInterface.tsx b/frontend/app/[locale]/chat/internal/chatInterface.tsx index cea44dbeb..7bfd41fa2 100644 --- a/frontend/app/[locale]/chat/internal/chatInterface.tsx +++ b/frontend/app/[locale]/chat/internal/chatInterface.tsx @@ -7,7 +7,8 @@ import { useRouter } from "next/navigation"; import { v4 as uuidv4 } from "uuid"; import { useTranslation } from "react-i18next"; -import { ROLE_ASSISTANT} from "@/const/agentConfig"; +import { ROLE_ASSISTANT } from "@/const/agentConfig"; +import { chatConfig } from "@/const/chatConfig"; import { USER_ROLES } from "@/const/modelConfig"; import { useConfig } from "@/hooks/useConfig"; import { useAuth } from "@/hooks/useAuth"; @@ -452,7 +453,7 @@ export function ChatInterface() { contents: [ { id: `preprocess-content-${Date.now()}`, - type: "preprocess", + type: chatConfig.contentTypes.PREPROCESS, content: t("chatInterface.parsingFile"), expanded: false, timestamp: Date.now(), @@ -499,7 +500,7 @@ export function ChatInterface() { contents: [ { id: `preprocess-content-${Date.now()}`, - type: "preprocess", + type: chatConfig.contentTypes.PREPROCESS, content: t("chatInterface.parsingFile"), expanded: false, timestamp: Date.now(), diff --git a/frontend/app/[locale]/chat/streaming/chatStreamMain.tsx b/frontend/app/[locale]/chat/streaming/chatStreamMain.tsx index f8702bd80..744bfe8b1 100644 --- a/frontend/app/[locale]/chat/streaming/chatStreamMain.tsx +++ b/frontend/app/[locale]/chat/streaming/chatStreamMain.tsx @@ -123,7 +123,7 @@ export function ChatStreamMain({ assistantId: message.id, relatedUserMsgId: currentUserMsgId, // For preprocess messages, include the full contents array for TaskWindow - contents: content.type === "preprocess" ? step.contents : undefined, + contents: content.type === chatConfig.contentTypes.PREPROCESS ? step.contents : undefined, }; // Handle truncation messages specially - buffer them instead of adding immediately diff --git a/frontend/app/[locale]/chat/streaming/taskWindow.tsx b/frontend/app/[locale]/chat/streaming/taskWindow.tsx index d5cc185bf..c4e6636da 100644 --- a/frontend/app/[locale]/chat/streaming/taskWindow.tsx +++ b/frontend/app/[locale]/chat/streaming/taskWindow.tsx @@ -34,13 +34,13 @@ const iconMap: Record = { const messageHandlers: MessageHandler[] = [ // Preprocess type processor - handles contents array logic { - canHandle: (message) => message.type === "preprocess", + canHandle: (message) => message.type === chatConfig.contentTypes.PREPROCESS, render: (message, _t) => { // For preprocess messages, display content from contents array if available let displayContent = message.content; if (message.contents && message.contents.length > 0) { // Find the latest preprocess content - const preprocessContent = message.contents.find((content: any) => content.type === "preprocess"); + const preprocessContent = message.contents.find((content: any) => content.type === chatConfig.contentTypes.PREPROCESS); if (preprocessContent) { displayContent = preprocessContent.content; } diff --git a/frontend/app/[locale]/setup/agentSetup/components/McpConfigModal.tsx b/frontend/app/[locale]/setup/agentSetup/components/McpConfigModal.tsx index 87fbbc9ab..e431a2fef 100644 --- a/frontend/app/[locale]/setup/agentSetup/components/McpConfigModal.tsx +++ b/frontend/app/[locale]/setup/agentSetup/components/McpConfigModal.tsx @@ -32,9 +32,8 @@ import { getMcpTools, updateToolList, checkMcpServerHealth, - McpServer, - McpTool, } from "@/services/mcpService"; +import { McpServer, McpTool } from "@/types/agentConfig"; const { Text, Title } = Typography; diff --git a/frontend/app/[locale]/setup/page.tsx b/frontend/app/[locale]/setup/page.tsx index 1cd126fcc..89ef6e91f 100644 --- a/frontend/app/[locale]/setup/page.tsx +++ b/frontend/app/[locale]/setup/page.tsx @@ -12,14 +12,12 @@ import { Globe } from "lucide-react"; import { useAuth } from "@/hooks/useAuth"; import { configService } from "@/services/configService"; -import modelEngineService, { - ConnectionStatus, -} from "@/services/modelEngineService"; +import modelEngineService from "@/services/modelEngineService"; import { configStore } from "@/lib/config"; import { languageOptions } from "@/const/constants"; import { useLanguageSwitch } from "@/lib/language"; import { HEADER_CONFIG } from "@/const/layoutConstants"; -import { USER_ROLES, CONNECTION_STATUS } from "@/const/modelConfig"; +import { USER_ROLES, CONNECTION_STATUS, ConnectionStatus } from "@/const/modelConfig"; import AppModelConfig from "./modelSetup/config"; import DataConfig from "./knowledgeSetup/config"; diff --git a/frontend/const/modelConfig.ts b/frontend/const/modelConfig.ts index 9b2d9a87a..055abd513 100644 --- a/frontend/const/modelConfig.ts +++ b/frontend/const/modelConfig.ts @@ -61,6 +61,8 @@ export const CONNECTION_STATUS = { PROCESSING: "processing" } as const; +export type ConnectionStatus = (typeof CONNECTION_STATUS)[keyof typeof CONNECTION_STATUS]; + // Layout configuration constants export const LAYOUT_CONFIG = { CARD_HEADER_PADDING: "10px 24px", diff --git a/frontend/services/modelEngineService.ts b/frontend/services/modelEngineService.ts index 457691acc..8bb314359 100644 --- a/frontend/services/modelEngineService.ts +++ b/frontend/services/modelEngineService.ts @@ -1,8 +1,8 @@ "use client" import { API_ENDPOINTS } from './api'; -import { CONNECTION_STATUS } from '@/const/modelConfig'; -import { ConnectionStatus, ModelEngineCheckResult } from '../types/modelConfig'; +import { CONNECTION_STATUS, ConnectionStatus } from '@/const/modelConfig'; +import { ModelEngineCheckResult } from '../types/modelConfig'; import { fetchWithAuth } from '@/lib/auth'; diff --git a/frontend/services/modelService.ts b/frontend/services/modelService.ts index 4c0b240f5..443fd53a8 100644 --- a/frontend/services/modelService.ts +++ b/frontend/services/modelService.ts @@ -5,7 +5,8 @@ import { API_ENDPOINTS } from './api' import { ModelOption, ModelType, ModelConnectStatus, ModelValidationResponse, ModelSource, ApiResponse } from '../types/modelConfig' import { getAuthHeaders } from '@/lib/auth' -import {STATUS_CODES} from "@/types/auth"; +import {STATUS_CODES} from "@/const/auth"; +import { MODEL_TYPES, MODEL_SOURCES } from '@/const/modelConfig'; // Error class export class ModelError extends Error { @@ -39,12 +40,12 @@ export const modelService = { if (response.status === STATUS_CODES.SUCCESS && result.data) { const modelOptions: ModelOption[] = [] const typeMap: Record = { - embed: "embedding", - chat: "llm", - asr: "stt", - tts: "tts", - rerank: "rerank", - vlm: "vlm" + embed: MODEL_TYPES.EMBEDDING, + chat: MODEL_TYPES.LLM, + asr: MODEL_TYPES.STT, + tts: MODEL_TYPES.TTS, + rerank: MODEL_TYPES.RERANK, + vlm: MODEL_TYPES.VLM } for (const model of result.data) { @@ -54,7 +55,7 @@ export const modelService = { name: model.id, type: typeMap[model.type], maxTokens: 0, - source: "OpenAI-API-Compatible", + source: MODEL_SOURCES.OPENAI_API_COMPATIBLE, apiKey: model.api_key, apiUrl: model.base_url, displayName: model.id