AI Memory
Use Couchbase as a vector memory provider for BoxLang AI applications. Store conversation history with semantic search capabilities for intelligent context retrieval in chatbots, agents, and RAG syste
Overview
Installation
3
Configure Couchbase Cache
component {
this.name = "MyAIApp";
// Configure Couchbase cache
this.caches["ai_memory"] = {
"provider": "Couchbase",
"properties": {
"connectionString": "couchbase://localhost",
"username": "Administrator",
"password": "password",
"bucket": "ai_conversations",
"scope": "_default",
"collection": "_default"
}
};
}
Basic Usage
Creating Vector Memory
// Create Couchbase vector memory for an AI agent
memory = aiMemory( "cache", {
cacheName: "ai_memory",
collection: "ai_conversations._default._default",
embeddingProvider: "openai",
embeddingModel: "text-embedding-3-small"
});
// Use with an AI agent
agent = aiAgent(
name: "Support Bot",
memory: memory,
model: aiModel( "openai" )
);
// Agent automatically stores and retrieves from Couchbase
response = agent.run( "What were we talking about yesterday?" );Multi-Tenant Isolation
Configuration
Memory Configuration Options
Multi-Tenant Configuration
Working with Memory
Adding Messages
Retrieving Relevant Context
Getting All Messages
Integration with AI Agents
Simple Agent with Couchbase Memory
Multi-Conversation Support
Hybrid Memory (Recent + Semantic)
Storage Structure
How Messages are Stored
Multi-Tenant Filtering
Best Practices
1. Use Unique Keys per Conversation
2. Set Appropriate Limits
3. Use Hybrid Memory for Best Results
4. Clear Old Conversations Periodically
Performance Considerations
Connection Pooling
Vector Index
Batch Operations
Couchbase Server Requirements
Minimum Version
Bucket Configuration
Vector Index Setup
Troubleshooting
Memory Not Persisting
Embedding Errors
Vector Search Not Finding Results
Complete Examples
RAG Chatbot with Couchbase Memory
Multi-Tenant Customer Support
See Also
Last updated
Was this helpful?
