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

Class DocumentProcessor

methods/graph_rag.py:126–142  ·  view source on GitHub ↗

Processes documents into chunks and creates embeddings.

Source from the content-addressed store, hash-verified

124 answer: str = Field(description="The current answer based on the context")
125
126class DocumentProcessor:
127 """Processes documents into chunks and creates embeddings."""
128
129 def __init__(self, embedding_model: str = None, chunk_size: int = DEFAULT_CHUNK_SIZE,
130 chunk_overlap: int = DEFAULT_CHUNK_OVERLAP):
131 self.text_splitter = RecursiveCharacterTextSplitter(
132 chunk_size=chunk_size,
133 chunk_overlap=chunk_overlap
134 )
135 self.embeddings = _get_embeddings(embedding_model)
136 self.vector_store = None
137
138 def process_documents(self, documents: List[Document]) -> Tuple[List, Any]:
139 """Split documents and create vector store."""
140 splits = self.text_splitter.split_documents(documents)
141 self.vector_store = FAISS.from_documents(splits, self.embeddings)
142 return splits, self.vector_store
143
144class KnowledgeGraph:
145 """Builds and manages a knowledge graph from document chunks."""

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected