Merge #46 into develop_web from feature/20251219_zy
fix(web): user memory detail * feature/20251219_zy: (1 commits) fix(web): user memory detail Signed-off-by: zhaoying <zhaoying@redbearai.com> Merged-by: zhaoying <zhaoying@redbearai.com> CR-link: https://codeup.aliyun.com/redbearai/python/redbear-mem-open/change/46
This commit is contained in:
@@ -140,15 +140,12 @@ const SelfReflectionEngine: React.FC = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
setResult(res as Result)
|
setResult(res as Result)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
|
||||||
setRunLoading(false)
|
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setRunLoading(false)
|
setRunLoading(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.catch(() => {
|
||||||
setLoading(false)
|
setRunLoading(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const EndUserProfile:FC = () => {
|
|||||||
return ['name', 'position', 'department', 'contact', 'phone', 'hire_date'].map(key => ({
|
return ['name', 'position', 'department', 'contact', 'phone', 'hire_date'].map(key => ({
|
||||||
key,
|
key,
|
||||||
label: t(`userMemory.${key}`),
|
label: t(`userMemory.${key}`),
|
||||||
children: key === 'hire_date' ? dayjs(data[key as keyof EndUser]).format('YYYY-MM-DD') : String(data[key as keyof EndUser] || ''),
|
children: key === 'hire_date' && data[key] ? dayjs(data[key as keyof EndUser]).format('YYYY-MM-DD') : String(data[key as keyof EndUser] || ''),
|
||||||
}))
|
}))
|
||||||
}, [data])
|
}, [data])
|
||||||
const handleEdit = () => {
|
const handleEdit = () => {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
|||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
...user,
|
...user,
|
||||||
end_user_id: user.id,
|
end_user_id: user.id,
|
||||||
hire_date: dayjs(user.hire_date)
|
hire_date: user.hire_date ? dayjs(user.hire_date) : undefined
|
||||||
});
|
});
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const operations = [
|
|||||||
{ name: 'drag', icon: drag },
|
{ name: 'drag', icon: drag },
|
||||||
{ name: 'zoom', icon: zoom },
|
{ name: 'zoom', icon: zoom },
|
||||||
]
|
]
|
||||||
|
const colors = ['#155EEF', '#369F21', '#4DA8FF', '#FF5D34', '#9C6FFF', '#FF8A4C', '#8BAEF7', '#FFB048']
|
||||||
const RelationshipNetwork:FC = () => {
|
const RelationshipNetwork:FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
@@ -30,7 +31,7 @@ const RelationshipNetwork:FC = () => {
|
|||||||
const [categories, setCategories] = useState<{ name: string }[]>([])
|
const [categories, setCategories] = useState<{ name: string }[]>([])
|
||||||
const [selectedNode, setSelectedNode] = useState<Node | null>(null)
|
const [selectedNode, setSelectedNode] = useState<Node | null>(null)
|
||||||
|
|
||||||
|
console.log('categories', categories)
|
||||||
// 关系网络
|
// 关系网络
|
||||||
const getEdgeData = useCallback(() => {
|
const getEdgeData = useCallback(() => {
|
||||||
if (!id) return
|
if (!id) return
|
||||||
@@ -39,7 +40,7 @@ const RelationshipNetwork:FC = () => {
|
|||||||
const { nodes, edges, statistics } = res as GraphData
|
const { nodes, edges, statistics } = res as GraphData
|
||||||
const curNodes: Node[] = []
|
const curNodes: Node[] = []
|
||||||
const curEdges: Edge[] = []
|
const curEdges: Edge[] = []
|
||||||
const curNodeTypes = Object.keys(statistics.node_types)
|
const curNodeTypes = Object.keys(statistics.node_types).filter(vo => vo !== 'Dialogue')
|
||||||
|
|
||||||
// 计算每个节点的连接数
|
// 计算每个节点的连接数
|
||||||
const connectionCount: Record<string, number> = {}
|
const connectionCount: Record<string, number> = {}
|
||||||
@@ -49,22 +50,22 @@ const RelationshipNetwork:FC = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 处理节点数据
|
// 处理节点数据
|
||||||
nodes.forEach(node => {
|
nodes.filter(vo => vo.label !== 'Dialogue').forEach(node => {
|
||||||
const connections = connectionCount[node.id] || 0
|
const connections = connectionCount[node.id] || 0
|
||||||
const categoryIndex = curNodeTypes.indexOf(node.label)
|
const categoryIndex = curNodeTypes.indexOf(node.label)
|
||||||
|
|
||||||
// 根据节点类型获取显示名称
|
// 根据节点类型获取显示名称
|
||||||
let displayName = ''
|
let displayName = ''
|
||||||
switch (node.label) {
|
switch (node.label) {
|
||||||
case 'Statement':
|
// case 'Statement':
|
||||||
displayName = 'statement' in node.properties ? node.properties.statement?.slice(0, 5) || '' : ''
|
// displayName = 'statement' in node.properties ? node.properties.statement?.slice(0, 5) || '' : ''
|
||||||
break
|
// break
|
||||||
case 'ExtractedEntity':
|
case 'ExtractedEntity':
|
||||||
displayName = 'name' in node.properties ? node.properties.name || '' : ''
|
displayName = 'name' in node.properties ? node.properties.name || '' : ''
|
||||||
break
|
break
|
||||||
default:
|
// default:
|
||||||
displayName = 'content' in node.properties ? node.properties.content?.slice(0, 5) || '' : ''
|
// displayName = 'content' in node.properties ? node.properties.content?.slice(0, 5) || '' : ''
|
||||||
break
|
// break
|
||||||
}
|
}
|
||||||
let symbolSize = 0
|
let symbolSize = 0
|
||||||
if (connections <= 1) {
|
if (connections <= 1) {
|
||||||
@@ -85,7 +86,7 @@ const RelationshipNetwork:FC = () => {
|
|||||||
category: categoryIndex >= 0 ? categoryIndex : 0,
|
category: categoryIndex >= 0 ? categoryIndex : 0,
|
||||||
symbolSize: symbolSize, // 根据连接数调整节点大小
|
symbolSize: symbolSize, // 根据连接数调整节点大小
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: ['#155EEF', '#4DA8FF', '#9C6FFF', '#8BAEF7', '#369F21', '#FF5D34', '#FF8A4C', '#FFB048'][categoryIndex % 8]
|
color: colors[categoryIndex % 8]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -150,17 +151,23 @@ const RelationshipNetwork:FC = () => {
|
|||||||
) : (
|
) : (
|
||||||
<ReactEcharts
|
<ReactEcharts
|
||||||
option={{
|
option={{
|
||||||
colors: ['#155EEF', '4DA8FF', '#9C6FFF', '#8BAEF7', '#369F21', '#FF5D34', '#FF8A4C', '#FFB048'],
|
colors: colors,
|
||||||
tooltip: {
|
tooltip: {
|
||||||
show: false
|
show: false
|
||||||
},
|
},
|
||||||
|
legend: {
|
||||||
|
show: true,
|
||||||
|
bottom: 20,
|
||||||
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
type: 'graph',
|
type: 'graph',
|
||||||
layout: 'force',
|
layout: 'force',
|
||||||
data: nodes || [],
|
data: nodes || [],
|
||||||
links: links || [],
|
links: links || [],
|
||||||
categories: categories || [],
|
categories: categories.map(vo => ({
|
||||||
|
name: t(`userMemory.${vo.name}`)
|
||||||
|
})) || [],
|
||||||
roam: true,
|
roam: true,
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user