Generate final answer using LLM.
(self, query: str, context: str)
| 445 | return False, "" |
| 446 | |
| 447 | def _generate_answer(self, query: str, context: str) -> str: |
| 448 | """Generate final answer using LLM.""" |
| 449 | response_prompt = PromptTemplate( |
| 450 | input_variables=["query", "context"], |
| 451 | template=( |
| 452 | "Based on the following context, please answer the query very concisely.\n\n" |
| 453 | "Context: {context}\n\nQuery: {query}" |
| 454 | ) |
| 455 | ) |
| 456 | response_chain = response_prompt | self.llm |
| 457 | |
| 458 | truncated_context = self._truncate_context(context) |
| 459 | response = response_chain.invoke({"query": query, "context": truncated_context}) |
| 460 | |
| 461 | return response |
| 462 | |
| 463 | class GraphRAG: |
| 464 | """Main GraphRAG system coordinating document processing, graph building, and querying.""" |
no test coverage detected