Skip to content

Commit de17aab

Browse files
committed
Merge branch 'hotfix-1.0.0' into develop
2 parents 4961cb1 + 2d17654 commit de17aab

File tree

25 files changed

+287
-159
lines changed

25 files changed

+287
-159
lines changed

app-builder/jane/plugins/aipp-plugin/src/main/resources/sql/data/appbuilder_insert.sql

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

app-engine/frontend/src/pages/addFlow/components/connect-knowledge.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next';
1010
import { useHistory } from 'react-router-dom';
1111
import { useAppDispatch } from '@/store/hook';
1212
import { setIsAutoOpen } from '@/store/common/common';
13-
import { getConnectKnowledgeList } from '@/shared/http/appBuilder';
13+
import { getConnectKnowledgeList, getKnowledgeConfigId } from '@/shared/http/knowledge';
1414
import BookIcon from '@/assets/images/ai/connect-knowledge.png';
1515
import NotConnectIcon from '@/assets/images/ai/not-connect.png';
1616
import ConnectedIcon from '@/assets/images/ai/connected.svg';
@@ -21,18 +21,19 @@ import '../styles/connect-knowledge.scss'
2121
*
2222
* @param modelRef 当前组件ref.
2323
* @param groupId 父组件组件groupId.
24-
* @param updateGroupId 更新父组件groupId的方法.
24+
* @param updateKnowledgeOption 更新父组件groupId的方法.
2525
* @return {JSX.Element}
2626
* @constructor
2727
*/
2828

29-
const ConnectKnowledge = ({ modelRef, groupId, updateGroupId }) => {
29+
const ConnectKnowledge = ({ modelRef, groupId, updateKnowledgeOption }) => {
3030
const { t } = useTranslation();
3131
const dispatch = useAppDispatch();
3232
const navigate = useHistory().push;
3333
const [open, setOpen] = useState(false);
3434
const [connectList, setConnectList] = useState([]);
35-
const [choseId, setChoseId] = useState(groupId);
35+
const [chosenId, setChosenId] = useState(groupId);
36+
const [knowledgeConfigId, setKnowledgeConfigId] = useState('');
3637

3738
useImperativeHandle(modelRef, () => {
3839
return { openModal: () => setOpen(true) };
@@ -41,7 +42,7 @@ const ConnectKnowledge = ({ modelRef, groupId, updateGroupId }) => {
4142
// 确定
4243
const confirm = () => {
4344
setOpen(false);
44-
updateGroupId(choseId);
45+
updateKnowledgeOption(chosenId, knowledgeConfigId);
4546
};
4647

4748
// 获取知识库列表
@@ -60,10 +61,19 @@ const ConnectKnowledge = ({ modelRef, groupId, updateGroupId }) => {
6061
navigate(`/plugin`);
6162
};
6263

64+
// 选择知识库集回调
65+
const onClickKnowledgeSet = async (groupId: String) => {
66+
setChosenId(groupId);
67+
const res = await getKnowledgeConfigId(groupId);
68+
if (res.code === 0) {
69+
setKnowledgeConfigId(res.data);
70+
}
71+
}
72+
6373
useEffect(() => {
6474
if (open) {
6575
getConnectList();
66-
setChoseId(groupId);
76+
setChosenId(groupId);
6777
}
6878
}, [open]);
6979

@@ -87,14 +97,17 @@ const ConnectKnowledge = ({ modelRef, groupId, updateGroupId }) => {
8797
<div className='connect-list'>
8898
{
8999
connectList.map(item =>
90-
<div className={`knowledge-item ${choseId === item.groupId ? 'chose' : ''}`} key={item.groupId} onClick={() => setChoseId(item.groupId)}>
100+
<div className={`knowledge-item ${chosenId === item.groupId ? 'chose' : ''}`}
101+
key={item.groupId}
102+
onClick={() => onClickKnowledgeSet(item.groupId)}
103+
>
91104
<div className='knowledge-title'>
92105
<img src={BookIcon} alt="" style={{ marginRight: 8 }} />
93106
{item.name}
94107
</div>
95108
<div className='knowledge-desc' title={item.description}>{item.description}</div>
96109
<div className='connect-circle'>
97-
<img src={choseId === item.groupId ? ConnectedIcon : NotConnectIcon} alt="" />
110+
<img src={chosenId === item.groupId ? ConnectedIcon : NotConnectIcon} alt="" />
98111
</div>
99112
</div>
100113
)

app-engine/frontend/src/pages/addFlow/components/elsa-stage.tsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ const Stage = (props) => {
6565
const [skillList, setSkillList] = useState([]);
6666
const [promptValue, setPromptValue] = useState('');
6767
const [currentModelInfo, setCurrentModelInfo] = useState({});
68-
const [groupId, setGroupId] = useState("");
68+
const [groupId, setGroupId] = useState('');
69+
const [knowledgeConfigId, setKnowledgeConfigId] = useState('');
6970
const { CONFIGS } = configMap[process.env.NODE_ENV];
7071
const { type, appInfo, setFlowInfo } = useContext(FlowContext);
7172
const testStatus = useAppSelector((state) => state.flowTestStore.testStatus);
@@ -151,10 +152,11 @@ const Stage = (props) => {
151152
});
152153
// 知识库模态框
153154
agent.onKnowledgeBaseSelect((args) => {
154-
let { selectedKnowledgeBases, onSelect, groupId } = args;
155+
let { selectedKnowledgeBases, onSelect, groupId, selectedKnowledgeConfigId } = args;
155156
setGroupId(groupId);
157+
setKnowledgeConfigId(selectedKnowledgeConfigId);
156158
knowledgeCallback.current = onSelect;
157-
modalRef.current.showModal(selectedKnowledgeBases, groupId);
159+
modalRef.current.showModal(selectedKnowledgeBases, groupId, selectedKnowledgeConfigId);
158160
});
159161
// 插件模态框
160162
agent.onPluginSelect((args) => {
@@ -209,8 +211,9 @@ const Stage = (props) => {
209211
agent.listen('SELECT_KNOWLEDGE_BASE_GROUP', (event) => {
210212
connectKnowledgeEvent.current = event;
211213
connectKnowledgeRef.current.openModal();
212-
event.onSelect(groupId);
214+
event.onSelect(groupId, knowledgeConfigId);
213215
setGroupId(event.selectedGroupId);
216+
setKnowledgeConfigId(event.selectedKnowledgeConfigId);
214217
});
215218
// 循环节点
216219
agent.onLoopSelect(({ onSelect }) => {
@@ -252,18 +255,22 @@ const Stage = (props) => {
252255
dispatch(setTestTime(0));
253256
}
254257
}
258+
255259
// hugging-face模型选中
256260
const onModelSelectCallBack = (model) => {
257261
modelCallback.current(model);
258262
}
263+
259264
// 知识库选中
260265
const handleKnowledgeChange = (value) => {
261266
knowledgeCallback.current(value);
262267
}
268+
263269
// 搜索参数配置选中
264270
const handleSearchChange = (value) => {
265271
searchCallback.current(value);
266272
};
273+
267274
// 插件工具流选中
268275
const toolsConfirm = (item) => {
269276
let obj = {};
@@ -286,18 +293,21 @@ const Stage = (props) => {
286293
pluginCallback.current(obj);
287294
}
288295
}
296+
289297
// 自定义表单选中
290298
const formConfirm = (item) => {
291299
formCallback.current(item);
292300
setShowDrawer(false);
293301
}
302+
294303
// 数据实时保存
295304
const handleChange = useCallback(debounce((id) => elsaChange(id), 2000), []);
296305
function elsaChange(id: any) {
297306
let graphChangeData = window.agent.serialize();
298307
currentApp.current.flowGraph.appearance = graphChangeData;
299308
updateAppRunningFlow(id);
300309
}
310+
301311
// 编辑更新应用
302312
async function updateAppRunningFlow(id = undefined) {
303313
currentChange.current = false;
@@ -310,6 +320,7 @@ const Stage = (props) => {
310320
setSaveTime(getCurrentTime());
311321
}
312322
}
323+
313324
// 拖拽完成回调
314325
function handleDragEnter(e) {
315326
const nodeTab = e.dataTransfer.getData('itemTab');
@@ -379,12 +390,13 @@ const Stage = (props) => {
379390
}
380391
}, []);
381392

382-
383393
// 更新groupId
384-
const updateGroupId = (val) => {
385-
connectKnowledgeEvent.current.onSelect(val);
386-
setGroupId(val);
394+
const updateKnowledgeOption = (groupId: String, knowledgeConfigId:String) => {
395+
connectKnowledgeEvent.current.onSelect(groupId, knowledgeConfigId);
396+
setGroupId(groupId);
397+
setKnowledgeConfigId(knowledgeConfigId);
387398
};
399+
388400
return <>
389401
<div
390402
className='content-right'
@@ -468,7 +480,7 @@ const Stage = (props) => {
468480
<ConnectKnowledge
469481
modelRef={connectKnowledgeRef}
470482
groupId={groupId}
471-
updateGroupId={updateGroupId}
483+
updateKnowledgeOption={updateKnowledgeOption}
472484
></ConnectKnowledge>
473485
</>
474486
};

app-engine/frontend/src/pages/configForm/configUi/components/add-knowledge.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useHistory } from 'react-router-dom';
99
import { Button, Input, Dropdown, Modal, Checkbox, Tooltip } from 'antd';
1010
import { SearchOutlined, DownOutlined } from '@ant-design/icons';
1111
import { setSpaClassName } from '@/shared/utils/common';
12-
import { getKnowledgesCard } from '@/shared/http/appBuilder';
12+
import { getKnowledgesCard } from '@/shared/http/knowledge';
1313
import { Message } from '@/shared/utils/message';
1414
import { deepClone } from '@/pages/chatPreview/utils/chat-process';
1515
import { useTranslation } from 'react-i18next';
@@ -37,7 +37,6 @@ const AddKnowledge = (props) => {
3737
const [cachedKnowledgeList, setCachedKnowledgeList] = useState<any>([]);
3838
const searchName = useRef('');
3939
const checkData = useRef<any>([]);
40-
const navigate = useHistory().push;
4140
const typeMap: any = {
4241
VECTOR: t('unstructuredData'),
4342
RDB: t('structuredData'),
@@ -47,18 +46,18 @@ const AddKnowledge = (props) => {
4746
const cancel = () => {
4847
setOpen(false);
4948
};
50-
const showModal = (list = [], groupId: String) => {
49+
const showModal = (list = [], groupId: String, knowledgeConfigId: String) => {
5150
setTotal(0);
5251
checkData.current = deepClone(list);
5352
setOpen(true);
54-
setCheck(groupId);
53+
setCheck(groupId, knowledgeConfigId);
5554
};
5655
// 设置选中列表
57-
const setCheck = (groupId: String) => {
56+
const setCheck = (groupId: String, knowledgeConfigId: String) => {
5857
setListPage(1);
5958
setPageSize(12);
6059
setKnowledgeList(checkData.current);
61-
handleGetKnowledgeOptions(groupId);
60+
handleGetKnowledgeOptions(knowledgeConfigId, groupId);
6261
};
6362

6463
// 过滤Id
@@ -67,13 +66,14 @@ const AddKnowledge = (props) => {
6766
};
6867

6968
// 获取知识库列表
70-
const handleGetKnowledgeOptions = async (grpahGroupId?:String) => {
69+
const handleGetKnowledgeOptions = async (knowledgeConfigId: String, graphGroupId?:String) => {
7170
const params = {
7271
tenantId,
7372
pageIndex: listPage,
7473
pageSize: pageSize,
7574
repoName: encodeURIComponent(searchName.current.trim()),
76-
groupId: grpahGroupId || groupId,
75+
groupId: graphGroupId || groupId,
76+
knowledgeConfigId
7777
};
7878
try {
7979
const res: any = await getKnowledgesCard(params);

app-engine/frontend/src/pages/configForm/configUi/components/add-search.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import React, { useImperativeHandle, useState, useRef } from 'react';
88
import { Modal, Tabs, Radio, Switch, Tooltip, Spin } from 'antd';
99
import { QuestionCircleOutlined } from '@ant-design/icons';
10-
import { getSearchParams } from '@/shared/http/appBuilder';
10+
import { getSearchParams } from '@/shared/http/knowledge';
1111
import { useTranslation } from 'react-i18next';
1212
import { Message } from '@/shared/utils/message';
1313
import type { RadioChangeEvent } from 'antd';

app-engine/frontend/src/pages/configForm/configUi/components/knowledge-container.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const KnowledgeContainer = (props) => {
2323
const { graphOperator, config, updateData, validateList } = props;
2424
const [knowledge, setKnowledge] = useState([]);
2525
const [groupConfig, setGroupConfig] = useState({});
26-
const [groupId, setGroupId] = useState('default');
26+
const [groupId, setGroupId] = useState('');
27+
const [knowledgeConfigId, setKnowledgeConfigId] = useState('');
2728
const [activePanelKey, setActivePanelKey] = useState(['']);
2829
const knowledgeRef: any = useRef(null);
2930
const curKnowledge = useRef(null);
@@ -55,8 +56,9 @@ const KnowledgeContainer = (props) => {
5556
const groupConfig = [config[0], 'option'];
5657
const groupValue = graphOperator.getConfig(groupConfig);
5758
if (groupValue) {
58-
const { groupId } = groupValue;
59+
const { groupId, knowledgeConfigId } = groupValue;
5960
groupId && setGroupId(groupId);
61+
setKnowledgeConfigId(knowledgeConfigId);
6062
setGroupConfig(groupConfig);
6163
curGroupValue.current = groupValue;
6264
}
@@ -69,13 +71,13 @@ const KnowledgeContainer = (props) => {
6971
}
7072

7173
// 更新groupId
72-
const updateGroupId = (val) => {
73-
setGroupId(val);
74-
if (curGroupValue.current.groupId !== val) {
75-
curGroupValue.current.groupId = val;
76-
graphOperator.update(groupConfig, curGroupValue.current);
77-
updateData();
78-
}
74+
const updateKnowledgeOption = (groupId: String, knowledgeConfigId:String) => {
75+
setGroupId(groupId);
76+
setKnowledgeConfigId(knowledgeConfigId);
77+
curGroupValue.current.groupId = groupId;
78+
curGroupValue.current.knowledgeConfigId = knowledgeConfigId;
79+
graphOperator.update(groupConfig, curGroupValue.current);
80+
updateData();
7981
}
8082

8183
// 更新每一条是否存在
@@ -138,6 +140,7 @@ const KnowledgeContainer = (props) => {
138140
knowledgeRef={knowledgeRef}
139141
knowledge={knowledge}
140142
groupId={groupId}
143+
knowledgeConfigId={knowledgeConfigId}
141144
updateData={updateKnowledge}
142145
/>
143146
</Panel>
@@ -146,9 +149,9 @@ const KnowledgeContainer = (props) => {
146149
<ConnectKnowledge
147150
modelRef={connectKnowledgeRef}
148151
groupId={groupId}
149-
updateGroupId={updateGroupId}
152+
updateKnowledgeOption={updateKnowledgeOption}
150153
/>
151154
</>
152155
};
153156

154-
export default KnowledgeContainer;
157+
export default KnowledgeContainer;

app-engine/frontend/src/pages/configForm/configUi/components/knowledge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import closeImg from '@/assets/images/close_btn.svg';
1515

1616
const Knowledge = (props) => {
1717
const { t } = useTranslation();
18-
const { knowledge, groupId, updateData, knowledgeRef } = props;
18+
const { knowledge, groupId, updateData, knowledgeRef, knowledgeConfigId } = props;
1919
const [knows, setKnows] = useState([]);
2020
const [showOperateIndex, setShowOperateIndex] = useState(-1);
2121
const { tenantId } = useParams();
@@ -43,7 +43,7 @@ const Knowledge = (props) => {
4343
};
4444

4545
const addKnowledge = () => {
46-
modalRef.current.showModal(knows)
46+
modalRef.current.showModal(knows, groupId, knowledgeConfigId);
4747
};
4848

4949
// hover显示操作按钮

0 commit comments

Comments
 (0)