remove type from loading

This commit is contained in:
Sashank Meka
2026-01-13 22:02:20 -05:00
parent 861c11b786
commit 8af50b9418
2 changed files with 103 additions and 2 deletions

View File

@@ -74,8 +74,20 @@ export class KnowledgeGraphManager {
const lines = data.split("\n").filter(line => line.trim() !== "");
return lines.reduce((graph: KnowledgeGraph, line) => {
const item = JSON.parse(line);
if (item.type === "entity") graph.entities.push(item as Entity);
if (item.type === "relation") graph.relations.push(item as Relation);
if (item.type === "entity") {
graph.entities.push({
name: item.name,
entityType: item.entityType,
observations: item.observations
});
}
if (item.type === "relation") {
graph.relations.push({
from: item.from,
to: item.to,
relationType: item.relationType
});
}
return graph;
}, { entities: [], relations: [] });
} catch (error) {