Query the system and return answer with context.
(self, query: str)
| 504 | ) |
| 505 | |
| 506 | def query(self, query: str) -> Tuple[str, str]: |
| 507 | """Query the system and return answer with context.""" |
| 508 | if self.query_engine is None: |
| 509 | raise RuntimeError("GraphRAG not initialized. Call process_documents first.") |
| 510 | |
| 511 | final_answer, expanded_context, _, _ = self.query_engine.query(query) |
| 512 | |
| 513 | # Extract text from LLM response if needed |
| 514 | if hasattr(final_answer, 'content'): |
| 515 | final_answer = final_answer.content |
| 516 | |
| 517 | return str(final_answer), expanded_context |
| 518 | |
| 519 | class GraphRAGAgent(BaseAgent): |
| 520 | """GraphRAG Agent - Knowledge graph based RAG method adapter. |