feat(web): Add Reflection Engine
This commit is contained in:
@@ -36,7 +36,8 @@ export const en = {
|
||||
apiKeyManagement: 'API KEY Management',
|
||||
toolManagement: 'Tool Management',
|
||||
emotionEngine: 'Emotion Engine',
|
||||
emotionDetail: 'Emotion Memory'
|
||||
emotionDetail: 'Emotion Memory',
|
||||
selfReflectionEngine: 'Self Reflection Engine',
|
||||
},
|
||||
dashboard: {
|
||||
totalMemoryCapacity: 'Total Memory Capacity',
|
||||
@@ -648,7 +649,7 @@ export const en = {
|
||||
inactive: 'Inactive',
|
||||
configurationName: 'Configuration Name',
|
||||
emotionEngine: 'Emotion Engine',
|
||||
selfReflexionEngine: 'Self-Reflection Engine'
|
||||
reflectionEngine: 'Self-Reflection Engine'
|
||||
},
|
||||
member: {
|
||||
username: 'Username',
|
||||
@@ -1117,7 +1118,7 @@ export const en = {
|
||||
intelligentSemanticPruningSceneDesc: 'Select intelligent semantic pruning scene (education, online_service, outbound).',
|
||||
intelligentSemanticPruningThreshold: 'Intelligent Semantic Pruning Threshold',
|
||||
intelligentSemanticPruningThresholdDesc: 'Set intelligent semantic pruning threshold (0-0.9).',
|
||||
selfReflexionEngine: 'Self-Reflexion Engine',
|
||||
reflectionEngine: 'Self-Reflexion Engine',
|
||||
selfReflexionEngineSubTitle: 'Through reflection and refinement, transform episodic memory into deeper semantic memory.',
|
||||
enableSelfReflexion: 'Enable self-reflexion',
|
||||
iterationPeriod: 'Iteration Period',
|
||||
@@ -1631,6 +1632,58 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
|
||||
stability: 'Stability',
|
||||
resilience: 'Resilience',
|
||||
suggestions: 'Personalized Suggestions',
|
||||
},
|
||||
reflectionEngine: {
|
||||
reflectionEngineConfig: 'Reflection Engine Configuration',
|
||||
reflection_enabled: 'Enable Reflection Engine',
|
||||
reflection_enabled_desc: 'Transform episodic memory into semantic memory, forming long-term cognition',
|
||||
reflection_model_id: 'Reflection Model',
|
||||
reflection_model_id_desc: 'Different models vary in accuracy and speed',
|
||||
reflection_period_in_hours: 'Iteration Period',
|
||||
reflection_period_in_hours_desc: 'Determines how often the system performs memory reflection and refinement',
|
||||
reflexion_range: 'Reflection Range',
|
||||
partial: 'Partial Reflection (New memories only)',
|
||||
all: 'Full Reflection (All historical memories)',
|
||||
reflexion_range_desc: '',
|
||||
baseline: 'Reflection Baseline',
|
||||
baseline_desc: '',
|
||||
TIME: 'Time-based (Temporal relationships)',
|
||||
FACT: 'Fact-based (Knowledge points)',
|
||||
HYBRID: 'Fact + Time (Comprehensive dimension)',
|
||||
quality_assessment: 'Enable Quality Assessment',
|
||||
quality_assessment_desc: 'Automatically evaluate memory accuracy, completeness and timeliness',
|
||||
memory_verify: 'Enable Memory Verification',
|
||||
memory_verify_desc: 'Detect sensitive information and filter inappropriate content',
|
||||
oneHour: 'Every 1 hour',
|
||||
threeHours: 'Every 3 hours',
|
||||
sixHours: 'Every 6 hours',
|
||||
twelveHours: 'Every 12 hours',
|
||||
daily: 'Daily',
|
||||
run: 'Run Debug',
|
||||
example: 'Raw Data',
|
||||
exampleText: 'My sister was born in 2025, oh wait, I remembered wrong, she was actually born in 2024. By the way, my ID number is 33252218293749845X.',
|
||||
runTitle: 'Reflection Test Run',
|
||||
status: 'Status',
|
||||
message: 'Message',
|
||||
|
||||
conflictDetection: 'Conflict Detection',
|
||||
reason: 'Conflict Reason',
|
||||
solution: 'Solution',
|
||||
|
||||
qualityAssessment: 'Quality Assessment',
|
||||
qualityAssessmentObj: {
|
||||
score: 'Quality Score',
|
||||
summary: 'Assessment Summary',
|
||||
},
|
||||
|
||||
privacyAudit: 'Privacy Audit',
|
||||
privacyAuditObj: {
|
||||
true: 'Yes',
|
||||
false: 'No',
|
||||
has_privacy: 'Contains Privacy Information',
|
||||
privacy_types: 'Privacy Types',
|
||||
summary: 'Audit Summary',
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -36,7 +36,8 @@ export const zh = {
|
||||
userMemoryDetail: '用户记忆详情',
|
||||
toolManagement: '工具管理',
|
||||
emotionEngine: '情感引擎',
|
||||
emotionDetail: '情绪记忆'
|
||||
emotionDetail: '情绪记忆',
|
||||
selfReflectionEngine: '反思引擎',
|
||||
},
|
||||
knowledgeBase: {
|
||||
home: '首页',
|
||||
@@ -997,7 +998,7 @@ export const zh = {
|
||||
inactive: '不活跃',
|
||||
configurationName: '配置名称',
|
||||
emotionEngine: '情感引擎',
|
||||
selfReflexionEngine: '反思引擎'
|
||||
reflectionEngine: '反思引擎'
|
||||
},
|
||||
member: {
|
||||
username: '用户名',
|
||||
@@ -1191,7 +1192,7 @@ export const zh = {
|
||||
intelligentSemanticPruningSceneDesc: '选择智能语义修剪场景(education、online_service、outbound)。',
|
||||
intelligentSemanticPruningThreshold: '智能语义修剪阈值',
|
||||
intelligentSemanticPruningThresholdDesc: '设置智能语义修剪阈值(0-0.9)。',
|
||||
selfReflexionEngine: '自我反思引擎',
|
||||
reflectionEngine: '自我反思引擎',
|
||||
selfReflexionEngineSubTitle: '通过反思和精炼,将情节记忆转化为更深层的语义记忆。',
|
||||
enableSelfReflexion: '启用自我反思',
|
||||
iterationPeriod: '迭代周期',
|
||||
@@ -1720,6 +1721,58 @@ export const zh = {
|
||||
stability: '稳定性',
|
||||
resilience: '恢复力',
|
||||
suggestions: '个性化建议',
|
||||
},
|
||||
reflectionEngine: {
|
||||
reflectionEngineConfig: '反思引擎配置',
|
||||
reflection_enabled: '启用反思引擎',
|
||||
reflection_enabled_desc: '将情节记忆转化为语义记忆,形成长期认知',
|
||||
reflection_model_id: '反思模型',
|
||||
reflection_model_id_desc: '不同模型在准确度和速度上有所差异',
|
||||
reflection_period_in_hours: '迭代周期',
|
||||
reflection_period_in_hours_desc: '决定系统多久进行一次记忆反思和提炼',
|
||||
reflexion_range: '反思范围',
|
||||
partial: '部分反思 (仅新增记忆)',
|
||||
all: '全部反思 (所有历史记忆)',
|
||||
reflexion_range_desc: '',
|
||||
baseline: '反思基线',
|
||||
baseline_desc: '',
|
||||
TIME: '基于时间(时序关系)',
|
||||
FACT: '基于事实(知识点)',
|
||||
HYBRID: '事实+时间(综合维度)',
|
||||
quality_assessment: '启用质量评估',
|
||||
quality_assessment_desc: '自动评估记忆的准确性、完整性和时效性',
|
||||
memory_verify: '启用记忆审核',
|
||||
memory_verify_desc: '检测敏感信息并过滤违规内容',
|
||||
oneHour: '每1个小时',
|
||||
threeHours: '每3个小时',
|
||||
sixHours: '每6个小时',
|
||||
twelveHours: '每12个小时',
|
||||
daily: '每天',
|
||||
run: '运行调试',
|
||||
example: '原始数据',
|
||||
exampleText: '我妹妹是2025年出生的,哦不对,我记错了,她其实是2024年出生的。对了,我的身份证号码是33252218293749845X。',
|
||||
runTitle: '反思试运行',
|
||||
status: '状态',
|
||||
message: '消息',
|
||||
|
||||
conflictDetection: '冲突检测',
|
||||
reason: '冲突原因',
|
||||
solution: '解决方案',
|
||||
|
||||
qualityAssessment: '质量评估',
|
||||
qualityAssessmentObj: {
|
||||
score: '质量评分',
|
||||
summary: '评估摘要',
|
||||
},
|
||||
|
||||
privacyAudit: '隐私审核',
|
||||
privacyAuditObj: {
|
||||
true: '是',
|
||||
false: '否',
|
||||
has_privacy: '包含隐私信息',
|
||||
privacy_types: '隐私类型',
|
||||
summary: '审核摘要',
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -55,9 +55,9 @@ const componentMap: Record<string, LazyExoticComponent<ComponentType<object>>> =
|
||||
ModelManagement: lazy(() => import('@/views/ModelManagement')),
|
||||
SpaceManagement: lazy(() => import('@/views/SpaceManagement')),
|
||||
ApiKeyManagement: lazy(() => import('@/views/ApiKeyManagement')),
|
||||
ToolManagement: lazy(() => import('@/views/ToolManagement')),
|
||||
EmotionEngine: lazy(() => import('@/views/EmotionEngine')),
|
||||
EmotionDetail: lazy(() => import('@/views/UserMemoryDetail/pages/EmotionDetail')),
|
||||
SelfReflectionEngine: lazy(() => import('@/views/SelfReflectionEngine')),
|
||||
Login: lazy(() => import('@/views/Login')),
|
||||
InviteRegister: lazy(() => import('@/views/InviteRegister')),
|
||||
NoPermission: lazy(() => import('@/views/NoPermission')),
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
{ "path": "/user-management", "element": "UserManagement" },
|
||||
{ "path": "/model", "element": "ModelManagement" },
|
||||
{ "path": "/space", "element": "SpaceManagement" },
|
||||
{ "path": "/tool", "element": "ToolManagement" },
|
||||
{ "path": "/no-permission", "element": "NoPermission" }
|
||||
]
|
||||
},
|
||||
@@ -27,8 +26,8 @@
|
||||
{ "path": "/knowledge-base/:knowledgeBaseId/create-dataset", "element": "CreateDataset" },
|
||||
{ "path": "/knowledge-base/:knowledgeBaseId/DocumentDetails", "element": "DocumentDetails" },
|
||||
{ "path": "/api-key", "element": "ApiKeyManagement" },
|
||||
{ "path": "/tool", "element": "ToolManagement" },
|
||||
{ "path": "/emotion-engine/:id", "element": "EmotionEngine" },
|
||||
{ "path": "/reflection-engine/:id", "element": "SelfReflectionEngine" },
|
||||
{ "path": "/user-memory/emotion/:id", "element": "EmotionDetail" },
|
||||
{ "path": "/no-permission", "element": "NoPermission" },
|
||||
{ "path": "/*", "element": "NotFound" }
|
||||
|
||||
@@ -209,6 +209,19 @@
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 72,
|
||||
"parent": 7,
|
||||
"code": "selfReflectionEngine",
|
||||
"label": "反思引擎",
|
||||
"i18nKey": "menu.selfReflectionEngine",
|
||||
"path": "/reflection-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@ const configList = [
|
||||
key: 'emotion_model_id',
|
||||
type: 'customSelect',
|
||||
url: getModelListUrl,
|
||||
params: { type: 'chat', page: 1, pagesize: 100 }, // chat,llm
|
||||
params: { type: 'chat,llm', page: 1, pagesize: 100 }, // chat,llm
|
||||
},
|
||||
{
|
||||
key: 'emotion_min_intensity',
|
||||
@@ -40,7 +40,7 @@ const configList = [
|
||||
},
|
||||
]
|
||||
|
||||
const ForgettingEngine: React.FC = () => {
|
||||
const EmotionEngine: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams();
|
||||
const [configData, setConfigData] = useState<ConfigForm>({} as ConfigForm);
|
||||
@@ -249,4 +249,4 @@ const ForgettingEngine: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default ForgettingEngine;
|
||||
export default EmotionEngine;
|
||||
|
||||
@@ -152,7 +152,7 @@ export const configList: ConfigVo[] = [
|
||||
},
|
||||
// 自我反思引擎
|
||||
// {
|
||||
// title: 'selfReflexionEngine',
|
||||
// title: 'reflectionEngine',
|
||||
// list: [
|
||||
// // 是否启用反思引擎
|
||||
// {
|
||||
|
||||
@@ -69,6 +69,10 @@ const MemoryManagement: React.FC = () => {
|
||||
break
|
||||
case 'emotionEngine':
|
||||
navigate(`/emotion-engine/${id}`)
|
||||
break;
|
||||
case 'reflectionEngine':
|
||||
navigate(`/reflection-engine/${id}`)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +99,7 @@ const MemoryManagement: React.FC = () => {
|
||||
</Tooltip>
|
||||
|
||||
<div className="rb:grid rb:grid-cols-2 rb:gap-4 rb:mt-3">
|
||||
{['memoryExtractionEngine', 'forgottenEngine', 'emotionEngine', 'selfReflexionEngine'].map((key) => (
|
||||
{['memoryExtractionEngine', 'forgottenEngine', 'emotionEngine', 'reflectionEngine'].map((key) => (
|
||||
<div key={key} className="rb:group rb:cursor-pointer rb:bg-[#F0F3F8] rb:h-10 rb:rounded-md rb:flex rb:items-center rb:justify-between rb:p-[0_8px_0_12px] rb:mt-3 rb:text-[#5B6167] rb:font-medium"
|
||||
onClick={() => handleClick(item.config_id, key)}
|
||||
>
|
||||
|
||||
365
web/src/views/SelfReflectionEngine/index.tsx
Normal file
365
web/src/views/SelfReflectionEngine/index.tsx
Normal file
@@ -0,0 +1,365 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Row, Col, Form, App, Button, Switch, Space, Select } from 'antd';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import RbCard from '@/components/RbCard/Card';
|
||||
import strategyImpactSimulator from '@/assets/images/memory/strategyImpactSimulator.svg'
|
||||
import { getMemoryReflectionConfig, updateMemoryReflectionConfig, pilotRunMemoryReflectionConfig } from '@/api/memory'
|
||||
import type { ConfigForm, Result, ReflexionData, MemoryVerify, QualityAssessment } from './types'
|
||||
import CustomSelect from '@/components/CustomSelect';
|
||||
import { getModelListUrl } from '@/api/models'
|
||||
import Tag from '@/components/Tag'
|
||||
|
||||
const configList = [
|
||||
// 启用反思引擎
|
||||
{
|
||||
key: 'reflection_enabled',
|
||||
type: 'switch',
|
||||
},
|
||||
// 反思模型
|
||||
{
|
||||
key: 'reflection_model_id',
|
||||
type: 'customSelect',
|
||||
url: getModelListUrl,
|
||||
params: { type: 'chat,llm', page: 1, pagesize: 100 }, // chat,llm
|
||||
},
|
||||
// 迭代周期
|
||||
{
|
||||
key: 'reflection_period_in_hours',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: 'oneHour', value: '1' },
|
||||
{ label: 'threeHours', value: '3' },
|
||||
{ label: 'sixHours', value: '6' },
|
||||
{ label: 'twelveHours', value: '12' },
|
||||
{ label: 'daily', value: '24' },
|
||||
],
|
||||
},
|
||||
// 反思范围
|
||||
{
|
||||
key: 'reflexion_range',
|
||||
type: 'select',
|
||||
hiddenDesc: true,
|
||||
options: [
|
||||
{ label: 'partial', value: 'partial' },
|
||||
{ label: 'all', value: 'all' },
|
||||
],
|
||||
},
|
||||
// 反思基线
|
||||
{
|
||||
key: 'baseline',
|
||||
type: 'select',
|
||||
hiddenDesc: true,
|
||||
options: [
|
||||
{ label: 'TIME', value: 'TIME' },
|
||||
{ label: 'FACT', value: 'FACT' },
|
||||
{ label: 'HYBRID', value: 'HYBRID' },
|
||||
],
|
||||
},
|
||||
// 质量评估
|
||||
{
|
||||
key: 'quality_assessment',
|
||||
type: 'switch',
|
||||
},
|
||||
// 质量评估
|
||||
{
|
||||
key: 'memory_verify',
|
||||
type: 'switch',
|
||||
},
|
||||
]
|
||||
|
||||
const SelfReflectionEngine: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams();
|
||||
const [configData, setConfigData] = useState<ConfigForm>({} as ConfigForm);
|
||||
const [form] = Form.useForm<ConfigForm>();
|
||||
const { message } = App.useApp();
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [runLoading, setRunLoading] = useState(false)
|
||||
const [result, setResult] = useState<Result>({
|
||||
"baseline": "TIME",
|
||||
"source_data": "我是 2023 年春天去北京工作的,后来基本一直都在北京上班,也没怎么换过城市。不过后来公司调整,2024 年上半年我被调到上海待了差不多半年,那段时间每天都是在上海办公室打卡。当时入职资料用的还是我之前的身份信息,身份证号是 11010119950308123X,银行卡是 6222023847595898,这些一直没变。对了,其实我 从 2023 年开始就一直在北京生活,从来没有长期离开过北京,上海那段更多算是远程配合",
|
||||
"quality_assessments": [
|
||||
{
|
||||
"score": 80,
|
||||
"summary": "数据整体质量良好,实体和关系描述清晰,时间字段完整。但存在少量语义冲突:关于用户长期在北京生活的陈述与2024年上半年被调至上海工作半年的事实存在空间互斥重叠冲突。此外,'在上海期间算远程配合'的主观认知与'每天在上海办公室打卡'的客观行为可能存在逻辑不一致,需进一步验证。无明显格式错误或缺失字段。"
|
||||
}
|
||||
],
|
||||
"memory_verifies": [
|
||||
{
|
||||
"has_privacy": true,
|
||||
"privacy_types": [
|
||||
"身份证信息",
|
||||
"银行信息"
|
||||
],
|
||||
"summary": "检测到2类隐私信息:1个身份证号码(11010119950308123X)和1个银行卡号(6222023847595898),共涉及2条记录"
|
||||
}
|
||||
],
|
||||
"reflexion_data": [
|
||||
{
|
||||
"reason": "检测到时间冲突:用户从2023年起一直在北京生活工作的陈述与2024年上半年被调至上海工作半年的事实在时间线上存在重叠和矛盾。",
|
||||
"solution": "保留‘用户于2024年上半年被调至上海工作半年’这一更具体且可验证的时间事实,将‘用户从未长期离开北京’等绝对化陈述设为失效。同时对涉及的隐私信息进行脱敏处理。"
|
||||
},
|
||||
{
|
||||
"reason": "检测到混合冲突:用户‘每天在上海办公室打卡’是客观行为,而‘认为更多算是远程配合’是主观认知,两者在逻辑上构成事实与感知的不一致,属于混合型冲突(HYBRID)。",
|
||||
"solution": "保留两种记录以反映客观行为与主观认知的差异,无需修改数据状态。但在输出中应对可能涉及的隐私信息进行脱敏处理。"
|
||||
},
|
||||
{
|
||||
"reason": "检测到隐私信息:身份证号(11010119950308123X)和银行卡号(6222023847595898)属于敏感个人信息,需按规则脱敏。",
|
||||
"solution": "对身份证号和银行卡号进行脱敏处理,保留前三位和后四位,中间用*代替。"
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const values = Form.useWatch([], form);
|
||||
|
||||
useEffect(() => {
|
||||
getConfigData()
|
||||
}, [id])
|
||||
|
||||
const getConfigData = () => {
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
getMemoryReflectionConfig(id)
|
||||
.then((res) => {
|
||||
const response = res as ConfigForm
|
||||
const initialValues = {
|
||||
...response,
|
||||
}
|
||||
console.log('initialValues', initialValues)
|
||||
setConfigData(initialValues);
|
||||
form.setFieldsValue(initialValues);
|
||||
})
|
||||
.catch(() => {
|
||||
console.error('Failed to load data');
|
||||
})
|
||||
}
|
||||
const handleReset = () => {
|
||||
form.setFieldsValue(configData);
|
||||
}
|
||||
const handleSave = () => {
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
setLoading(true)
|
||||
updateMemoryReflectionConfig({
|
||||
...values,
|
||||
config_id: id
|
||||
})
|
||||
.then(() => {
|
||||
message.success(t('common.saveSuccess'))
|
||||
setConfigData({...(values || {})})
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
}
|
||||
const handleRun = () => {
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
setRunLoading(true)
|
||||
pilotRunMemoryReflectionConfig({
|
||||
config_id: id,
|
||||
dialogue_text: t('reflectionEngine.exampleText')
|
||||
})
|
||||
.then((res) => {
|
||||
setResult(res as Result)
|
||||
})
|
||||
.finally(() => {
|
||||
setRunLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col span={12}>
|
||||
<RbCard
|
||||
title={
|
||||
<div className="rb:flex rb:items-center">
|
||||
<img src={strategyImpactSimulator} className="rb:w-5 rb:h-5 rb:mr-2" />
|
||||
{t('reflectionEngine.reflectionEngineConfig')}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={{
|
||||
offset: 0,
|
||||
lambda_time: 0.03,
|
||||
lambda_mem: 0.03,
|
||||
}}
|
||||
>
|
||||
{configList.map(config => {
|
||||
if (config.type === 'customSelect') {
|
||||
return (
|
||||
<div key={config.key}>
|
||||
<div className="rb:text-[14px] rb:font-medium rb:leading-5 rb:mb-2">
|
||||
{t(`reflectionEngine.${config.key}`)}
|
||||
</div>
|
||||
<Form.Item
|
||||
name={config.key}
|
||||
extra={t(`reflectionEngine.${config.key}_desc`)}
|
||||
>
|
||||
<CustomSelect
|
||||
url={config.url as string}
|
||||
params={config.params}
|
||||
valueKey='id'
|
||||
labelKey='name'
|
||||
hasAll={false}
|
||||
placeholder={t('common.pleaseSelect')}
|
||||
disabled={!values?.reflection_enabled && config.key !== 'reflection_enabled'}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (config.type === 'select') {
|
||||
return (
|
||||
<div key={config.key}>
|
||||
<div className="rb:text-[14px] rb:font-medium rb:leading-5 rb:mb-2">
|
||||
{t(`reflectionEngine.${config.key}`)}
|
||||
</div>
|
||||
<Form.Item
|
||||
name={config.key}
|
||||
extra={t(`reflectionEngine.${config.key}_desc`)}
|
||||
>
|
||||
<Select
|
||||
options={config.options?.map(vo => ({
|
||||
...vo,
|
||||
label: t(`reflectionEngine.${vo.label}`),
|
||||
}))}
|
||||
placeholder={t('common.pleaseSelect')}
|
||||
disabled={!values?.reflection_enabled && config.key !== 'reflection_enabled'}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rb:flex rb:items-center rb:justify-between rb:mb-6">
|
||||
<div>
|
||||
<span className="rb:text-[14px] rb:font-medium rb:leading-5">{t(`reflectionEngine.${config.key}`)}</span>
|
||||
{(config as any).hasSubTitle && <div className="rb:mt-1 rb:text-[12px] rb:text-[#5B6167] rb:font-regular rb:leading-4">{t(`reflectionEngine.${config.key}_subTitle`)}</div>}
|
||||
<div className="rb:mt-1 rb:text-[12px] rb:text-[#5B6167] rb:font-regular rb:leading-4">{t(`reflectionEngine.${config.key}_desc`)}</div>
|
||||
</div>
|
||||
<Form.Item
|
||||
name={config.key}
|
||||
valuePropName="checked"
|
||||
className="rb:ml-2 rb:mb-0!"
|
||||
>
|
||||
<Switch
|
||||
disabled={!values?.reflection_enabled && config.key !== 'reflection_enabled'} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
<Row gutter={16} className="rb:mt-3">
|
||||
<Col span={12}>
|
||||
<Button block onClick={handleReset}>{t('common.reset')}</Button>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Button type="primary" loading={loading} block onClick={handleSave}>{t('common.save')}</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</RbCard>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Space size={16} direction="vertical" className="rb:w-full">
|
||||
<RbCard
|
||||
title={t('memoryExtractionEngine.example')}
|
||||
>
|
||||
<div className="rb:text-[14px] rb:text-[#5B6167] rb:font-regular rb:leading-5 rb:mb-6">
|
||||
{t('reflectionEngine.exampleText')}
|
||||
</div>
|
||||
|
||||
<Button type="primary" block loading={runLoading} onClick={handleRun}>{t('reflectionEngine.run')}</Button>
|
||||
</RbCard>
|
||||
{result && <>
|
||||
<RbCard
|
||||
title={t('reflectionEngine.runTitle')}
|
||||
>
|
||||
<div
|
||||
className="rb:flex rb:gap-4 rb:justify-start rb:text-[#5B6167] rb:text-[14px] rb:leading-5 rb:mb-3"
|
||||
>
|
||||
<div className="rb:whitespace-nowrap rb:w-20 rb:font-medium">{t(`reflectionEngine.baseline`)}</div>
|
||||
<div className='rb:flex-inline rb:text-left rb:py-px rb:rounded rb:text-[#5B6167] rb:flex-1'>
|
||||
{result.baseline}
|
||||
</div>
|
||||
</div>
|
||||
</RbCard>
|
||||
<RbCard
|
||||
title={t('reflectionEngine.conflictDetection')}
|
||||
>
|
||||
<Space size={12} direction="vertical" className="rb:w-full">
|
||||
{result.reflexion_data.map((item, index) => (
|
||||
<div key={index} className="rb:bg-[#F0F3F8] rb:px-3 rb:py-2.5 rb:rounded-md rb:text-[12px]">
|
||||
{['reason', 'solution'].map(key => (
|
||||
<div
|
||||
key={key}
|
||||
className="rb:flex rb:gap-4 rb:justify-start rb:text-[14px] rb:leading-5 rb:mb-3"
|
||||
>
|
||||
<div className="rb:whitespace-nowrap rb:w-20 rb:font-medium">{t(`reflectionEngine.${key}`)}</div>
|
||||
<div className='rb:flex-inline rb:text-left rb:py-px rb:rounded rb:text-[#5B6167] rb:flex-1'>
|
||||
{item[key as keyof ReflexionData]}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</Space>
|
||||
</RbCard>
|
||||
<RbCard
|
||||
title={t('reflectionEngine.qualityAssessment')}
|
||||
>
|
||||
{result.quality_assessments.map((item, index) => (
|
||||
<div key={index} className="rb:bg-[#F0F3F8] rb:px-3 rb:py-2.5 rb:rounded-md rb:text-[12px]">
|
||||
{['score', 'summary'].map(key => (
|
||||
<div
|
||||
key={key}
|
||||
className="rb:flex rb:gap-4 rb:justify-start rb:text-[14px] rb:leading-5 rb:mb-3"
|
||||
>
|
||||
<div className="rb:whitespace-nowrap rb:w-20 rb:font-medium">{t(`reflectionEngine.qualityAssessmentObj.${key}`)}</div>
|
||||
<div className='rb:flex-inline rb:text-left rb:py-px rb:rounded rb:text-[#5B6167] rb:flex-1'>
|
||||
{item[key as keyof QualityAssessment]}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</RbCard>
|
||||
<RbCard
|
||||
title={t('reflectionEngine.privacyAudit')}
|
||||
>
|
||||
{result.memory_verifies.map((item, index) => (
|
||||
<div key={index} className="rb:bg-[#F0F3F8] rb:px-3 rb:py-2.5 rb:rounded-md rb:text-[12px]">
|
||||
{['has_privacy', 'privacy_types', 'summary'].map(key => (
|
||||
<div
|
||||
key={key}
|
||||
className="rb:flex rb:gap-4 rb:justify-start rb:text-[14px] rb:leading-5 rb:mb-3"
|
||||
>
|
||||
<div className="rb:whitespace-nowrap rb:w-20 rb:font-medium">{t(`reflectionEngine.privacyAuditObj.${key}`)}</div>
|
||||
<div className='rb:flex-inline rb:text-left rb:py-px rb:rounded rb:text-[#5B6167] rb:flex-1'>
|
||||
{key === 'has_privacy'
|
||||
? <Tag color={item[key as keyof MemoryVerify] ? 'success' : 'error'}>{t(`reflectionEngine.privacyAuditObj.${item[key as keyof MemoryVerify]}`)}</Tag>
|
||||
: key === 'privacy_types' ? (item[key as keyof MemoryVerify] as string[]).join('、')
|
||||
: item[key as keyof MemoryVerify]
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</RbCard>
|
||||
</>}
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
};
|
||||
|
||||
export default SelfReflectionEngine;
|
||||
72
web/src/views/SelfReflectionEngine/types.ts
Normal file
72
web/src/views/SelfReflectionEngine/types.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
// 标签表单数据类型
|
||||
export interface TagFormData {
|
||||
tagName: string;
|
||||
type: string;
|
||||
color: string;
|
||||
description?: string;
|
||||
applicableScope?: string[];
|
||||
semanticExpansion?: string;
|
||||
isActive?: boolean;
|
||||
// 扩展字段用于区分编辑和新增操作
|
||||
isEditing?: boolean;
|
||||
tagId?: string;
|
||||
}
|
||||
|
||||
// 记忆总览数据类型
|
||||
export interface MemoryOverviewRecord {
|
||||
id: number;
|
||||
memoryID: string,
|
||||
contentSummary: string;
|
||||
type: string;
|
||||
createTime: string;
|
||||
lastCallTime: string;
|
||||
retentionDegree: string;
|
||||
status: string;
|
||||
}
|
||||
// 定义组件暴露的方法接口
|
||||
export interface MemoryOverviewFormRef {
|
||||
handleOpen: (memoryOverview?: MemoryOverviewRecord | null) => void;
|
||||
}
|
||||
|
||||
// 遗忘曲线数据类型
|
||||
export interface CurveRecord {
|
||||
memoryID: string;
|
||||
type: string;
|
||||
currentRetentionRate: string;
|
||||
finallyActivated: string;
|
||||
expectedForgettingTime: string;
|
||||
reinforcementCount: string;
|
||||
}
|
||||
|
||||
export interface ConfigForm {
|
||||
config_id: number | string;
|
||||
reflection_enabled: boolean;
|
||||
reflection_period_in_hours: string;
|
||||
reflexion_range: string;
|
||||
baseline: string;
|
||||
reflection_model_id: string;
|
||||
memory_verify: boolean;
|
||||
quality_assessment: boolean;
|
||||
}
|
||||
|
||||
export interface QualityAssessment {
|
||||
score: number;
|
||||
summary: string;
|
||||
}
|
||||
export interface MemoryVerify {
|
||||
has_privacy: boolean;
|
||||
privacy_types: string[];
|
||||
summary: string;
|
||||
}
|
||||
export interface ReflexionData {
|
||||
reason: string;
|
||||
solution: string;
|
||||
}
|
||||
|
||||
export interface Result {
|
||||
baseline: string;
|
||||
source_data: string;
|
||||
quality_assessments: QualityAssessment[];
|
||||
memory_verifies: MemoryVerify[];
|
||||
reflexion_data: ReflexionData[]
|
||||
}
|
||||
Reference in New Issue
Block a user