MCPcopy Create free account
hub / github.com/InternScience/InternAgent / add_documents

Method add_documents

tasks/AutoMem/code/memory_layer.py:472–489  ·  view source on GitHub ↗

One-time Add documents to both BM25 and semantic index

(self, documents: List[str])

Source from the content-addressed store, hash-verified

470 return retriever
471
472 def add_documents(self, documents: List[str]) -> bool:
473 """One-time Add documents to both BM25 and semantic index"""
474 if not documents:
475 return
476
477 # Tokenize for BM25
478 tokenized_docs = [doc.lower().split() for doc in documents]
479 self.bm25 = BM25Okapi(tokenized_docs)
480
481 # Create embeddings
482 self.embeddings = self.model.encode(documents)
483 self.corpus = documents
484 doc_idx = 0
485 for document in documents:
486 self.document_ids[document] = doc_idx
487 doc_idx += 1
488
489 return True
490
491 def add_document(self, document: str) -> bool:
492 """Add a single document to the retriever.

Callers 4

add_noteMethod · 0.45
consolidate_memoriesMethod · 0.45

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected