MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / _generate_answer

Method _generate_answer

methods/graph_rag.py:447–461  ·  view source on GitHub ↗

Generate final answer using LLM.

(self, query: str, context: str)

Source from the content-addressed store, hash-verified

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
463class GraphRAG:
464 """Main GraphRAG system coordinating document processing, graph building, and querying."""

Callers 1

queryMethod · 0.95

Calls 1

_truncate_contextMethod · 0.95

Tested by

no test coverage detected