Vector Memory is a terminal-based AI assistant that uses Google's Gemini for conversational intelligence and Pinecone for persistent, queryable long-term memory.
- Natural Conversation: Engage in natural, human-like conversations.
- Persistent Memory: Remembers key facts from conversations.
- Context-Aware Responses: Retrieves relevant memories to provide contextually-aware, personalized responses.
- Continuous Learning: Continuously learns and appends new memories over time.
- Vector Normalization: Ensures that vector embeddings are normalized for accurate cosine similarity calculations, making the system more robust.
The application follows a request/response/memory cycle:
- User Input: The user enters a message.
- Memory Retrieval: The application generates a vector embedding of the user's input and queries the Pinecone index to find the most similar memories.
- Context Assembly: A new prompt is constructed for the chat model, including a system prompt, the retrieved memories, and the user's current message.
- LLM Interaction: The assembled prompt is sent to the Gemini model.
- Response Generation: The application receives and displays the generated response.
- Memory Extraction & Storage: The conversation turn is sent to Gemini in a separate call to extract new, permanent facts. These facts are then embedded and upserted into the Pinecone index.
graph TD
A[User Input] --> B{Generate Embedding};
B --> C[Query Pinecone];
C --> D[Retrieve Memories];
D --> E{Assemble Prompt};
A --> E;
E --> F[Send to Gemini];
F --> G[Display Response];
F --> H{Extract New Facts};
H --> I[Embed New Facts];
I --> J[Upsert to Pinecone];
- Language: Python
- LLM: Google Gemini
- Vector Database: Pinecone
- Libraries:
google-generativeaipinecone-clientpython-dotenvrichnumpy
-
Clone the repository:
git clone https://github.com/your-username/vector-memory.git cd vector-memory -
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.envfile in the root of the project and add your API keys:GEMINI_API_KEY="YOUR_GEMINI_API_KEY" PINECONE_API_KEY="YOUR_PINECONE_API_KEY"
To run the application, execute the following command:
python vector_memory.py- System Prompt: You can customize the AI's personality and behavior by modifying the
SYSTEM_PROMPTvariable invector_memory.py. - Initial Data: You can add your own initial facts to the
INITIAL_FACTSlist invector_memory.pyto give the AI some starting knowledge.