Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions frontend/app/[locale]/chat/internal/chatInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/[locale]/chat/streaming/chatStreamMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/[locale]/chat/streaming/taskWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ const iconMap: Record<string, React.ReactNode> = {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import {
getMcpTools,
updateToolList,
checkMcpServerHealth,
McpServer,
McpTool,
} from "@/services/mcpService";
import { McpServer, McpTool } from "@/types/agentConfig";

const { Text, Title } = Typography;

Expand Down
6 changes: 2 additions & 4 deletions frontend/app/[locale]/setup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions frontend/const/modelConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions frontend/services/modelEngineService.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
17 changes: 9 additions & 8 deletions frontend/services/modelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -39,12 +40,12 @@ export const modelService = {
if (response.status === STATUS_CODES.SUCCESS && result.data) {
const modelOptions: ModelOption[] = []
const typeMap: Record<string, ModelType> = {
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) {
Expand All @@ -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
Expand Down