mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
(feature)(supersonic-fe) add permission manage in agent (#2095)
This commit is contained in:
@@ -209,5 +209,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
}
|
},
|
||||||
|
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Form, Input, Button, Switch, Tabs, Select, message, Space, Tooltip, Row, Col } from 'antd';
|
import { Form, Input, Button, Switch, Tabs, Select, message, Space, Tooltip } from 'antd';
|
||||||
import MainTitleMark from '@/components/MainTitleMark';
|
import MainTitleMark from '@/components/MainTitleMark';
|
||||||
import { AgentType, ChatAppConfig, ChatAppConfigItem } from './type';
|
import { AgentType, ChatAppConfig } from './type';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import styles from './style.less';
|
import styles from './style.less';
|
||||||
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
@@ -9,9 +9,9 @@ import ToolsSection from './ToolsSection';
|
|||||||
import globalStyles from '@/global.less';
|
import globalStyles from '@/global.less';
|
||||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||||
import SelectTMEPerson from '@/components/SelectTMEPerson';
|
import SelectTMEPerson from '@/components/SelectTMEPerson';
|
||||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
import { getLlmModelAppList, getLlmList } from '../../services/system';
|
||||||
import { getLlmModelTypeList, getLlmModelAppList, getLlmList } from '../../services/system';
|
|
||||||
import MemorySection from './MemorySection';
|
import MemorySection from './MemorySection';
|
||||||
|
import PermissionSection from './PermissionSection';
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
const { TextArea } = Input;
|
const { TextArea } = Input;
|
||||||
@@ -195,16 +195,6 @@ const AgentForm: React.FC<Props> = ({ editAgent, onSaveAgent, onCreateToolBtnCli
|
|||||||
<FormItem name="enableFeedback" label="开启用户确认" valuePropName="checked" htmlFor="">
|
<FormItem name="enableFeedback" label="开启用户确认" valuePropName="checked" htmlFor="">
|
||||||
<Switch />
|
<Switch />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
{/* <FormItem
|
|
||||||
name={['multiTurnConfig', 'enableMultiTurn']}
|
|
||||||
label="开启多轮对话"
|
|
||||||
valuePropName="checked"
|
|
||||||
>
|
|
||||||
<Switch />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem name="enableMemoryReview" label="开启记忆评估" valuePropName="checked">
|
|
||||||
<Switch />
|
|
||||||
</FormItem> */}
|
|
||||||
<FormItem
|
<FormItem
|
||||||
name={['toolConfig', 'simpleMode']}
|
name={['toolConfig', 'simpleMode']}
|
||||||
label="开启精简模式"
|
label="开启精简模式"
|
||||||
@@ -214,7 +204,6 @@ const AgentForm: React.FC<Props> = ({ editAgent, onSaveAgent, onCreateToolBtnCli
|
|||||||
>
|
>
|
||||||
<Switch />
|
<Switch />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
<FormItem
|
<FormItem
|
||||||
name={['toolConfig', 'debugMode']}
|
name={['toolConfig', 'debugMode']}
|
||||||
label="开启调试信息"
|
label="开启调试信息"
|
||||||
@@ -286,8 +275,6 @@ const AgentForm: React.FC<Props> = ({ editAgent, onSaveAgent, onCreateToolBtnCli
|
|||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
<Space style={{ alignItems: 'start' }}>
|
<Space style={{ alignItems: 'start' }}>
|
||||||
{/* <Row> */}
|
|
||||||
{/* <Col flex="400px"> */}
|
|
||||||
<div style={{ width: 350 }}>
|
<div style={{ width: 350 }}>
|
||||||
{modelTypeOptions.map((item) => {
|
{modelTypeOptions.map((item) => {
|
||||||
return (
|
return (
|
||||||
@@ -312,8 +299,6 @@ const AgentForm: React.FC<Props> = ({ editAgent, onSaveAgent, onCreateToolBtnCli
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{/* </Col>
|
|
||||||
<Col flex="auto"> */}
|
|
||||||
<div style={{ width: 900 }}>
|
<div style={{ width: 900 }}>
|
||||||
{modelTypeOptions.map((item) => {
|
{modelTypeOptions.map((item) => {
|
||||||
return (
|
return (
|
||||||
@@ -358,44 +343,10 @@ const AgentForm: React.FC<Props> = ({ editAgent, onSaveAgent, onCreateToolBtnCli
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{/* </Col> */}
|
|
||||||
{/* </Row> */}
|
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// label: '提示词配置',
|
|
||||||
// key: 'promptConfig',
|
|
||||||
// children: (
|
|
||||||
// <div className={styles.agentFormContainer}>
|
|
||||||
// <FormItem
|
|
||||||
// name={['promptConfig', 'promptTemplate']}
|
|
||||||
// label={
|
|
||||||
// <>
|
|
||||||
// <Space>
|
|
||||||
// 提示词模板
|
|
||||||
// <Tooltip
|
|
||||||
// overlayInnerStyle={{ width: 400 }}
|
|
||||||
// title={
|
|
||||||
// <>
|
|
||||||
// {tips.map((tip) => (
|
|
||||||
// <div>{tip}</div>
|
|
||||||
// ))}
|
|
||||||
// </>
|
|
||||||
// }
|
|
||||||
// >
|
|
||||||
// <QuestionCircleOutlined />
|
|
||||||
// </Tooltip>
|
|
||||||
// </Space>
|
|
||||||
// </>
|
|
||||||
// }
|
|
||||||
// >
|
|
||||||
// <Input.TextArea style={{ minHeight: 600 }} />
|
|
||||||
// </FormItem>
|
|
||||||
// </div>
|
|
||||||
// ),
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
label: '工具配置',
|
label: '工具配置',
|
||||||
key: 'tools',
|
key: 'tools',
|
||||||
@@ -406,6 +357,11 @@ const AgentForm: React.FC<Props> = ({ editAgent, onSaveAgent, onCreateToolBtnCli
|
|||||||
key: 'memory',
|
key: 'memory',
|
||||||
children: <MemorySection agentId={editAgent?.id} />,
|
children: <MemorySection agentId={editAgent?.id} />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: '权限管理',
|
||||||
|
key: 'permissonSetting',
|
||||||
|
children: <PermissionSection currentAgent={editAgent} onSaveAgent={onSaveAgent} />,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -421,7 +377,7 @@ const AgentForm: React.FC<Props> = ({ editAgent, onSaveAgent, onCreateToolBtnCli
|
|||||||
<Tabs
|
<Tabs
|
||||||
tabBarExtraContent={
|
tabBarExtraContent={
|
||||||
<Space>
|
<Space>
|
||||||
{activeKey !== 'memory' && (
|
{activeKey !== 'memory' && activeKey !== 'permissonSetting' && (
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
loading={saveLoading}
|
loading={saveLoading}
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { Form, Switch } from 'antd';
|
||||||
|
import SelectPartner from '@/components/SelectPartner';
|
||||||
|
import SelectTMEPerson from '@/components/SelectTMEPerson';
|
||||||
|
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||||
|
import styles from './style.less';
|
||||||
|
import { AgentType } from './type';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
currentAgent?: AgentType;
|
||||||
|
onSaveAgent: (agent: AgentType, noTip?: boolean) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
|
const PermissionSection: React.FC<Props> = ({ currentAgent, onSaveAgent }) => {
|
||||||
|
const [isOpenState, setIsOpenState] = useState(true);
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
form.setFieldsValue({
|
||||||
|
...currentAgent,
|
||||||
|
});
|
||||||
|
setIsOpenState(currentAgent?.isOpen === 1);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const saveAuth = async () => {
|
||||||
|
const values = await form.validateFields();
|
||||||
|
const { admins, adminOrgs, isOpen, viewOrgs = [], viewers = [] } = values;
|
||||||
|
const agent = {
|
||||||
|
...(currentAgent || {}),
|
||||||
|
admins,
|
||||||
|
adminOrgs,
|
||||||
|
viewOrgs,
|
||||||
|
viewers,
|
||||||
|
isOpen: isOpen ? 1 : 0,
|
||||||
|
};
|
||||||
|
onSaveAgent(agent as any);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form
|
||||||
|
form={form}
|
||||||
|
layout="vertical"
|
||||||
|
onValuesChange={(value) => {
|
||||||
|
const { isOpen } = value;
|
||||||
|
if (isOpen !== undefined) {
|
||||||
|
setIsOpenState(isOpen);
|
||||||
|
}
|
||||||
|
saveAuth();
|
||||||
|
}}
|
||||||
|
className={styles.permissionSection}
|
||||||
|
>
|
||||||
|
<FormItem
|
||||||
|
name="admins"
|
||||||
|
label={
|
||||||
|
<FormItemTitle title={'管理员'} subTitle={'管理员将拥有主题域下所有编辑及访问权限'} />
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTMEPerson placeholder="请邀请团队成员" />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem name="adminOrgs" label="按组织">
|
||||||
|
<SelectPartner
|
||||||
|
type="selectedDepartment"
|
||||||
|
treeSelectProps={{
|
||||||
|
placeholder: '请选择需要授权的部门',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<Form.Item label={<FormItemTitle title={'设为公开'} />} name="isOpen" valuePropName="checked">
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
|
{!isOpenState && (
|
||||||
|
<>
|
||||||
|
<FormItem name="viewOrgs" label="按组织">
|
||||||
|
<SelectPartner
|
||||||
|
type="selectedDepartment"
|
||||||
|
treeSelectProps={{
|
||||||
|
placeholder: '请选择需要授权的部门',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem name="viewers" label="按个人">
|
||||||
|
<SelectTMEPerson placeholder="请选择需要授权的个人" />
|
||||||
|
</FormItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PermissionSection;
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agentFormTitle{
|
.agentFormTitle {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -381,7 +381,6 @@
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.agentChatModelCell {
|
.agentChatModelCell {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
&:hover {
|
&:hover {
|
||||||
@@ -392,3 +391,14 @@
|
|||||||
.agentChatModelCellActive {
|
.agentChatModelCellActive {
|
||||||
background-color: #f0f5ff;
|
background-color: #f0f5ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.permissionSection {
|
||||||
|
width: 1000px;
|
||||||
|
height: calc(100vh - 250px);
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
row-gap: 40px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|||||||
@@ -95,10 +95,14 @@ export type AgentType = {
|
|||||||
enableSearch?: 0 | 1;
|
enableSearch?: 0 | 1;
|
||||||
enableFeedback?: 0 | 1;
|
enableFeedback?: 0 | 1;
|
||||||
toolConfig?: string;
|
toolConfig?: string;
|
||||||
// modelConfig?: LlmConfigType;
|
|
||||||
chatAppConfig: ChatAppConfig;
|
chatAppConfig: ChatAppConfig;
|
||||||
multiTurnConfig?: MultiTurnConfig;
|
multiTurnConfig?: MultiTurnConfig;
|
||||||
visualConfig?: VisualConfig;
|
visualConfig?: VisualConfig;
|
||||||
|
admins?: string[];
|
||||||
|
adminOrgs?: string[];
|
||||||
|
viewers?: string[];
|
||||||
|
viewOrgs?: string[];
|
||||||
|
isOpen: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ModelType = {
|
export type ModelType = {
|
||||||
|
|||||||
28637
webapp/pnpm-lock.yaml
generated
28637
webapp/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user