(self,
model_name: str = 'all-MiniLM-L6-v2',
llm_backend: str = "sglang",
llm_model: str = "gpt-4o-mini",
evo_threshold: int = 100,
api_key: Optional[str] = None,
api_base: Optional[str] = None,
sglang_host: str = "http://localhost",
sglang_port: int = 30000)
| 676 | |
| 677 | # Load other attributes |
| 678 | if os.path.exists(retriever_cache_file): |
| 679 | print(f"Loading corpus from {retriever_cache_file}") |
| 680 | with open(retriever_cache_file, 'rb') as f: |
| 681 | state = pickle.load(f) |
| 682 | self.corpus = state['corpus'] |
| 683 | self.document_ids = state['document_ids'] |
| 684 | print(f"Loaded corpus with {len(self.corpus)} documents") |
| 685 | else: |
| 686 | print(f"Corpus file not found: {retriever_cache_file}") |
| 687 | |
| 688 | return self |
| 689 | |
| 690 | @classmethod |
| 691 | def load_from_local_memory(cls, memories: Dict, model_name: str) -> 'SimpleEmbeddingRetriever': |
| 692 | """Load retriever state from memory""" |
| 693 | # Create documents combining content and metadata for each memory |
| 694 | all_docs = [] |
| 695 | for m in memories.values(): |
| 696 | metadata_text = f"{m.context} {' '.join(m.keywords)} {' '.join(m.tags)}" |
| 697 | doc = f"{m.content} , {metadata_text}" |
| 698 | all_docs.append(doc) |
| 699 | |
| 700 | # Create and initialize retriever |
| 701 | retriever = cls(model_name) |
| 702 | retriever.add_documents(all_docs) |
| 703 | return retriever |
| 704 | |
| 705 | class AgenticMemorySystem: |
| 706 | """Memory management system with embedding-based retrieval""" |
| 707 | def __init__(self, |
| 708 | model_name: str = 'all-MiniLM-L6-v2', |
| 709 | llm_backend: str = "sglang", |
| 710 | llm_model: str = "gpt-4o-mini", |
| 711 | evo_threshold: int = 100, |
| 712 | api_key: Optional[str] = None, |
| 713 | api_base: Optional[str] = None, |
| 714 | sglang_host: str = "http://localhost", |
| 715 | sglang_port: int = 30000, |
| 716 | max_tokens: int = 2000, |
| 717 | usage_tracker: Optional[Any] = None): |
| 718 | self.memories = {} # id -> MemoryNote |
| 719 | self.retriever = SimpleEmbeddingRetriever(model_name) |
| 720 | self.llm_controller = LLMController( |
| 721 | llm_backend, llm_model, api_key, api_base, |
| 722 | sglang_host, sglang_port, max_tokens=max_tokens, |
| 723 | usage_tracker=usage_tracker, |
| 724 | ) |
| 725 | self.evolution_system_prompt = ''' |
nothing calls this directly
no test coverage detected