Merge pull request #847 from SuanmoSuanyangTechnology/feature/ui_upgrade_zy
fix(web): agent knowledge
This commit is contained in:
@@ -229,10 +229,11 @@ const Agent = forwardRef<AgentRef, { onFeaturesLoad?: (features: FeaturesConfigF
|
|||||||
...knowledgeRest,
|
...knowledgeRest,
|
||||||
knowledge_bases: knowledge_bases.map(item => ({
|
knowledge_bases: knowledge_bases.map(item => ({
|
||||||
kb_id: item.kb_id || item.id,
|
kb_id: item.kb_id || item.id,
|
||||||
|
retrieve_type: item.retrieve_type,
|
||||||
top_k: item.top_k,
|
top_k: item.top_k,
|
||||||
similarity_threshold: item.similarity_threshold,
|
similarity_threshold: item.similarity_threshold,
|
||||||
vector_similarity_weight: item.vector_similarity_weight,
|
vector_similarity_weight: item.vector_similarity_weight,
|
||||||
...(item.config || {})
|
// ...(item.config || {})
|
||||||
}))
|
}))
|
||||||
} as KnowledgeConfig : null,
|
} as KnowledgeConfig : null,
|
||||||
tools: tools.map(vo => {
|
tools: tools.map(vo => {
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ const Knowledge: FC<{value?: KnowledgeConfig; onChange?: (config: KnowledgeConfi
|
|||||||
const list = [...knowledgeList]
|
const list = [...knowledgeList]
|
||||||
list[index] = {
|
list[index] = {
|
||||||
...list[index],
|
...list[index],
|
||||||
|
...values,
|
||||||
config: {...values as KnowledgeConfigForm}
|
config: {...values as KnowledgeConfigForm}
|
||||||
}
|
}
|
||||||
setKnowledgeList([...list])
|
setKnowledgeList([...list])
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ const KnowledgeListModal = forwardRef<KnowledgeModalRef, KnowledgeModalProps>(({
|
|||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
refresh(selectedRows.map(item => ({
|
refresh(selectedRows.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
|
similarity_threshold: 0.7,
|
||||||
|
retrieve_type: "hybrid",
|
||||||
|
top_k: 3,
|
||||||
|
weight: 1,
|
||||||
config: {
|
config: {
|
||||||
similarity_threshold: 0.7,
|
similarity_threshold: 0.7,
|
||||||
retrieve_type: "hybrid",
|
retrieve_type: "hybrid",
|
||||||
|
|||||||
@@ -61,6 +61,20 @@ const CaseList: FC<CaseListProps> = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const form = Form.useFormInstance();
|
const form = Form.useFormInstance();
|
||||||
|
|
||||||
|
const bringLoopChildrenToFront = (cell: any) => {
|
||||||
|
const type = cell?.getData()?.type;
|
||||||
|
if ((type !== 'loop' && type !== 'iteration') || !graphRef?.current) return;
|
||||||
|
const cycleId = cell.getData().id;
|
||||||
|
graphRef.current.getEdges().forEach((edge: any) => {
|
||||||
|
const src = graphRef.current?.getCellById(edge.getSourceCellId());
|
||||||
|
const tgt = graphRef.current?.getCellById(edge.getTargetCellId());
|
||||||
|
if (src?.getData()?.cycle === cycleId || tgt?.getData()?.cycle === cycleId) edge.toFront();
|
||||||
|
});
|
||||||
|
graphRef.current.getNodes().forEach((n: any) => {
|
||||||
|
if (n.getData()?.cycle === cycleId) n.toFront();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Recalculate node height and port Y positions without rebuilding ports
|
// Recalculate node height and port Y positions without rebuilding ports
|
||||||
const updateNodeLayout = (cases: any[]) => {
|
const updateNodeLayout = (cases: any[]) => {
|
||||||
if (!selectedNode || !graphRef?.current) return;
|
if (!selectedNode || !graphRef?.current) return;
|
||||||
@@ -141,6 +155,8 @@ const CaseList: FC<CaseListProps> = ({
|
|||||||
}
|
}
|
||||||
sourceCell.toFront()
|
sourceCell.toFront()
|
||||||
selectedNode.toFront()
|
selectedNode.toFront()
|
||||||
|
bringLoopChildrenToFront(sourceCell)
|
||||||
|
bringLoopChildrenToFront(selectedNode)
|
||||||
graphRef.current?.removeCell(edge);
|
graphRef.current?.removeCell(edge);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -186,7 +202,9 @@ const CaseList: FC<CaseListProps> = ({
|
|||||||
...edgeAttrs
|
...edgeAttrs
|
||||||
});
|
});
|
||||||
selectedNode.toFront()
|
selectedNode.toFront()
|
||||||
|
bringLoopChildrenToFront(selectedNode)
|
||||||
targetCell.toFront()
|
targetCell.toFront()
|
||||||
|
bringLoopChildrenToFront(targetCell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,20 @@ const CategoryList: FC<CategoryListProps> = ({ parentName, selectedNode, graphRe
|
|||||||
const form = Form.useFormInstance();
|
const form = Form.useFormInstance();
|
||||||
const formValues = Form.useWatch([parentName], form);
|
const formValues = Form.useWatch([parentName], form);
|
||||||
|
|
||||||
|
const bringLoopChildrenToFront = (cell: any) => {
|
||||||
|
const type = cell?.getData()?.type;
|
||||||
|
if ((type !== 'loop' && type !== 'iteration') || !graphRef?.current) return;
|
||||||
|
const cycleId = cell.getData().id;
|
||||||
|
graphRef.current.getEdges().forEach((edge: any) => {
|
||||||
|
const src = graphRef.current?.getCellById(edge.getSourceCellId());
|
||||||
|
const tgt = graphRef.current?.getCellById(edge.getTargetCellId());
|
||||||
|
if (src?.getData()?.cycle === cycleId || tgt?.getData()?.cycle === cycleId) edge.toFront();
|
||||||
|
});
|
||||||
|
graphRef.current.getNodes().forEach((n: any) => {
|
||||||
|
if (n.getData()?.cycle === cycleId) n.toFront();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Update node ports based on category count changes (add/remove categories)
|
// Update node ports based on category count changes (add/remove categories)
|
||||||
const updateNodePorts = (caseCount: number, removedCaseIndex?: number) => {
|
const updateNodePorts = (caseCount: number, removedCaseIndex?: number) => {
|
||||||
if (!selectedNode || !graphRef?.current) return;
|
if (!selectedNode || !graphRef?.current) return;
|
||||||
@@ -89,7 +103,9 @@ const CategoryList: FC<CategoryListProps> = ({ parentName, selectedNode, graphRe
|
|||||||
...edgeAttrs
|
...edgeAttrs
|
||||||
});
|
});
|
||||||
sourceCell.toFront()
|
sourceCell.toFront()
|
||||||
|
bringLoopChildrenToFront(sourceCell)
|
||||||
selectedNode.toFront()
|
selectedNode.toFront()
|
||||||
|
bringLoopChildrenToFront(selectedNode)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -122,7 +138,9 @@ const CategoryList: FC<CategoryListProps> = ({ parentName, selectedNode, graphRe
|
|||||||
...edgeAttrs
|
...edgeAttrs
|
||||||
});
|
});
|
||||||
selectedNode.toFront()
|
selectedNode.toFront()
|
||||||
|
bringLoopChildrenToFront(selectedNode)
|
||||||
targetCell.toFront()
|
targetCell.toFront()
|
||||||
|
bringLoopChildrenToFront(targetCell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user