Skip to content

Commit 95ac1a6

Browse files
authored
♻️ Front-end services bug fix
2 parents e5e2801 + 72e6145 commit 95ac1a6

File tree

8 files changed

+23
-22
lines changed

8 files changed

+23
-22
lines changed

frontend/app/[locale]/chat/internal/chatInterface.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { useRouter } from "next/navigation";
77
import { v4 as uuidv4 } from "uuid";
88
import { useTranslation } from "react-i18next";
99

10-
import { ROLE_ASSISTANT} from "@/const/agentConfig";
10+
import { ROLE_ASSISTANT } from "@/const/agentConfig";
11+
import { chatConfig } from "@/const/chatConfig";
1112
import { USER_ROLES } from "@/const/modelConfig";
1213
import { useConfig } from "@/hooks/useConfig";
1314
import { useAuth } from "@/hooks/useAuth";
@@ -452,7 +453,7 @@ export function ChatInterface() {
452453
contents: [
453454
{
454455
id: `preprocess-content-${Date.now()}`,
455-
type: "preprocess",
456+
type: chatConfig.contentTypes.PREPROCESS,
456457
content: t("chatInterface.parsingFile"),
457458
expanded: false,
458459
timestamp: Date.now(),
@@ -499,7 +500,7 @@ export function ChatInterface() {
499500
contents: [
500501
{
501502
id: `preprocess-content-${Date.now()}`,
502-
type: "preprocess",
503+
type: chatConfig.contentTypes.PREPROCESS,
503504
content: t("chatInterface.parsingFile"),
504505
expanded: false,
505506
timestamp: Date.now(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export function ChatStreamMain({
123123
assistantId: message.id,
124124
relatedUserMsgId: currentUserMsgId,
125125
// For preprocess messages, include the full contents array for TaskWindow
126-
contents: content.type === "preprocess" ? step.contents : undefined,
126+
contents: content.type === chatConfig.contentTypes.PREPROCESS ? step.contents : undefined,
127127
};
128128

129129
// Handle truncation messages specially - buffer them instead of adding immediately

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ const iconMap: Record<string, React.ReactNode> = {
3434
const messageHandlers: MessageHandler[] = [
3535
// Preprocess type processor - handles contents array logic
3636
{
37-
canHandle: (message) => message.type === "preprocess",
37+
canHandle: (message) => message.type === chatConfig.contentTypes.PREPROCESS,
3838
render: (message, _t) => {
3939
// For preprocess messages, display content from contents array if available
4040
let displayContent = message.content;
4141
if (message.contents && message.contents.length > 0) {
4242
// Find the latest preprocess content
43-
const preprocessContent = message.contents.find((content: any) => content.type === "preprocess");
43+
const preprocessContent = message.contents.find((content: any) => content.type === chatConfig.contentTypes.PREPROCESS);
4444
if (preprocessContent) {
4545
displayContent = preprocessContent.content;
4646
}

frontend/app/[locale]/setup/agentSetup/components/McpConfigModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ import {
3232
getMcpTools,
3333
updateToolList,
3434
checkMcpServerHealth,
35-
McpServer,
36-
McpTool,
3735
} from "@/services/mcpService";
36+
import { McpServer, McpTool } from "@/types/agentConfig";
3837

3938
const { Text, Title } = Typography;
4039

frontend/app/[locale]/setup/page.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ import { Globe } from "lucide-react";
1212

1313
import { useAuth } from "@/hooks/useAuth";
1414
import { configService } from "@/services/configService";
15-
import modelEngineService, {
16-
ConnectionStatus,
17-
} from "@/services/modelEngineService";
15+
import modelEngineService from "@/services/modelEngineService";
1816
import { configStore } from "@/lib/config";
1917
import { languageOptions } from "@/const/constants";
2018
import { useLanguageSwitch } from "@/lib/language";
2119
import { HEADER_CONFIG } from "@/const/layoutConstants";
22-
import { USER_ROLES, CONNECTION_STATUS } from "@/const/modelConfig";
20+
import { USER_ROLES, CONNECTION_STATUS, ConnectionStatus } from "@/const/modelConfig";
2321

2422
import AppModelConfig from "./modelSetup/config";
2523
import DataConfig from "./knowledgeSetup/config";

frontend/const/modelConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export const CONNECTION_STATUS = {
6161
PROCESSING: "processing"
6262
} as const;
6363

64+
export type ConnectionStatus = (typeof CONNECTION_STATUS)[keyof typeof CONNECTION_STATUS];
65+
6466
// Layout configuration constants
6567
export const LAYOUT_CONFIG = {
6668
CARD_HEADER_PADDING: "10px 24px",

frontend/services/modelEngineService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use client"
22

33
import { API_ENDPOINTS } from './api';
4-
import { CONNECTION_STATUS } from '@/const/modelConfig';
5-
import { ConnectionStatus, ModelEngineCheckResult } from '../types/modelConfig';
4+
import { CONNECTION_STATUS, ConnectionStatus } from '@/const/modelConfig';
5+
import { ModelEngineCheckResult } from '../types/modelConfig';
66

77
import { fetchWithAuth } from '@/lib/auth';
88

frontend/services/modelService.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { API_ENDPOINTS } from './api'
55
import { ModelOption, ModelType, ModelConnectStatus, ModelValidationResponse, ModelSource, ApiResponse } from '../types/modelConfig'
66

77
import { getAuthHeaders } from '@/lib/auth'
8-
import {STATUS_CODES} from "@/types/auth";
8+
import {STATUS_CODES} from "@/const/auth";
9+
import { MODEL_TYPES, MODEL_SOURCES } from '@/const/modelConfig';
910

1011
// Error class
1112
export class ModelError extends Error {
@@ -39,12 +40,12 @@ export const modelService = {
3940
if (response.status === STATUS_CODES.SUCCESS && result.data) {
4041
const modelOptions: ModelOption[] = []
4142
const typeMap: Record<string, ModelType> = {
42-
embed: "embedding",
43-
chat: "llm",
44-
asr: "stt",
45-
tts: "tts",
46-
rerank: "rerank",
47-
vlm: "vlm"
43+
embed: MODEL_TYPES.EMBEDDING,
44+
chat: MODEL_TYPES.LLM,
45+
asr: MODEL_TYPES.STT,
46+
tts: MODEL_TYPES.TTS,
47+
rerank: MODEL_TYPES.RERANK,
48+
vlm: MODEL_TYPES.VLM
4849
}
4950

5051
for (const model of result.data) {
@@ -54,7 +55,7 @@ export const modelService = {
5455
name: model.id,
5556
type: typeMap[model.type],
5657
maxTokens: 0,
57-
source: "OpenAI-API-Compatible",
58+
source: MODEL_SOURCES.OPENAI_API_COMPATIBLE,
5859
apiKey: model.api_key,
5960
apiUrl: model.base_url,
6061
displayName: model.id

0 commit comments

Comments
 (0)