style(web): translate the comments in the src/views directory into English

This commit is contained in:
zhaoying
2026-02-03 18:38:04 +08:00
parent a191e32f71
commit 9e195ea63b
155 changed files with 4169 additions and 586 deletions

View File

@@ -1,9 +1,24 @@
/*
* @Author: ZhaoYing
* @Date: 2026-02-03 17:30:51
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-02-03 17:30:51
*/
/**
* Card Component
* Collapsible card wrapper for configuration sections
*/
import { type FC, type ReactNode } from 'react'
import { useTranslation } from 'react-i18next'
import clsx from 'clsx';
import RbCard from '@/components/RbCard/Card'
import down from '@/assets/images/userMemory/down.svg'
/**
* Component props
*/
interface CardProps {
type?: string;
title: string | ReactNode;
@@ -35,7 +50,7 @@ const Card: FC<CardProps> = ({
headerType="borderless"
extra={type && handleExpand && (
<div
className="rb:flex rb:items-center rb:text-[14px] rb:text-[#5B6167] rb:cursor-pointer rb:font-regular rb:leading-[20px]"
className="rb:flex rb:items-center rb:text-[14px] rb:text-[#5B6167] rb:cursor-pointer rb:font-regular rb:leading-5"
onClick={() => handleExpand(type)}
>
{expanded ? t('common.foldUp') : t('common.expanded')}

View File

@@ -1,9 +1,23 @@
/*
* @Author: ZhaoYing
* @Date: 2026-02-03 17:30:11
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-02-03 17:30:11
*/
/**
* Result Component
* Displays real-time extraction results with progress tracking
* Shows text preprocessing, knowledge extraction, node/edge creation, and deduplication
*/
import { type FC, useState } from 'react'
import { useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Space, Button, Progress } from 'antd'
import { ExclamationCircleFilled, CheckCircleFilled, ClockCircleOutlined, LoadingOutlined } from '@ant-design/icons'
import clsx from 'clsx'
import type { AnyObject } from 'antd/es/_util/type';
import Card from './Card'
import RbCard from '@/components/RbCard/Card'
import RbAlert from '@/components/RbAlert'
@@ -13,18 +27,24 @@ import { type SSEMessage } from '@/utils/stream'
import Tag, { type TagProps } from '@/components/Tag'
import Markdown from '@/components/Markdown'
import { groupDataByType } from '../constant'
import type { AnyObject } from 'antd/es/_util/type';
/** Result metric mapping */
const resultObj = {
extractTheNumberOfEntities: 'entities.extracted_count',
numberOfEntityDisambiguation: 'disambiguation.block_count',
memoryFragments: 'memory.chunks',
numberOfRelationalTriples: 'triplets.count'
}
/**
* Component props
*/
interface ResultProps {
loading: boolean;
handleSave: () => void;
}
/**
* Module processing item
*/
interface ModuleItem {
status: 'pending' | 'processing' | 'completed' | 'failed';
data: any[],
@@ -32,6 +52,7 @@ interface ModuleItem {
start_at?: number;
end_at?: number;
}
/** Tag color mapping by status */
const tagColors: {
[key: string]: TagProps['color']
} = {
@@ -40,6 +61,7 @@ const tagColors: {
completed: 'success',
failed: 'error'
}
/** Initial module state */
const initObj = {
data: [],
status: 'pending',
@@ -57,6 +79,7 @@ const Result: FC<ResultProps> = ({ loading, handleSave }) => {
const [creatingNodesEdges, setCreatingNodesEdges] = useState<ModuleItem>(initObj as ModuleItem)
const [deduplication, setDeduplication] = useState<ModuleItem>(initObj as ModuleItem)
/** Run pilot test */
const handleRun = () => {
if(!id) return
setTextPreprocessing({...initObj} as ModuleItem)
@@ -172,6 +195,7 @@ const Result: FC<ResultProps> = ({ loading, handleSave }) => {
const completedNum = [textPreprocessing, knowledgeExtraction, creatingNodesEdges, deduplication].filter(item => item.status === 'completed').length
const deduplicationData = groupDataByType(deduplication.data, 'result_type')
/** Format status tag */
const formatTag = (status: string) => {
return (
<Tag color={tagColors[status]}>
@@ -181,12 +205,14 @@ const Result: FC<ResultProps> = ({ loading, handleSave }) => {
</Tag>
)
}
/** Format processing time */
const formatTime = (data: ModuleItem, color?: string) => {
if (typeof data.end_at === 'number' && typeof data.start_at === 'number') {
return <div className={`rb:mt-3 rb:text-[${color ?? '#155EEF'}]`}>{t('memoryExtractionEngine.time')}{data.end_at - data.start_at}ms</div>
}
return null
}
/** Convert first character to lowercase */
const lowercaseFirst = (str: string) => str.charAt(0).toLowerCase() + str.slice(1)
return (
<Card
@@ -307,7 +333,7 @@ const Result: FC<ResultProps> = ({ loading, handleSave }) => {
const keys = (resultObj as Record<string, string>)[key].split('.')
return (
<div key={index}>
<div className="rb:text-[24px] rb:leading-[30px] rb:font-extrabold">{(testResult?.[keys[0] as keyof TestResult] as any)?.[keys[1]]}</div>
<div className="rb:text-[24px] rb:leading-7.5 rb:font-extrabold">{(testResult?.[keys[0] as keyof TestResult] as any)?.[keys[1]]}</div>
<div className="rb:text-[12px] rb:text-[#5B6167] rb:leading-4 rb:font-regular">{t(`memoryExtractionEngine.${key}`)}</div>
<div className="rb:mt-1 rb:text-[12px] rb:text-[#369F21] rb:leading-3.5 rb:font-regular">
{}

View File

@@ -1,5 +1,17 @@
/*
* @Author: ZhaoYing
* @Date: 2026-02-03 17:30:06
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-02-03 17:30:06
*/
/**
* Memory Extraction Engine Configuration Constants
* Defines configuration structure for storage and arrangement layer modules
*/
import type { ConfigVo } from './types'
/** Configuration list for memory extraction engine */
export const configList: ConfigVo[] = [
{
type: 'storageLayerModule',
@@ -206,6 +218,7 @@ export const configList: ConfigVo[] = [
}
]
/** Mock module data for testing */
export const mockModuleData = [
{
"data": [
@@ -1074,7 +1087,12 @@ export const mockModuleData = [
}
}
]
// 按type聚合数据的处理函数
/**
* Group data by specified key
* @param data - Array of data items
* @param groupKey - Key to group by
* @returns Grouped data object
*/
export const groupDataByType = (data: any[], groupKey: string) => {
const grouped: { [key: string]: any[] } = {}

View File

@@ -1,3 +1,15 @@
/*
* @Author: ZhaoYing
* @Date: 2026-02-03 17:30:02
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-02-03 17:30:02
*/
/**
* Memory Extraction Engine Configuration Page
* Configures entity deduplication, disambiguation, semantic anchoring, and pruning
* Supports real-time testing with example data
*/
import { type FC, useState, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
@@ -14,12 +26,15 @@ import Result from './components/Result'
import SwitchFormItem from '@/components/FormItem/SwitchFormItem'
import CustomSelect from '@/components/CustomSelect'
/** Available configuration section keys */
const keys = [
// 'example',
'storageLayerModule',
'arrangementLayerModule'
]
/**
* Configuration description component
*/
const ConfigDesc: FC<{ config: Variable, className?: string }> = ({config, className}) => {
const { t } = useTranslation();
return (
@@ -54,6 +69,7 @@ const MemoryExtractionEngine: FC = () => {
}
}, [values])
/** Fetch configuration data */
const getConfig = () => {
if (!id) {
return
@@ -79,11 +95,13 @@ const MemoryExtractionEngine: FC = () => {
}
}, [id])
/** Toggle section expansion */
const handleExpand = (key: string) => {
const newKeys = expandedKeys.includes(key) ? expandedKeys.filter(item => item !== key) : [...expandedKeys, key]
setExpandedKeys(newKeys)
}
/** Save configuration */
const handleSave = () => {
if (!id) {
return

View File

@@ -1,3 +1,12 @@
/*
* @Author: ZhaoYing
* @Date: 2026-02-03 17:29:55
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-02-03 17:29:55
*/
/**
* Memory Extraction Engine Configuration Form Types
*/
export interface ConfigForm {
llm_id: string;
config_id?: number | string;
@@ -19,6 +28,9 @@ export interface ConfigForm {
baseline: string;
}
/**
* Configuration variable definition
*/
export interface Variable {
label: string;
variableName: string;
@@ -33,6 +45,9 @@ export interface Variable {
max?: number;
step?: number;
}
/**
* Configuration section structure
*/
export interface ConfigVo {
type: string;
data: {
@@ -41,6 +56,9 @@ export interface ConfigVo {
}[]
}
/**
* Test result data structure
*/
export interface TestResult {
generated_at: string;
entities: Record<string, number>;