mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-29 20:44:25 +08:00
Compare commits
2 Commits
50ed340ae0
...
b5aa6e046e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5aa6e046e | ||
|
|
29271f7278 |
@@ -38,6 +38,9 @@ public class Agent extends RecordInfo {
|
|||||||
private VisualConfig visualConfig;
|
private VisualConfig visualConfig;
|
||||||
private List<String> admins = Lists.newArrayList();
|
private List<String> admins = Lists.newArrayList();
|
||||||
private List<String> viewers = Lists.newArrayList();
|
private List<String> viewers = Lists.newArrayList();
|
||||||
|
private List<String> adminOrgs = Lists.newArrayList();
|
||||||
|
private List<String> viewOrgs = Lists.newArrayList();
|
||||||
|
private Integer isOpen = 0;
|
||||||
|
|
||||||
public List<String> getTools(AgentToolType type) {
|
public List<String> getTools(AgentToolType type) {
|
||||||
Map<String, Object> map = JSONObject.parseObject(toolConfig, Map.class);
|
Map<String, Object> map = JSONObject.parseObject(toolConfig, Map.class);
|
||||||
@@ -115,4 +118,8 @@ public class Agent extends RecordInfo {
|
|||||||
return list.apply(this).contains(user.getName());
|
return list.apply(this).contains(user.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean openToAll() {
|
||||||
|
return isOpen != null && isOpen == 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,10 @@ public class AgentDO {
|
|||||||
private String admin;
|
private String admin;
|
||||||
|
|
||||||
private String viewer;
|
private String viewer;
|
||||||
|
|
||||||
|
private String adminOrg;
|
||||||
|
|
||||||
|
private String viewOrg;
|
||||||
|
|
||||||
|
private Integer isOpen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tencent.supersonic.chat.server.service.impl;
|
package com.tencent.supersonic.chat.server.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||||
import com.tencent.supersonic.chat.api.pojo.request.ChatMemoryFilter;
|
import com.tencent.supersonic.chat.api.pojo.request.ChatMemoryFilter;
|
||||||
import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
|
import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
|
||||||
import com.tencent.supersonic.chat.server.agent.Agent;
|
import com.tencent.supersonic.chat.server.agent.Agent;
|
||||||
@@ -26,6 +27,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -42,6 +44,9 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ChatModelService chatModelService;
|
private ChatModelService chatModelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("chatExecutor")
|
@Qualifier("chatExecutor")
|
||||||
private ThreadPoolExecutor executor;
|
private ThreadPoolExecutor executor;
|
||||||
@@ -53,17 +58,19 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean filterByAuth(Agent agent, User user, AuthType authType) {
|
private boolean filterByAuth(Agent agent, User user, AuthType authType) {
|
||||||
if (user.isSuperAdmin() || user.getName().equals(agent.getCreatedBy())) {
|
Set<String> orgIds = userService.getUserAllOrgId(user.getName());
|
||||||
|
|
||||||
|
if (user.isSuperAdmin() || agent.openToAll()
|
||||||
|
|| user.getName().equals(agent.getCreatedBy())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
authType = authType == null ? AuthType.VIEWER : authType;
|
authType = authType == null ? AuthType.VIEWER : authType;
|
||||||
switch (authType) {
|
switch (authType) {
|
||||||
case ADMIN:
|
case ADMIN:
|
||||||
return agent.contains(user, Agent::getAdmins);
|
return checkAdminPermission(orgIds, user, agent);
|
||||||
case VIEWER:
|
case VIEWER:
|
||||||
default:
|
default:
|
||||||
return agent.contains(user, Agent::getAdmins)
|
return checkViewPermission(orgIds, user, agent);
|
||||||
|| agent.contains(user, Agent::getViewers);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +168,9 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
|
|||||||
});
|
});
|
||||||
agent.setAdmins(JsonUtil.toList(agentDO.getAdmin(), String.class));
|
agent.setAdmins(JsonUtil.toList(agentDO.getAdmin(), String.class));
|
||||||
agent.setViewers(JsonUtil.toList(agentDO.getViewer(), String.class));
|
agent.setViewers(JsonUtil.toList(agentDO.getViewer(), String.class));
|
||||||
|
agent.setAdminOrgs(JsonUtil.toList(agentDO.getAdminOrg(), String.class));
|
||||||
|
agent.setViewOrgs(JsonUtil.toList(agentDO.getViewOrg(), String.class));
|
||||||
|
agent.setIsOpen(agentDO.getIsOpen());
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,9 +183,56 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
|
|||||||
agentDO.setVisualConfig(JsonUtil.toString(agent.getVisualConfig()));
|
agentDO.setVisualConfig(JsonUtil.toString(agent.getVisualConfig()));
|
||||||
agentDO.setAdmin(JsonUtil.toString(agent.getAdmins()));
|
agentDO.setAdmin(JsonUtil.toString(agent.getAdmins()));
|
||||||
agentDO.setViewer(JsonUtil.toString(agent.getViewers()));
|
agentDO.setViewer(JsonUtil.toString(agent.getViewers()));
|
||||||
|
agentDO.setAdminOrg(JsonUtil.toString(agent.getAdminOrgs()));
|
||||||
|
agentDO.setViewOrg(JsonUtil.toString(agent.getViewOrgs()));
|
||||||
|
agentDO.setIsOpen(agent.getIsOpen());
|
||||||
if (agentDO.getStatus() == null) {
|
if (agentDO.getStatus() == null) {
|
||||||
agentDO.setStatus(1);
|
agentDO.setStatus(1);
|
||||||
}
|
}
|
||||||
return agentDO;
|
return agentDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkAdminPermission(Set<String> orgIds, User user, Agent agent) {
|
||||||
|
List<String> admins = agent.getAdmins();
|
||||||
|
List<String> adminOrgs = agent.getAdminOrgs();
|
||||||
|
if (user.isSuperAdmin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (admins.contains(user.getName()) || agent.getCreatedBy().equals(user.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(adminOrgs)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (String orgId : orgIds) {
|
||||||
|
if (adminOrgs.contains(orgId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkViewPermission(Set<String> orgIds, User user, Agent agent) {
|
||||||
|
if (checkAdminPermission(orgIds, user, agent)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
List<String> viewers = agent.getViewers();
|
||||||
|
List<String> viewOrgs = agent.getViewOrgs();
|
||||||
|
if (agent.openToAll()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (viewers.contains(user.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(viewOrgs)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (String orgId : orgIds) {
|
||||||
|
if (viewOrgs.contains(orgId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -405,4 +405,9 @@ ALTER TABLE s2_chat_context RENAME COLUMN `user` TO `query_user`;
|
|||||||
|
|
||||||
--20241226
|
--20241226
|
||||||
ALTER TABLE s2_chat_memory add column `query_id` BIGINT DEFAULT NULL;
|
ALTER TABLE s2_chat_memory add column `query_id` BIGINT DEFAULT NULL;
|
||||||
ALTER TABLE s2_query_stat_info RENAME COLUMN `sql` TO `query_sql`;
|
ALTER TABLE s2_query_stat_info RENAME COLUMN `sql` TO `query_sql`;
|
||||||
|
|
||||||
|
--20250224
|
||||||
|
ALTER TABLE s2_agent add column `admin_org` varchar(3000) DEFAULT NULL COMMENT '管理员组织';
|
||||||
|
ALTER TABLE s2_agent add column `view_org` varchar(3000) DEFAULT NULL COMMENT '可用组织';
|
||||||
|
ALTER TABLE s2_agent add column `is_open` tinyint DEFAULT NULL COMMENT '是否公开';
|
||||||
@@ -377,8 +377,11 @@ CREATE TABLE IF NOT EXISTS s2_agent
|
|||||||
updated_at TIMESTAMP null,
|
updated_at TIMESTAMP null,
|
||||||
enable_search int null,
|
enable_search int null,
|
||||||
enable_feedback int null,
|
enable_feedback int null,
|
||||||
admin varchar(1000),
|
`admin` varchar(3000) DEFAULT NULL , -- administrator
|
||||||
viewer varchar(1000),
|
`admin_org` varchar(3000) DEFAULT NULL , -- administrators organization
|
||||||
|
`is_open` TINYINT DEFAULT NULL , -- whether the public
|
||||||
|
`viewer` varchar(3000) DEFAULT NULL , -- available users
|
||||||
|
`view_org` varchar(3000) DEFAULT NULL , -- available organization
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
); COMMENT ON TABLE s2_agent IS 'agent information table';
|
); COMMENT ON TABLE s2_agent IS 'agent information table';
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ CREATE TABLE IF NOT EXISTS `s2_agent` (
|
|||||||
`created_at` datetime DEFAULT NULL,
|
`created_at` datetime DEFAULT NULL,
|
||||||
`updated_by` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
`updated_by` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
`updated_at` datetime DEFAULT NULL,
|
`updated_at` datetime DEFAULT NULL,
|
||||||
`admin` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
|
`admin` varchar(3000) DEFAULT NULL COMMENT '管理员',
|
||||||
`viewer` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
|
`admin_org` varchar(3000) DEFAULT NULL COMMENT '管理员组织',
|
||||||
|
`is_open` tinyint DEFAULT NULL COMMENT '是否公开',
|
||||||
|
`viewer` varchar(3000) DEFAULT NULL COMMENT '可用用户',
|
||||||
|
`view_org` varchar(3000) DEFAULT NULL COMMENT '可用组织',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ CREATE TABLE IF NOT EXISTS s2_agent (
|
|||||||
created_at timestamp DEFAULT NULL,
|
created_at timestamp DEFAULT NULL,
|
||||||
updated_by varchar(100) DEFAULT NULL,
|
updated_by varchar(100) DEFAULT NULL,
|
||||||
updated_at timestamp DEFAULT NULL,
|
updated_at timestamp DEFAULT NULL,
|
||||||
admin varchar(1000) DEFAULT NULL,
|
admin varchar(3000) DEFAULT NULL,
|
||||||
viewer varchar(1000) DEFAULT NULL
|
admin_org varchar(3000) DEFAULT NULL,
|
||||||
|
is_open smallint DEFAULT NULL,
|
||||||
|
viewer varchar(3000) DEFAULT NULL,
|
||||||
|
view_org varchar(3000) DEFAULT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS s2_auth_groups (
|
CREATE TABLE IF NOT EXISTS s2_auth_groups (
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -391,4 +390,15 @@
|
|||||||
|
|
||||||
.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