Enhance semantic links with LLM classification and richer UI labels

This commit is contained in:
phyroslam
2026-04-12 21:37:07 -07:00
parent 12a82372f4
commit 96989d0ec3
3 changed files with 283 additions and 24 deletions

View File

@@ -12,6 +12,10 @@ type SemanticLink = {
source_entity_id: string
target_entity_type: string
target_entity_id: string
source_entity_label?: string
target_entity_label?: string
source_entity_name?: string
target_entity_name?: string
link_type: string
status: string
origin: string
@@ -53,9 +57,18 @@ const getOtherSide = (link: SemanticLink) => {
return {
entityType: isSource ? link.target_entity_type : link.source_entity_type,
entityId: isSource ? link.target_entity_id : link.source_entity_id,
entityLabel: isSource ? link.target_entity_label : link.source_entity_label,
entityName: isSource ? link.target_entity_name : link.source_entity_name,
}
}
const formatLinkType = (value?: string) => {
if (!value) return 'Related'
return value
.replace(/_/g, ' ')
.replace(/\b\w/g, (c) => c.toUpperCase())
}
const parseEvidence = (raw: any) => {
if (!raw) return null
if (typeof raw === 'object') return raw
@@ -142,10 +155,11 @@ watch(
>
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="text-sm font-medium">
{{ getOtherSide(link).entityType }} · {{ getOtherSide(link).entityId }}
{{ getOtherSide(link).entityLabel || getOtherSide(link).entityType }} ·
{{ getOtherSide(link).entityName || getOtherSide(link).entityId }}
</div>
<div class="text-xs text-muted-foreground">
{{ link.link_type }} {{ link.origin }} {{ formatConfidence(link.confidence) }}
{{ formatLinkType(link.link_type) }} {{ link.origin }} {{ formatConfidence(link.confidence) }}
</div>
</div>
@@ -160,19 +174,22 @@ watch(
<Separator />
<div>
<div class="font-medium text-foreground">Evidence</div>
<div v-if="parseEvidence(link.evidence)?.sourceSignals?.length">
<div class="mt-1">Source signals:</div>
<p v-if="parseEvidence(link.evidence)?.explanation" class="mt-1 text-foreground">
{{ parseEvidence(link.evidence).explanation }}
</p>
<div v-if="parseEvidence(link.evidence)?.matchedSignals?.length" class="mt-2">
<div>Matched context:</div>
<ul class="list-disc pl-4">
<li
v-for="(signal, idx) in parseEvidence(link.evidence).sourceSignals"
v-for="(signal, idx) in parseEvidence(link.evidence).matchedSignals"
:key="idx"
>
{{ signal.sourceKind }}: {{ signal.text }}
{{ signal }}
</li>
</ul>
</div>
<div v-if="parseEvidence(link.evidence)?.matchedChunks?.length" class="mt-2">
<div>Matched:</div>
<div>Matched excerpts:</div>
<ul class="list-disc pl-4">
<li
v-for="(match, idx) in parseEvidence(link.evidence).matchedChunks"