(graph: KnowledgeGraph)
| 99 | } |
| 100 | |
| 101 | private async saveGraph(graph: KnowledgeGraph): Promise<void> { |
| 102 | const lines = [ |
| 103 | ...graph.entities.map(e => JSON.stringify({ |
| 104 | type: "entity", |
| 105 | name: e.name, |
| 106 | entityType: e.entityType, |
| 107 | observations: e.observations |
| 108 | })), |
| 109 | ...graph.relations.map(r => JSON.stringify({ |
| 110 | type: "relation", |
| 111 | from: r.from, |
| 112 | to: r.to, |
| 113 | relationType: r.relationType |
| 114 | })), |
| 115 | ]; |
| 116 | await fs.writeFile(this.memoryFilePath, lines.join("\n")); |
| 117 | } |
| 118 | |
| 119 | async createEntities(entities: Entity[]): Promise<Entity[]> { |
| 120 | const graph = await this.loadGraph(); |
no outgoing calls
no test coverage detected