This guide will help you quickly set up and start playing with the AI Memory Service using the interactive Streamlit interface.
This project utelise a form of the ai-memory project.
- Python 3.10+
- MongoDB Atlas account (free tier works)
- OpenAI API key
- AWS account with Bedrock access (optional, for advanced features)
git clone https://github.com/mongodb-partners/ai-memory.git
cd ai-memorypip install -r requirements.txtCreate a .env file in the project root with the following configuration:
# MongoDB Atlas Configuration
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority&appName=YourCluster
# OpenAI Configuration (Required for Streamlit app)
OPENAI_API_KEY=sk-proj-your-openai-api-key-here
# AWS Configuration (Optional - for advanced memory features)
AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-key
AWS_REGION=us-east-1
LLM_MODEL_ID=us.anthropic.claude-3-7-sonnet-20250219-v1:0
EMBEDDING_MODEL_ID=amazon.titan-embed-text-v1
# Memory Service Configuration
SERVICE_HOST=0.0.0.0
SERVICE_PORT=8182
DEBUG=false
# Memory System Parameters (Optional - has defaults)
MAX_DEPTH=5
SIMILARITY_THRESHOLD=0.7
DECAY_FACTOR=0.99
REINFORCEMENT_FACTOR=1.1- Create a MongoDB Atlas Account: Go to mongodb.com/atlas
- Create a Cluster: Use the free M0 tier
- Enable Vector Search: In your cluster, go to "Search" → "Create Search Index"
- Create Database: Name it
ai_memory - Get Connection String: Replace
username,password, and cluster details inMONGODB_URI
- Get API Key: Go to platform.openai.com
- Create New Key: Click "Create new secret key"
- Copy Key: Add it to your
.envfile asOPENAI_API_KEY
python main.pyThe service will start on http://localhost:8182
streamlit run streamlit_app_fixed.pyThe app will open in your browser at http://localhost:8501
- Helpful Assistant: General-purpose AI
- Business Advisor: Strategic business consultant
- Learning Tutor: Educational assistant
- Code Mentor: Programming expert
- Custom: Write your own personality
Try This: Switch between templates and see how the AI's responses change!
- User Preferences:
"Get my user preferences for user_001" - Weather Lookup:
"What's the weather in New York?" - Investment Calculator:
"Calculate returns for $1000 at 5% for 10 years"
{
"tool_name": "task_manager",
"input": {
"user_id": "string",
"action": "string"
},
"output": {
"tasks": ["array of strings"],
"status": "string"
}
}Try This: Create a tool for your specific use case and watch the AI use it!
- Click "🎯 Random Username" → Gets:
amazing_developer_123 - Click "💬 Random Conversation ID" → Gets:
project_planning_20250131_abc123 - Click "🚀 Generate Sample Conversations" → Creates realistic conversation history
After generating sample data, try these queries:
"What did we discuss about AI projects?""Tell me about the code review conversation""What MongoDB advice was given?""Remind me about the tool development discussion"
- Automatic: Always retrieves memories (best for ongoing conversations)
- Query-based: Only when you ask for context (keywords: "remember", "what did we")
- Disabled: No memory retrieval (for testing current context only)
Try This: Switch modes and see how the AI's awareness changes!
- Configure your ideal system prompt
- Set up your favorite tools
- Click "💾 Save Config"
- Download the JSON file
- Click "📤 Load Config"
- Upload your saved JSON
- Everything restores automatically!
At the bottom of the app, explore:
- Memory Context: See what memories the AI has access to
- System Prompt: View the current AI instructions
- Tool Status: Check which tools are available
- Tool Execution History: See detailed tool calls with inputs/outputs
- Configuration: Review all current settings
- Generate sample conversations
- Start a new conversation thread
- Ask:
"What do you know about my preferences?" - Watch it pull relevant memories!
- Enable PydanticAI tools
- Load sample tools
- Ask:
"Check my user preferences and then get the weather for my location" - Watch multiple tools work together!
- Switch to "Business Advisor" template
- Ask:
"Should I invest in this project?" - Switch to "Learning Tutor" template
- Ask the same question
- Compare the different approaches!
- Have a conversation about your interests
- Start a new conversation thread (different ID)
- Ask:
"What do you remember about me?" - Test cross-conversation memory!
- Check MongoDB URI is correct
- Verify AWS credentials (if using Bedrock)
- Check port 8182 isn't in use
- Ensure OpenAI API key is valid
- Check memory service is running on localhost:8182
- Verify all Python dependencies are installed
- Check MongoDB Atlas connection
- Verify vector search indexes are created
- Try the health check button in the app
- Start Simple: Begin with OpenAI mode, then add PydanticAI tools
- Generate Sample Data: Use sample conversations to test memory features
- Save Configurations: Save different setups for different use cases
- Monitor Context Window: Use it to understand what the AI "sees"
- Experiment with Prompts: Custom system prompts can create specialized agents
Once you're comfortable with the basics:
- Create custom tools for your business logic
- Experiment with different memory retrieval strategies
- Build complex multi-step workflows using tool chaining
- Integrate with your own data sources
Enjoy exploring the AI Memory Service! 🚀


