portal: 圖譜鄰居渲染修 [object Object]+關聯列從 workflow neighbors 導出
- workflow 版 graph_neighbors 的 neighbors 是 {node,predicate,from,depth} 物件,
renderGraph 期望字串 → 節點 chips 全變 [object Object];正規化成名字再渲染。
- workflow 版 edges 恆空 → 關聯永遠 0;neighbor 物件本身就是一條邊,導出成
{subject,predicate,object} 餵關聯列(plugin 版行為不變)。
- 邊列 subject 比對改大小寫不敏感(graph 查詢端已正規化,搜 rag 命中節點 RAG)。
- 來源:leo RAG demo 客戶測試回饋問題 3(鄰居/關聯顯示有誤)。
This commit is contained in:
@@ -749,11 +749,23 @@ function renderPortalHtml(brand: string, sourceWebBase = ''): string {
|
||||
if (!x.ok) { $('se-count').innerHTML = '<span class="err">' + esc(x.d.error || ('關聯查詢失敗(HTTP ' + x.status + ')')) + '</span>'; renderGraphEmpty(x.d.error || '關聯查詢失敗'); return; }
|
||||
var neighbors = x.d.neighbors || [];
|
||||
var edges = x.d.edges || [];
|
||||
$('se-count').textContent = '節點「' + name + '」・鄰居 ' + neighbors.length + '・關聯 ' + edges.length;
|
||||
if (!neighbors.length) { renderGraphEmpty('尚無關聯資料——這個名字還沒有連進知識圖譜。'); return; }
|
||||
renderGraph(name, neighbors.slice(0, 10));
|
||||
// 形狀相容(Arcrun#57 家族):plugin 版 neighbors 是字串、workflow 版是
|
||||
// { node, predicate, from, depth } 物件——不正規化會渲染成 [object Object]。
|
||||
var names = neighbors.map(function (nb) {
|
||||
if (typeof nb === 'string') return nb;
|
||||
return (nb && (nb.node || nb.name)) || '';
|
||||
}).filter(Boolean);
|
||||
// workflow 版 edges 恆空,但 neighbor 物件本身就是一條邊(from --predicate--> node)→ 導出。
|
||||
if (!edges.length) {
|
||||
edges = neighbors.filter(function (nb) { return nb && typeof nb === 'object' && nb.predicate; })
|
||||
.map(function (nb) { return { subject: nb.from || name, predicate: nb.predicate, object: nb.node }; });
|
||||
}
|
||||
$('se-count').textContent = '節點「' + name + '」・鄰居 ' + names.length + '・關聯 ' + edges.length;
|
||||
if (!names.length) { renderGraphEmpty('尚無關聯資料——這個名字還沒有連進知識圖譜。'); return; }
|
||||
renderGraph(name, names.slice(0, 10));
|
||||
$('gr-edges').innerHTML = edges.slice(0, 12).map(function (t) {
|
||||
var other = t.subject === name ? t.object : t.subject;
|
||||
// 大小寫不敏感比對(graph 查詢已正規化:搜 rag 會命中節點 RAG)
|
||||
var other = String(t.subject).toLowerCase() === String(name).toLowerCase() ? t.object : t.subject;
|
||||
return '<div class="nbrow" data-gnode="' + esc(other) + '">' +
|
||||
'<span class="tag green" style="flex:none">' + esc(t.predicate || '關聯') + '</span>' +
|
||||
'<span style="word-break:break-word">' + esc(other) + '</span>' +
|
||||
|
||||
Reference in New Issue
Block a user