diff --git a/webapp/packages/supersonic-fe/config/proxy.ts b/webapp/packages/supersonic-fe/config/proxy.ts index 166919713..98dc00814 100644 --- a/webapp/packages/supersonic-fe/config/proxy.ts +++ b/webapp/packages/supersonic-fe/config/proxy.ts @@ -1,7 +1,8 @@ export default { dev: { '/api/': { - target: 'http://localhost:9080', + target: 'http://10.91.206.51:9080', + // target: 'http://s2.tmeoa.com', changeOrigin: true, }, }, diff --git a/webapp/packages/supersonic-fe/src/global.less b/webapp/packages/supersonic-fe/src/global.less index 3359784ee..30ebda48d 100644 --- a/webapp/packages/supersonic-fe/src/global.less +++ b/webapp/packages/supersonic-fe/src/global.less @@ -276,7 +276,7 @@ ol { .ant-form-item-label { .anticon { position: relative; - top: 2px; + top: 1px; } } .ant-input-search .ant-input-search-button { diff --git a/webapp/packages/supersonic-fe/src/pages/Agent/AgentForm.tsx b/webapp/packages/supersonic-fe/src/pages/Agent/AgentForm.tsx index 9e7f6c437..05ec97d33 100644 --- a/webapp/packages/supersonic-fe/src/pages/Agent/AgentForm.tsx +++ b/webapp/packages/supersonic-fe/src/pages/Agent/AgentForm.tsx @@ -11,6 +11,7 @@ import { Row, message, Space, + Tooltip, } from 'antd'; import MainTitleMark from '@/components/MainTitleMark'; import { AgentType } from './type'; @@ -20,6 +21,7 @@ import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'; import { uuid, jsonParse, encryptPassword, decryptPassword } from '@/utils/utils'; import ToolsSection from './ToolsSection'; import globalStyles from '@/global.less'; +import { QuestionCircleOutlined } from '@ant-design/icons'; import { testLLMConn } from '../../services/system'; import MemorySection from './MemorySection'; @@ -118,6 +120,12 @@ const AgentForm: React.FC = ({ editAgent, onSaveAgent, onCreateToolBtnCli message.error('模型连接失败'); } }; + const tips = [ + '自定义提示词模板可嵌入以下变量,将由系统自动进行替换:', + '-{{exemplar}} :替换成few-shot示例,示例个数由系统配置', + '-{{question}} :替换成用户问题,拼接了一定的补充信息', + '-{{schema}} :替换成数据语义信息,根据用户问题映射而来', + ]; const formTabList = [ { @@ -397,14 +405,29 @@ const AgentForm: React.FC = ({ editAgent, onSaveAgent, onCreateToolBtnCli key: 'promptConfig', children: (
- - + + + 提示词模板 + + {tips.map((tip) => ( +
{tip}
+ ))} + + } + > + +
+
+ + } + > +
), diff --git a/webapp/packages/supersonic-fe/src/pages/Agent/MemorySection.tsx b/webapp/packages/supersonic-fe/src/pages/Agent/MemorySection.tsx index fd6f92e89..5ae2ba586 100644 --- a/webapp/packages/supersonic-fe/src/pages/Agent/MemorySection.tsx +++ b/webapp/packages/supersonic-fe/src/pages/Agent/MemorySection.tsx @@ -2,10 +2,11 @@ import type { ProColumns } from '@ant-design/pro-components'; import { EditableProTable } from '@ant-design/pro-components'; import React, { useState } from 'react'; import { MemoryType, ReviewEnum, StatusEnum } from './type'; -import { getMemeoryList, saveMemory } from './service'; -import { Popover, Input, Badge, Radio, Select, Button } from 'antd'; +import { getMemeoryList, saveMemory, batchDeleteMemory } from './service'; +import { Popover, Input, Badge, Radio, Select, Button, message } from 'antd'; import styles from './style.less'; - +import { isArrayOfValues } from '@/utils/utils'; +import dayjs from 'dayjs'; const { TextArea } = Input; const RadioGroup = Radio.Group; @@ -19,6 +20,24 @@ const MemorySection = ({ agentId }: Props) => { const [loading, setLoading] = useState(false); const [filters, setFilters] = useState({}); const { question, status, llmReviewRet, humanReviewRet } = filters; + const [selectedRowKeys, setSelectedRowKeys] = useState([]); + + const defaultPagination = { + current: 1, + pageSize: 10, + total: 0, + }; + const [pagination, setPagination] = useState(defaultPagination); + + const deleteTermConfig = async (ids: number[]) => { + const { code, msg } = await batchDeleteMemory(ids); + if (code === 200) { + loadMemoryList(); + setSelectedRowKeys([]); + } else { + message.error(msg); + } + }; const columns: ProColumns[] = [ { @@ -73,6 +92,7 @@ const MemorySection = ({ agentId }: Props) => { status: 'Error', }, }, + sorter: true, }, { title: '管理员评估意见', @@ -96,6 +116,7 @@ const MemorySection = ({ agentId }: Props) => { key: 'humanReviewRet', dataIndex: 'humanReviewRet', width: 150, + sorter: true, valueType: 'radio', renderFormItem: (_, { record }) => ( { dataIndex: 'status', valueType: 'radio', width: 120, + sorter: true, tooltip: '若启用,将会把这条记录加入到向量库中作为样例召回供大模型参考以及作为相似问题推荐给用户', valueEnum: { @@ -145,6 +167,26 @@ const MemorySection = ({ agentId }: Props) => { } }, }, + { + dataIndex: 'updatedAt', + title: '更新时间', + editable: false, + search: false, + sorter: true, + render: (value: any) => { + return value && value !== '-' ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'; + }, + }, + { + dataIndex: 'createdAt', + title: '创建时间', + search: false, + editable: false, + sorter: true, + render: (value: any) => { + return value && value !== '-' ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'; + }, + }, { title: '操作', valueType: 'option', @@ -162,10 +204,15 @@ const MemorySection = ({ agentId }: Props) => { }, ]; - const loadMemoryList = async ({ - filtersValue, - current, - }: { filtersValue?: any; current?: number } = {}) => { + const sortMap = { + ascend: 'asc', + descend: 'desc', + }; + + const loadMemoryList = async ( + { filtersValue, current }: { filtersValue?: any; current?: number } = {}, + sort?: any, + ) => { if (!agentId) { return { data: [], @@ -173,17 +220,49 @@ const MemorySection = ({ agentId }: Props) => { success: true, }; } + let sortParams: { orderCondition: string; sort: 'desc' | 'asc' } = { + orderCondition: 'updatedAt', + sort: 'desc', + }; + + if (sort) { + const target = Object.entries(sort)[0]; + if (target) { + const [sortKey, sortValue] = target; + if (sortKey && sortValue) { + sortParams = { + orderCondition: sortKey, + sort: sortMap[sortValue] || 'desc', + }; + } + } + } setLoading(true); - const res = await getMemeoryList(agentId, filtersValue || filters, current || 1); + const res = await getMemeoryList({ + agentId, + chatMemoryFilter: filtersValue || filters, + current: current || 1, + ...sortParams, + }); setLoading(false); - const { list, total } = res.data; + const { list, total, pageSize, pageNum } = res.data; setDataSource(list); + setPagination({ + pageSize, + current: pageNum, + total, + }); return { data: list, total: total, success: true, }; }; + const rowSelection = { + onChange: (selectedRowKeys: React.Key[]) => { + setSelectedRowKeys(selectedRowKeys as number[]); + }, + }; const onSave = async (_: any, data: any) => { await saveMemory(data); @@ -258,6 +337,16 @@ const MemorySection = ({ agentId }: Props) => { + rowKey="id" @@ -265,9 +354,14 @@ const MemorySection = ({ agentId }: Props) => { loading={loading} columns={columns} request={loadMemoryList} + rowSelection={{ + type: 'checkbox', + ...rowSelection, + }} value={dataSource} onChange={setDataSource} - pagination={{ pageSize: 10 }} + // pagination={{ pageSize: 10 }} + pagination={pagination} sticky={{ offsetHeader: 0 }} editable={{ type: 'multiple', diff --git a/webapp/packages/supersonic-fe/src/pages/Agent/service.ts b/webapp/packages/supersonic-fe/src/pages/Agent/service.ts index 4c6fe3e60..1a3f45d9d 100644 --- a/webapp/packages/supersonic-fe/src/pages/Agent/service.ts +++ b/webapp/packages/supersonic-fe/src/pages/Agent/service.ts @@ -35,13 +35,17 @@ export function getMetricList(modelId: number) { }); } -export function getMemeoryList(agentId: number, chatMemoryFilter: any, current: number) { +export function getMemeoryList(data: { agentId: number; chatMemoryFilter: any; current: number }) { + const { agentId, chatMemoryFilter, current } = data; return request>('/api/chat/memory/pageMemories', { method: 'POST', data: { + ...data, chatMemoryFilter: { agentId, ...chatMemoryFilter }, current, pageSize: 10, + sort: 'desc', + // orderCondition: 'updatedAt', }, }); } @@ -52,3 +56,10 @@ export function saveMemory(data: MemoryType) { data, }); } + +export function batchDeleteMemory(ids: number[]) { + return request>('/api/chat/memory/batchDelete', { + method: 'POST', + data: { ids }, + }); +} diff --git a/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/ClassMetricTable.tsx b/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/ClassMetricTable.tsx index e15d32046..974105a88 100644 --- a/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/ClassMetricTable.tsx +++ b/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/ClassMetricTable.tsx @@ -222,6 +222,7 @@ const ClassMetricTable: React.FC = ({ onEmptyMetricData }) => { { ...columnsConfig.createInfo, }, + { title: '操作', dataIndex: 'x', diff --git a/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/Term/TermTable.tsx b/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/Term/TermTable.tsx index 6ed97b7e2..70696c490 100644 --- a/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/Term/TermTable.tsx +++ b/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/Term/TermTable.tsx @@ -167,7 +167,6 @@ const TermTable: React.FC = ({}) => { { queryTermList(value); }}