Soika Memory - Long-term Memory for AI Agents
Soika Memory is a comprehensive memory management system that provides long-term memory capabilities for AI agents and applications. It enables storage, retrieval, and semantic search of conversation history and contextual information using vector databases and graph networks.
Features
🧠 Core Memory Management
- Create memories: Store conversation messages and context for users, agents, or runs
- Retrieve memories: Get all memories with flexible filtering options
- Search memories: Semantic search through stored memories using vector similarity
- Update memories: Modify existing memories with new information
- Delete memories: Remove specific memories or bulk delete with filters
🔗 Graph Memory
- Knowledge Graph: Extract entities and relationships from conversations
- Graph Search: Find related information through entity relationships
- Multiple Graph Stores: Support for Neo4j, Memgraph, and AWS Neptune
🚀 Multiple LLM Providers
- OpenAI: GPT models with structured output support
- Azure OpenAI: Enterprise-grade OpenAI integration
- Anthropic: Claude models
- Google Gemini: Gemini Pro models
- Groq: High-speed inference
- DeepSeek: Cost-effective models
- XAI: Grok models
- SoikaStack: Integrated AI framework with multi-model support
📊 Vector Store Support
- Qdrant: Default vector database
- Pinecone: Managed vector database
- Chroma: Open-source vector database
- PGVector: PostgreSQL with vector extension
- Google Vertex AI: Vector search
- Baidu: Chinese market support
- LangChain: Framework integration
🌐 Flexible Deployment
- REST API: FastAPI-based server with OpenAPI documentation
- Python Client: Sync and async client libraries
- Proxy Integration: Memory-enhanced OpenAI API proxy
- Docker Support: Container deployment
Quick Start
Installation
pip install ai-memory
Or with optional dependencies:
# With graph support
pip install memory[graph]
# With all vector stores
pip install memory[vector_stores]
# Full installation
pip install memory[graph,vector_stores]
Basic Usage
from soika_memory import Memory
# Initialize memory with SoikaStack provider
m = Memory(
config={
"llm": {
"provider": "soikastack",
"config": {
"api_key": "your-soikastack-api-key",
"model": "llama3.3",
"base_url": "http://localhost:4141/v1"
}
},
"embedder": {
"provider": "soikastack",
"config": {
"api_key": "your-soikastack-api-key",
"model": "bge-m3"
}
}
}
)
# Alternative: Use OpenAI provider
# m = Memory(
# config={
# "llm": {
# "provider": "openai",
# "config": {
# "api_key": "your-openai-api-key",
# "model": "gpt-4"
# }
# },
# "embedder": {
# "provider": "openai",
# "config": {
# "api_key": "your-openai-api-key",
# "model": "text-embedding-3-large"
# }
# }
# }
# )
```python
from soika_memory import Memory
# Initialize with default configuration
memory = Memory()
# Add a memory
result = memory.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="alice")
print(result)
# Search memories
search_results = m.search("software engineer", user_id="john_doe")
print(search_results)
# Get all memories
all_memories = m.get_all(filters={"user_id": "john_doe"})
print(all_memories)
REST API Server
Start the memory server:
cd server
python main.py
The API will be available at http://localhost:8000 with documentation at /docs.
API Examples
Create Memory:
curl -X POST "http://localhost:8000/memories" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "I love pizza"},
{"role": "assistant", "content": "Great! I will remember that."}
],
"user_id": "user123"
}'
Search Memories:
curl -X POST "http://localhost:8000/search" \
-H "Content-Type: application/json" \
-d '{
"query": "food preferences",
"user_id": "user123"
}'
Get All Memories:
curl "http://localhost:8000/memories?user_id=user123"
Configuration
Memory supports extensive configuration options:
config = {
"llm": {
"provider": "openai", # openai, azure_openai, anthropic, gemini, etc.
"config": {
"api_key": "your-api-key",
"model": "gpt-4",
"temperature": 0.1
}
},
"embedder": {
"provider": "openai",
"config": {
"api_key": "your-api-key",
"model": "text-embedding-3-large"
}
},
"vector_store": {
"provider": "qdrant", # qdrant, pinecone, chroma, pgvector, etc.
"config": {
"host": "localhost",
"port": 6333
}
},
"graph_store": {
"provider": "neo4j", # neo4j, memgraph, neptune
"config": {
"url": "bolt://localhost:7687",
"username": "neo4j",
"password": "password"
}
}
}
Advanced Features
Graph Memory
Enable graph memory to extract and store entity relationships:
# Enable graph memory
m = Memory(config=config, enable_graph=True)
# Add complex information
messages = [
{"role": "user", "content": "Alice works at Google as a software engineer and lives in Mountain View"}
]
result = m.add(messages, user_id="user123")
# Access extracted relationships
relations = result.get("relations", {})
entities = relations.get("added_entities", [])
Space-based Isolation
Organize memories by workspace or project:
# Add memories to different spaces
m.add(messages, user_id="user123", space_id="project_alpha")
m.add(messages, user_id="user123", space_id="project_beta")
# Search within specific space
results = m.search("query", user_id="user123", space_id="project_alpha")
Async Operations
Use async client for high-performance applications:
from soika_memory import AsyncMemory
async def main():
m = AsyncMemory(config=config)
# Async operations
result = await m.add(messages, user_id="user123")
search_results = await m.search("query", user_id="user123")
all_memories = await m.get_all(filters={"user_id": "user123"})
Docker Deployment
Using Docker Compose
version: '3.8'
services:
memory-server:
build: .
ports:
- "8000:8000"
environment:
- OPENAI_API_KEY=your-openai-api-key
- QDRANT_HOST=qdrant
- QDRANT_PORT=6333
depends_on:
- qdrant
qdrant:
image: qdrant/qdrant
ports:
- "6333:6333"
volumes:
- qdrant_storage:/qdrant/storage
Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Client SDK │ │ REST API │ │ Proxy Server │
│ (Sync/Async) │ │ (FastAPI) │ │ (OpenAI) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
│
┌─────────────────┐
│ Memory Core │
│ (Engine) │
└─────────────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ LLM │ │ Vector │ │ Graph │
│ Providers │ │ Stores │ │ Stores │
└─────────────┘ └─────────────┘ └─────────────┘
Testing
Run the test suite:
# Basic functionality test
cd server
python simple_test.py
# Advanced scenarios
python advanced_test.py
# API endpoint testing
python test_endpoints.py
# Space isolation demo
bash final_demo.sh
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Roadmap
- Real-time memory synchronization
- Multi-modal memory support (images)
- Advanced graph analytics
- Memory compression and archival
- Federated memory networks
Memory - Making AI agents truly intelligent with persistent, searchable, and contextual memory.
Metadata
Release files for soika-memory 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| soika_memory-1.2.2.tar.gz | 115.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| soika_memory-1.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 294.4 kB
Release files / soika_memory-1.2.2.tar.gz
| Download URL | soika_memory-1.2.2.tar.gz |
|---|---|
| Size | 115.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
837fe7485fb9ca8359d3c97d780030d2306e9f853dab720a8c72fb5d3cbb581d
|
|
BLAKE2b-256 checksum How to use checksums |
18f22816d44de23675a62b595adeceb930fe8f6592e3fe7357f04dff5fe3f036
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / soika_memory-1.2.2-py3-none-any.whl
| Download URL | soika_memory-1.2.2-py3-none-any.whl |
|---|---|
| Size | 178.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
624409ec528995e0a4918e39e3cd5f148717f6387d2383b70fa1e1052b2c362f
|
|
BLAKE2b-256 checksum How to use checksums |
e20661fde0c46b3e1bd60d0a744717ec881a16262e7f8e4dc09dc7c259ef55de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|