feat(agent-mui): add agent canvas, nodes, and related components
docs(agent-hooks-guide): add comprehensive guide for agent hooks usage and implementation
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
import { ChatVariableEnabledField, variableEnabledFieldMap } from './chat';
|
||||
|
||||
export function setInitialChatVariableEnabledFieldValue(
|
||||
field: ChatVariableEnabledField,
|
||||
) {
|
||||
return false;
|
||||
return field !== ChatVariableEnabledField.MaxTokensEnabled;
|
||||
}
|
||||
|
||||
export enum ProgrammingLanguage {
|
||||
Python = 'python',
|
||||
Javascript = 'javascript',
|
||||
@@ -25,6 +34,26 @@ export enum AgentGlobals {
|
||||
SysFiles = 'sys.files',
|
||||
}
|
||||
|
||||
export const AgentGlobalsSysQueryWithBrace = `{${AgentGlobals.SysQuery}}`;
|
||||
|
||||
export const variableCheckBoxFieldMap = Object.keys(
|
||||
variableEnabledFieldMap,
|
||||
).reduce<Record<string, boolean>>((pre, cur) => {
|
||||
pre[cur] = setInitialChatVariableEnabledFieldValue(
|
||||
cur as ChatVariableEnabledField,
|
||||
);
|
||||
return pre;
|
||||
}, {});
|
||||
|
||||
export const initialLlmBaseValues = {
|
||||
...variableCheckBoxFieldMap,
|
||||
temperature: 0.1,
|
||||
top_p: 0.3,
|
||||
frequency_penalty: 0.7,
|
||||
presence_penalty: 0.4,
|
||||
max_tokens: 256,
|
||||
};
|
||||
|
||||
export enum AgentCategory {
|
||||
AgentCanvas = 'agent_canvas',
|
||||
DataflowCanvas = 'dataflow_canvas',
|
||||
|
||||
40
src/constants/chat.ts
Normal file
40
src/constants/chat.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
export enum MessageType {
|
||||
Assistant = 'assistant',
|
||||
User = 'user',
|
||||
}
|
||||
|
||||
export enum ChatVariableEnabledField {
|
||||
TemperatureEnabled = 'temperatureEnabled',
|
||||
TopPEnabled = 'topPEnabled',
|
||||
PresencePenaltyEnabled = 'presencePenaltyEnabled',
|
||||
FrequencyPenaltyEnabled = 'frequencyPenaltyEnabled',
|
||||
MaxTokensEnabled = 'maxTokensEnabled',
|
||||
}
|
||||
|
||||
export const variableEnabledFieldMap = {
|
||||
[ChatVariableEnabledField.TemperatureEnabled]: 'temperature',
|
||||
[ChatVariableEnabledField.TopPEnabled]: 'top_p',
|
||||
[ChatVariableEnabledField.PresencePenaltyEnabled]: 'presence_penalty',
|
||||
[ChatVariableEnabledField.FrequencyPenaltyEnabled]: 'frequency_penalty',
|
||||
[ChatVariableEnabledField.MaxTokensEnabled]: 'max_tokens',
|
||||
};
|
||||
|
||||
export enum SharedFrom {
|
||||
Agent = 'agent',
|
||||
Chat = 'chat',
|
||||
Search = 'search',
|
||||
}
|
||||
|
||||
export enum ChatSearchParams {
|
||||
DialogId = 'dialogId',
|
||||
ConversationId = 'conversationId',
|
||||
isNew = 'isNew',
|
||||
}
|
||||
|
||||
export const EmptyConversationId = 'empty';
|
||||
|
||||
export enum DatasetMetadata {
|
||||
Disabled = 'disabled',
|
||||
Automatic = 'automatic',
|
||||
Manual = 'manual',
|
||||
}
|
||||
@@ -1,113 +1,97 @@
|
||||
// object freeze
|
||||
export const KNOWLEDGE_ROUTE_KEYS = Object.freeze({
|
||||
Dataset: 'dataset',
|
||||
Testing: 'testing',
|
||||
Configuration: 'configuration',
|
||||
KnowledgeGraph: 'knowledgeGraph',
|
||||
} as const)
|
||||
export enum KnowledgeRouteKey {
|
||||
Dataset = 'dataset',
|
||||
Testing = 'testing',
|
||||
Configuration = 'configuration',
|
||||
KnowledgeGraph = 'knowledgeGraph',
|
||||
}
|
||||
|
||||
export type KnowledgeRouteKey = (typeof KNOWLEDGE_ROUTE_KEYS)[keyof typeof KNOWLEDGE_ROUTE_KEYS]
|
||||
export const DatasetBaseKey = 'dataset';
|
||||
|
||||
export const RUNNING_STATUS_KEYS = Object.freeze({
|
||||
UNSTART: '0', // need to run
|
||||
RUNNING: '1', // need to cancel
|
||||
CANCEL: '2', // need to refresh
|
||||
DONE: '3', // need to refresh
|
||||
FAIL: '4', // need to refresh
|
||||
} as const)
|
||||
|
||||
export type RunningStatus = (typeof RUNNING_STATUS_KEYS)[keyof typeof RUNNING_STATUS_KEYS]
|
||||
export enum RunningStatus {
|
||||
UNSTART = '0', // need to run
|
||||
RUNNING = '1', // need to cancel
|
||||
CANCEL = '2', // need to refresh
|
||||
DONE = '3', // need to refresh
|
||||
FAIL = '4', // need to refresh
|
||||
}
|
||||
|
||||
export const RunningStatusMap = {
|
||||
[RUNNING_STATUS_KEYS.UNSTART]: 'Pending',
|
||||
[RUNNING_STATUS_KEYS.RUNNING]: 'Running',
|
||||
[RUNNING_STATUS_KEYS.CANCEL]: 'Cancel',
|
||||
[RUNNING_STATUS_KEYS.DONE]: 'Success',
|
||||
[RUNNING_STATUS_KEYS.FAIL]: 'Failed',
|
||||
} as const;
|
||||
|
||||
export const MODEL_VARIABLE_TYPES = Object.freeze({
|
||||
Improvise: 'Improvise',
|
||||
Precise: 'Precise',
|
||||
Balance: 'Balance',
|
||||
} as const)
|
||||
|
||||
export type ModelVariableType = (typeof MODEL_VARIABLE_TYPES)[keyof typeof MODEL_VARIABLE_TYPES]
|
||||
[RunningStatus.UNSTART]: 'Pending',
|
||||
[RunningStatus.RUNNING]: 'Running',
|
||||
[RunningStatus.CANCEL]: 'Cancel',
|
||||
[RunningStatus.DONE]: 'Success',
|
||||
[RunningStatus.FAIL]: 'Failed',
|
||||
};
|
||||
|
||||
export enum ModelVariableType {
|
||||
Improvise = 'Improvise',
|
||||
Precise = 'Precise',
|
||||
Balance = 'Balance',
|
||||
}
|
||||
|
||||
export const settledModelVariableMap = {
|
||||
[MODEL_VARIABLE_TYPES.Improvise]: {
|
||||
[ModelVariableType.Improvise]: {
|
||||
temperature: 0.8,
|
||||
top_p: 0.9,
|
||||
frequency_penalty: 0.1,
|
||||
presence_penalty: 0.1,
|
||||
max_tokens: 4096,
|
||||
},
|
||||
[MODEL_VARIABLE_TYPES.Precise]: {
|
||||
[ModelVariableType.Precise]: {
|
||||
temperature: 0.2,
|
||||
top_p: 0.75,
|
||||
frequency_penalty: 0.5,
|
||||
presence_penalty: 0.5,
|
||||
max_tokens: 4096,
|
||||
},
|
||||
[MODEL_VARIABLE_TYPES.Balance]: {
|
||||
[ModelVariableType.Balance]: {
|
||||
temperature: 0.5,
|
||||
top_p: 0.85,
|
||||
frequency_penalty: 0.3,
|
||||
presence_penalty: 0.2,
|
||||
max_tokens: 4096,
|
||||
},
|
||||
} as const;
|
||||
};
|
||||
|
||||
export const LLM_MODEL_TYPES = Object.freeze({
|
||||
Embedding: 'embedding',
|
||||
Chat: 'chat',
|
||||
Image2text: 'image2text',
|
||||
Speech2text: 'speech2text',
|
||||
Rerank: 'rerank',
|
||||
TTS: 'tts',
|
||||
} as const)
|
||||
export enum LlmModelType {
|
||||
Embedding = 'embedding',
|
||||
Chat = 'chat',
|
||||
Image2text = 'image2text',
|
||||
Speech2text = 'speech2text',
|
||||
Rerank = 'rerank',
|
||||
TTS = 'tts',
|
||||
}
|
||||
|
||||
export type LlmModelType = (typeof LLM_MODEL_TYPES)[keyof typeof LLM_MODEL_TYPES]
|
||||
export enum KnowledgeSearchParams {
|
||||
DocumentId = 'doc_id',
|
||||
KnowledgeId = 'id',
|
||||
Type = 'type',
|
||||
}
|
||||
|
||||
export const DOCUMENT_TYPES = Object.freeze({
|
||||
Virtual: 'virtual',
|
||||
Visual: 'visual',
|
||||
} as const)
|
||||
export enum DocumentType {
|
||||
Virtual = 'virtual',
|
||||
Visual = 'visual',
|
||||
}
|
||||
|
||||
export type DocumentType = (typeof DOCUMENT_TYPES)[keyof typeof DOCUMENT_TYPES]
|
||||
|
||||
export const DOCUMENT_PARSER_TYPES = Object.freeze({
|
||||
Naive: 'naive',
|
||||
Qa: 'qa',
|
||||
Resume: 'resume',
|
||||
Manual: 'manual',
|
||||
Table: 'table',
|
||||
Paper: 'paper',
|
||||
Book: 'book',
|
||||
Laws: 'laws',
|
||||
Presentation: 'presentation',
|
||||
Picture: 'picture',
|
||||
One: 'one',
|
||||
Audio: 'audio',
|
||||
Email: 'email',
|
||||
Tag: 'tag',
|
||||
KnowledgeGraph: 'knowledge_graph',
|
||||
} as const)
|
||||
|
||||
export type DocumentParserType = (typeof DOCUMENT_PARSER_TYPES)[keyof typeof DOCUMENT_PARSER_TYPES]
|
||||
|
||||
export const KNOWLEDGE_SEARCH_PARAMS_KEYS = Object.freeze({
|
||||
DocumentId: 'doc_id',
|
||||
KnowledgeId: 'id',
|
||||
Type: 'type',
|
||||
} as const)
|
||||
|
||||
export type KnowledgeSearchParams = (typeof KNOWLEDGE_SEARCH_PARAMS_KEYS)[keyof typeof KNOWLEDGE_SEARCH_PARAMS_KEYS]
|
||||
|
||||
export const DATABASE_BASE_KEY = 'dataset';
|
||||
export enum DocumentParserType {
|
||||
Naive = 'naive',
|
||||
Qa = 'qa',
|
||||
Resume = 'resume',
|
||||
Manual = 'manual',
|
||||
Table = 'table',
|
||||
Paper = 'paper',
|
||||
Book = 'book',
|
||||
Laws = 'laws',
|
||||
Presentation = 'presentation',
|
||||
Picture = 'picture',
|
||||
One = 'one',
|
||||
Audio = 'audio',
|
||||
Email = 'email',
|
||||
Tag = 'tag',
|
||||
KnowledgeGraph = 'knowledge_graph',
|
||||
}
|
||||
|
||||
export enum ParseType {
|
||||
BuildIn = '1',
|
||||
Pipeline = '2',
|
||||
Pipeline = '2'
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import { LLM_MODEL_TYPES, type LlmModelType } from "@/constants/knowledge";
|
||||
import { DocumentParserType, LlmModelType } from "@/constants/knowledge";
|
||||
import type { IThirdOAIModelCollection, IThirdOAIModel } from "@/interfaces/database/llm";
|
||||
import userService from "@/services/user_service";
|
||||
|
||||
@@ -121,7 +121,7 @@ export function useLlmOptionsByModelType() {
|
||||
* @returns 嵌入模型选项列表
|
||||
*/
|
||||
export function useEmbeddingModelOptions() {
|
||||
return useLlmOptions(LLM_MODEL_TYPES.Embedding);
|
||||
return useLlmOptions(LlmModelType.Embedding);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ export function useEmbeddingModelOptions() {
|
||||
* @returns 聊天模型选项列表
|
||||
*/
|
||||
export function useChatModelOptions() {
|
||||
return useLlmOptions(LLM_MODEL_TYPES.Chat);
|
||||
return useLlmOptions(LlmModelType.Chat);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ export function useChatModelOptions() {
|
||||
* @returns 重排序模型选项列表
|
||||
*/
|
||||
export function useRerankModelOptions() {
|
||||
return useLlmOptions(LLM_MODEL_TYPES.Rerank);
|
||||
return useLlmOptions(LlmModelType.Rerank);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +145,7 @@ export function useRerankModelOptions() {
|
||||
* @returns 图像转文本模型选项列表
|
||||
*/
|
||||
export function useImage2TextModelOptions() {
|
||||
return useLlmOptions(LLM_MODEL_TYPES.Image2text);
|
||||
return useLlmOptions(LlmModelType.Image2text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ export function useImage2TextModelOptions() {
|
||||
* @returns 语音转文本模型选项列表
|
||||
*/
|
||||
export function useSpeech2TextModelOptions() {
|
||||
return useLlmOptions(LLM_MODEL_TYPES.Speech2text);
|
||||
return useLlmOptions(LlmModelType.Speech2text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ export function useSpeech2TextModelOptions() {
|
||||
* @returns 文本转语音模型选项列表
|
||||
*/
|
||||
export function useTTSModelOptions() {
|
||||
return useLlmOptions(LLM_MODEL_TYPES.TTS);
|
||||
return useLlmOptions(LlmModelType.TTS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,8 +4,8 @@ import { ReactFlow, Background, MiniMap, Controls, SmoothStepEdge } from '@xyflo
|
||||
import '@xyflow/react/dist/style.css';
|
||||
import agentService from '@/services/agent_service';
|
||||
import type { IAgentVersionItem, IAgent, IGraph } from '@/interfaces/database/agent';
|
||||
import ReadonlyNode from '@/pages/agent/canvas/node/ReadonlyNode';
|
||||
import NoteNode from '@/pages/agent/canvas/node/NoteNode';
|
||||
import ReadonlyNode from '../canvas/node/ReadonlyNode';
|
||||
import NoteNode from '../canvas/node/NoteNode';
|
||||
|
||||
function sanitizeGraph(g?: IGraph | null): IGraph | null {
|
||||
if (!g) return null;
|
||||
@@ -2,10 +2,10 @@ import { Box, Typography, Alert, CircularProgress } from "@mui/material";
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useAgentDetail } from '@/hooks/agent-hooks';
|
||||
import { useState } from 'react';
|
||||
import AgentTopbar from '@/pages/agent/components/AgentTopbar';
|
||||
import AgentCanvas from '@/pages/agent/canvas';
|
||||
import VersionListDialog from '@/pages/agent/components/VersionListDialog';
|
||||
import EditAgentDialog from '@/pages/agent/components/EditAgentDialog';
|
||||
import AgentTopbar from './components/AgentTopbar';
|
||||
import AgentCanvas from './canvas';
|
||||
import VersionListDialog from './components/VersionListDialog';
|
||||
import EditAgentDialog from './components/EditAgentDialog';
|
||||
import dayjs from "dayjs";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
import { Search as SearchIcon, Refresh as RefreshIcon, Add as AddIcon } from '@mui/icons-material';
|
||||
import { useAgentList, useAgentOperations } from '@/hooks/agent-hooks';
|
||||
import AgentGridView from '@/components/agent/AgentGridView';
|
||||
import CreateAgentDialog from '@/pages/agent/components/CreateAgentDialog';
|
||||
import EditAgentDialog from '@/pages/agent/components/EditAgentDialog';
|
||||
import CreateAgentDialog from './components/CreateAgentDialog';
|
||||
import EditAgentDialog from './components/EditAgentDialog';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useDialog } from '@/hooks/useDialog';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Card,
|
||||
CardContent,
|
||||
} from '@mui/material';
|
||||
import { DOCUMENT_PARSER_TYPES, ParseType, type DocumentParserType } from '@/constants/knowledge';
|
||||
import { DocumentParserType, ParseType } from '@/constants/knowledge';
|
||||
import { type IParserConfig } from '@/interfaces/database/knowledge';
|
||||
import {
|
||||
NaiveConfiguration,
|
||||
@@ -31,21 +31,21 @@ import { RadioFormField } from '@/components/FormField';
|
||||
|
||||
// 配置组件映射表
|
||||
const ConfigurationComponentMap = {
|
||||
[DOCUMENT_PARSER_TYPES.Naive]: NaiveConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Qa]: QAConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Resume]: ResumeConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Manual]: ManualConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Table]: TableConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Paper]: PaperConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Book]: BookConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Laws]: LawsConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Presentation]: PresentationConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.One]: OneConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Tag]: TagConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.KnowledgeGraph]: TagConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Picture]: TagConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Audio]: TagConfiguration,
|
||||
[DOCUMENT_PARSER_TYPES.Email]: TagConfiguration,
|
||||
[DocumentParserType.Naive]: NaiveConfiguration,
|
||||
[DocumentParserType.Qa]: QAConfiguration,
|
||||
[DocumentParserType.Resume]: ResumeConfiguration,
|
||||
[DocumentParserType.Manual]: ManualConfiguration,
|
||||
[DocumentParserType.Table]: TableConfiguration,
|
||||
[DocumentParserType.Paper]: PaperConfiguration,
|
||||
[DocumentParserType.Book]: BookConfiguration,
|
||||
[DocumentParserType.Laws]: LawsConfiguration,
|
||||
[DocumentParserType.Presentation]: PresentationConfiguration,
|
||||
[DocumentParserType.One]: OneConfiguration,
|
||||
[DocumentParserType.Tag]: TagConfiguration,
|
||||
[DocumentParserType.KnowledgeGraph]: TagConfiguration,
|
||||
[DocumentParserType.Picture]: TagConfiguration,
|
||||
[DocumentParserType.Audio]: TagConfiguration,
|
||||
[DocumentParserType.Email]: TagConfiguration,
|
||||
// [DOCUMENT_PARSER_TYPES.KnowledgeGraph]: KnowledgeGraphConfiguration,
|
||||
// [DOCUMENT_PARSER_TYPES.Picture]: PictureConfiguration,
|
||||
// [DOCUMENT_PARSER_TYPES.Audio]: AudioConfiguration,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useForm, FormProvider } from 'react-hook-form';
|
||||
import GeneralForm from './GeneralForm';
|
||||
import { RadioFormField } from '@/components/FormField';
|
||||
import { ChunkMethodItem, PipelineSelectorItem } from '../configuration';
|
||||
import { DOCUMENT_PARSER_TYPES, ParseType } from '@/constants/knowledge';
|
||||
import { DocumentParserType, ParseType } from '@/constants/knowledge';
|
||||
import { useKnowledgeOperations } from '@/hooks/knowledge-hooks';
|
||||
import { useSnackbar } from '@/components/Provider/SnackbarProvider';
|
||||
|
||||
@@ -38,7 +38,7 @@ function CreateKnowledgeDialog({ open, onClose, onSuccess }: CreateKnowledgeDial
|
||||
pagerank: 0,
|
||||
embd_id: '',
|
||||
// 解析相关
|
||||
parser_id: DOCUMENT_PARSER_TYPES.Naive,
|
||||
parser_id: DocumentParserType.Naive,
|
||||
pipeline_id: '',
|
||||
parseType: ParseType.BuildIn,
|
||||
},
|
||||
|
||||
@@ -52,7 +52,7 @@ import { DataGrid, type GridColDef, type GridRowSelectionModel } from '@mui/x-da
|
||||
import { zhCN, enUS } from '@mui/x-data-grid/locales';
|
||||
import type { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import type { IDocumentInfoFilter } from '@/interfaces/database/document';
|
||||
import { RUNNING_STATUS_KEYS, type RunningStatus } from '@/constants/knowledge';
|
||||
import { RunningStatus } from '@/constants/knowledge';
|
||||
import { LanguageAbbreviation } from '@/locales';
|
||||
import dayjs from 'dayjs';
|
||||
import logger from '@/utils/logger';
|
||||
@@ -92,11 +92,11 @@ interface DocumentListComponentProps {
|
||||
|
||||
const getRunStatusLabel = (status: string) => {
|
||||
const statusLabels = {
|
||||
[RUNNING_STATUS_KEYS.UNSTART]: translate('knowledge.runStatus.unstart'),
|
||||
[RUNNING_STATUS_KEYS.RUNNING]: translate('knowledge.runStatus.running'),
|
||||
[RUNNING_STATUS_KEYS.CANCEL]: translate('knowledge.runStatus.cancel'),
|
||||
[RUNNING_STATUS_KEYS.DONE]: translate('knowledge.runStatus.done'),
|
||||
[RUNNING_STATUS_KEYS.FAIL]: translate('knowledge.runStatus.fail'),
|
||||
[RunningStatus.UNSTART]: translate('knowledge.runStatus.unstart'),
|
||||
[RunningStatus.RUNNING]: translate('knowledge.runStatus.running'),
|
||||
[RunningStatus.CANCEL]: translate('knowledge.runStatus.cancel'),
|
||||
[RunningStatus.DONE]: translate('knowledge.runStatus.done'),
|
||||
[RunningStatus.FAIL]: translate('knowledge.runStatus.fail'),
|
||||
};
|
||||
return statusLabels[status as keyof typeof statusLabels] || translate('knowledge.runStatus.unknown');
|
||||
};
|
||||
@@ -146,16 +146,16 @@ const getStatusChip = (status: string) => {
|
||||
|
||||
const getRunStatusChip = (run: RunningStatus, progress: number) => {
|
||||
const statusConfig = {
|
||||
[RUNNING_STATUS_KEYS.UNSTART]: { label: translate('knowledge.runStatus.unstart'), color: 'default' as const },
|
||||
[RUNNING_STATUS_KEYS.RUNNING]: { label: translate('knowledge.runStatus.parsing'), color: 'info' as const },
|
||||
[RUNNING_STATUS_KEYS.CANCEL]: { label: translate('knowledge.runStatus.cancel'), color: 'warning' as const },
|
||||
[RUNNING_STATUS_KEYS.DONE]: { label: translate('knowledge.runStatus.done'), color: 'success' as const },
|
||||
[RUNNING_STATUS_KEYS.FAIL]: { label: translate('knowledge.runStatus.fail'), color: 'error' as const },
|
||||
[RunningStatus.UNSTART]: { label: translate('knowledge.runStatus.unstart'), color: 'default' as const },
|
||||
[RunningStatus.RUNNING]: { label: translate('knowledge.runStatus.parsing'), color: 'info' as const },
|
||||
[RunningStatus.CANCEL]: { label: translate('knowledge.runStatus.cancel'), color: 'warning' as const },
|
||||
[RunningStatus.DONE]: { label: translate('knowledge.runStatus.done'), color: 'success' as const },
|
||||
[RunningStatus.FAIL]: { label: translate('knowledge.runStatus.fail'), color: 'error' as const },
|
||||
};
|
||||
|
||||
const config = statusConfig[run] || { label: translate('knowledge.runStatus.unknown'), color: 'default' as const };
|
||||
|
||||
if (run === RUNNING_STATUS_KEYS.RUNNING) {
|
||||
if (run === RunningStatus.RUNNING) {
|
||||
return (
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||
<CircularProgress size={16} />
|
||||
@@ -648,7 +648,7 @@ const DocumentListComponent: React.FC<DocumentListComponentProps> = ({
|
||||
<PlayIcon sx={{ mr: 1 }} />
|
||||
<Typography>{t('knowledge.reparse')}</Typography>
|
||||
</MenuItem>
|
||||
{selectedFile?.run === RUNNING_STATUS_KEYS.RUNNING && (
|
||||
{selectedFile?.run === RunningStatus.RUNNING && (
|
||||
<MenuItem onClick={handleCancelRun}>
|
||||
<StopIcon sx={{ mr: 1 }} />
|
||||
<Typography>{t('knowledge.cancelRun')}</Typography>
|
||||
|
||||
@@ -14,7 +14,7 @@ import { Shuffle as ShuffleIcon } from '@mui/icons-material';
|
||||
import { useFormContext, Controller } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { t as translate } from 'i18next';
|
||||
import { DOCUMENT_PARSER_TYPES, LLM_MODEL_TYPES, type LlmModelType } from '@/constants/knowledge';
|
||||
import { DocumentParserType, LlmModelType } from '@/constants/knowledge';
|
||||
import { AgentCategory } from '@/constants/agent';
|
||||
import { useSelectChunkMethodList } from '../hooks';
|
||||
import { useEmbeddingModelOptions, useLlmOptionsByModelType } from '@/hooks/llm-hooks';
|
||||
@@ -35,17 +35,17 @@ import { getFactoryIconName } from '@/utils/common';
|
||||
|
||||
// 解析器选项配置
|
||||
const PARSER_OPTIONS = [
|
||||
{ value: DOCUMENT_PARSER_TYPES.Naive, label: 'General', description: translate('knowledge.config.parser.general') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Qa, label: 'Q&A', description: translate('knowledge.config.parser.qa') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Resume, label: 'Resume', description: translate('knowledge.config.parser.resume') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Manual, label: 'Manual', description: translate('knowledge.config.parser.manual') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Table, label: 'Table', description: translate('knowledge.config.parser.table') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Paper, label: 'Paper', description: translate('knowledge.config.parser.paper') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Book, label: 'Book', description: translate('knowledge.config.parser.book') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Laws, label: 'Laws', description: translate('knowledge.config.parser.laws') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Presentation, label: 'Presentation', description: translate('knowledge.config.parser.presentation') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.One, label: 'One', description: translate('knowledge.config.parser.one') },
|
||||
{ value: DOCUMENT_PARSER_TYPES.Tag, label: 'Tag', description: translate('knowledge.config.parser.tag') },
|
||||
{ value: DocumentParserType.Naive, label: 'General', description: translate('knowledge.config.parser.general') },
|
||||
{ value: DocumentParserType.Qa, label: 'Q&A', description: translate('knowledge.config.parser.qa') },
|
||||
{ value: DocumentParserType.Resume, label: 'Resume', description: translate('knowledge.config.parser.resume') },
|
||||
{ value: DocumentParserType.Manual, label: 'Manual', description: translate('knowledge.config.parser.manual') },
|
||||
{ value: DocumentParserType.Table, label: 'Table', description: translate('knowledge.config.parser.table') },
|
||||
{ value: DocumentParserType.Paper, label: 'Paper', description: translate('knowledge.config.parser.paper') },
|
||||
{ value: DocumentParserType.Book, label: 'Book', description: translate('knowledge.config.parser.book') },
|
||||
{ value: DocumentParserType.Laws, label: 'Laws', description: translate('knowledge.config.parser.laws') },
|
||||
{ value: DocumentParserType.Presentation, label: 'Presentation', description: translate('knowledge.config.parser.presentation') },
|
||||
{ value: DocumentParserType.One, label: 'One', description: translate('knowledge.config.parser.one') },
|
||||
{ value: DocumentParserType.Tag, label: 'Tag', description: translate('knowledge.config.parser.tag') },
|
||||
];
|
||||
|
||||
/* ============================================================================
|
||||
@@ -197,7 +197,7 @@ export function LayoutRecognizeItem() {
|
||||
];
|
||||
|
||||
// 获取图像转文本模型选项
|
||||
const image2TextOptions = getOptionsByModelType(LLM_MODEL_TYPES.Image2text);
|
||||
const image2TextOptions = getOptionsByModelType(LlmModelType.Image2text);
|
||||
|
||||
return { basicOptions, image2TextOptions };
|
||||
}, [getOptionsByModelType, t]);
|
||||
|
||||
@@ -24,7 +24,7 @@ import { useKnowledgeOperations, useKnowledgeDetail } from '@/hooks/knowledge-ho
|
||||
import GeneralForm from './components/GeneralForm';
|
||||
import ChunkMethodForm from './components/ChunkMethodForm';
|
||||
import { useSnackbar } from '@/components/Provider/SnackbarProvider';
|
||||
import { DOCUMENT_PARSER_TYPES } from '@/constants/knowledge';
|
||||
import { DocumentParserType } from '@/constants/knowledge';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
function KnowledgeBaseCreate() {
|
||||
@@ -57,7 +57,7 @@ function KnowledgeBaseCreate() {
|
||||
permission: 'me',
|
||||
avatar: undefined,
|
||||
pagerank: 0,
|
||||
parser_id: DOCUMENT_PARSER_TYPES.Naive,
|
||||
parser_id: DocumentParserType.Naive,
|
||||
embd_id: '',
|
||||
parser_config: {
|
||||
chunk_token_num: 512,
|
||||
|
||||
@@ -32,7 +32,7 @@ import FloatingActionButtons from './components/FloatingActionButtons';
|
||||
import KnowledgeBreadcrumbs from './components/KnowledgeBreadcrumbs';
|
||||
import KnowledgeGraphView from './components/KnowledgeGraphView';
|
||||
import { useDocumentList, useDocumentOperations } from '@/hooks/document-hooks';
|
||||
import { RUNNING_STATUS_KEYS } from '@/constants/knowledge';
|
||||
import { RunningStatus } from '@/constants/knowledge';
|
||||
import { useKnowledgeDetail } from '@/hooks/knowledge-hooks';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
@@ -210,7 +210,7 @@ function KnowledgeBaseDetail() {
|
||||
};
|
||||
|
||||
// 检查是否有运行中的文档
|
||||
const hasRunningDocuments = files.some(file => file.run === RUNNING_STATUS_KEYS.RUNNING);
|
||||
const hasRunningDocuments = files.some(file => file.run === RunningStatus.RUNNING);
|
||||
|
||||
// 根据运行状态自动管理轮询
|
||||
useEffect(() => {
|
||||
|
||||
@@ -20,7 +20,7 @@ import GeneralForm from './components/GeneralForm';
|
||||
import ChunkMethodForm, { type ConfigFormData } from './components/ChunkMethodForm';
|
||||
import KnowledgeBreadcrumbs from './components/KnowledgeBreadcrumbs';
|
||||
import { useSnackbar } from '@/components/Provider/SnackbarProvider';
|
||||
import { DOCUMENT_PARSER_TYPES } from '@/constants/knowledge';
|
||||
import { DocumentParserType } from '@/constants/knowledge';
|
||||
import { MainContainer } from './configuration';
|
||||
|
||||
// 统一表单数据类型
|
||||
@@ -74,7 +74,7 @@ function KnowledgeBaseSetting() {
|
||||
description: knowledge.description || '',
|
||||
permission: knowledge.permission || 'me',
|
||||
avatar: knowledge.avatar,
|
||||
parser_id: knowledge.parser_id || DOCUMENT_PARSER_TYPES.Naive,
|
||||
parser_id: knowledge.parser_id || DocumentParserType.Naive,
|
||||
embd_id: knowledge.embd_id || '',
|
||||
pagerank: knowledge.pagerank || 0,
|
||||
parser_config: {
|
||||
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
} from '../components/ModelDialogs';
|
||||
import type { ITenantInfo } from '@/interfaces/database/knowledge';
|
||||
import { useLlmList } from '@/hooks/llm-hooks';
|
||||
import type { LlmModelType } from '@/constants/knowledge';
|
||||
import { LlmModelType } from '@/constants/knowledge';
|
||||
import { useUserData } from '@/hooks/useUserData';
|
||||
import type { ISetApiKeyRequestBody, IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||
import type { ConfigFormItem, ConfigurationFormData, DocLinkConfig } from '../components/Dialog/ConfigurationDialog';
|
||||
@@ -291,12 +291,12 @@ export const useSystemModelSetting = (onSuccess?: () => void) => {
|
||||
}, [llmList]);
|
||||
|
||||
const allModelOptions = useMemo(() => {
|
||||
const llmOptions = getOptionsByModelType('chat');
|
||||
const image2textOptions = getOptionsByModelType('image2text');
|
||||
const embeddingOptions = getOptionsByModelType('embedding');
|
||||
const speech2textOptions = getOptionsByModelType('speech2text');
|
||||
const rerankOptions = getOptionsByModelType('rerank');
|
||||
const ttsOptions = getOptionsByModelType('tts');
|
||||
const llmOptions = getOptionsByModelType(LlmModelType.Chat);
|
||||
const image2textOptions = getOptionsByModelType(LlmModelType.Image2text);
|
||||
const embeddingOptions = getOptionsByModelType(LlmModelType.Embedding);
|
||||
const speech2textOptions = getOptionsByModelType(LlmModelType.Speech2text);
|
||||
const rerankOptions = getOptionsByModelType(LlmModelType.Rerank);
|
||||
const ttsOptions = getOptionsByModelType(LlmModelType.TTS);
|
||||
|
||||
return {
|
||||
llmOptions,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
import MainLayout from '../components/Layout/MainLayout';
|
||||
import SettingLayout from '../components/Layout/SettingLayout';
|
||||
import Login from '../pages/login/Login';
|
||||
import PipelineConfig from '../pages/PipelineConfig';
|
||||
import Dashboard from '../pages/Dashboard';
|
||||
import ModelsResources from '../pages/ModelsResources';
|
||||
import AgentList from '../pages/agent/list';
|
||||
import MainLayout from '@/components/Layout/MainLayout';
|
||||
import SettingLayout from '@/components/Layout/SettingLayout';
|
||||
import Login from '@/pages/login/Login';
|
||||
import PipelineConfig from '@/pages/PipelineConfig';
|
||||
import Dashboard from '@/pages/Dashboard';
|
||||
import ModelsResources from '@/pages/ModelsResources';
|
||||
import AgentList from '@/pages/agent-mui/list';
|
||||
import {
|
||||
KnowledgeBaseList,
|
||||
KnowledgeBaseCreate,
|
||||
@@ -13,19 +13,20 @@ import {
|
||||
KnowledgeBaseSetting,
|
||||
KnowledgeBaseTesting,
|
||||
KnowledgeLogsPage
|
||||
} from '../pages/knowledge';
|
||||
} from '@/pages/knowledge';
|
||||
import {
|
||||
ModelsSetting,
|
||||
SystemSetting,
|
||||
TeamsSetting,
|
||||
ProfileSetting,
|
||||
MCPSetting,
|
||||
} from '../pages/setting';
|
||||
import MCP from '../pages/MCP';
|
||||
import FormFieldTest from '../pages/FormFieldTest';
|
||||
import ChunkParsedResult from '../pages/chunk/parsed-result';
|
||||
import DocumentPreview from '../pages/chunk/document-preview';
|
||||
import AgentDetailPage from '@/pages/agent/detail';
|
||||
} from '@/pages/setting';
|
||||
import MCP from '@/pages/MCP';
|
||||
import FormFieldTest from '@/pages/FormFieldTest';
|
||||
import ChunkParsedResult from '@/pages/chunk/parsed-result';
|
||||
import DocumentPreview from '@/pages/chunk/document-preview';
|
||||
import AgentDetailPage from '@/pages/agent-mui/detail';
|
||||
// import AgentDetailPage from '@/pages/agent';
|
||||
|
||||
const AppRoutes = () => {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user