# Conversation Memory Module (06_conversation_memory) Stores conversation outputs as embeddings for context-aware retrieval. ## Files - `memory_processor.py`: Parses LLM's output, builds chunks, and stores them in Pinecone. - `config.py`: Configuration for embedding model and Pinecone namespace. - `error_handling.py`: Error handling for Pinecone operations (only needed for full pipeline, not for test_multi_retrieval.py) ## Features - **Deduplication**: Checks similarity before storing. If a memory is >95% similar to an existing one, it's skipped. - **Session Parsing**: Automatically parses LLM's `Query`/`Answer`/`Evidence` format. - **Unified Retrieval**: Designed to work with `04_vectoredb/retriever_multi.py`. ## Usage ### 1. Storing Memory ```python from memory_processor import store_memory_sync raw_output = ''' Query: "What is the patient's age?" Answer: The patient is 45 years old. Evidence: Patient is a 45-year-old male. ''' # Automatically checks for duplicates before storing result = store_memory_sync(raw_output, pinecone_index) if result: print(f"Stored: {result['chunk_id']}") else: print("Skipped (duplicate or error)") ``` ### 2. Retrieval Configuration Adjust thresholds in `04_vectoredb/config.py`: - `MEMORY_MIN_SCORE`: Minimum impact (default 0.4) - `MEMORY_BOOST`: Ranking boost (default 0.05) ## Integration Flow ``` 1. LLM generates answer 2. memory_processor parses & embeds 3. Checks Pinecone for duplicates (>0.95) 4. Stores if unique 5. Future queries retrieve this memory via retriever_multi.py ```