Demo: ingest a document, then query the graph.
()
| 166 | |
| 167 | |
| 168 | def main(): |
| 169 | """Demo: ingest a document, then query the graph.""" |
| 170 | skill = ContextGraphSkill() |
| 171 | |
| 172 | # ===== INGESTION ===== |
| 173 | document = """ |
| 174 | System crashes due to memory leaks. |
| 175 | Memory leaks occur when objects are not released. |
| 176 | """ |
| 177 | |
| 178 | result = ingest_document(skill, document) |
| 179 | print(f"\n[INGEST RESULT] Nodes added: {result['nodes_added']}, " f"Edges added: {result['edges_added']}") |
| 180 | if result["errors"]: |
| 181 | print(f"Errors: {result['errors']}") |
| 182 | |
| 183 | # ===== RETRIEVAL ===== |
| 184 | queries = [ |
| 185 | "Why does the system crash?", |
| 186 | "What causes memory leaks?", |
| 187 | ] |
| 188 | |
| 189 | for query in queries: |
| 190 | result = query_graph(skill, query) |
| 191 | if result["success"]: |
| 192 | print(f" Nodes found: {result['nodes_found']}, Edges found: {result['edges_found']}") |
| 193 | else: |
| 194 | print(f" Error: {result['error']}") |
| 195 | |
| 196 | |
| 197 | if __name__ == "__main__": |
no test coverage detected