Examples
- Examples
- Getting Started
- Agents
- Teams
- Workflows
- Applications
- Streamlit Apps
- Evals
Agent Concepts
- Reasoning
- Multimodal
- RAG
- User Control Flows
- Knowledge
- Memory
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Context
- Embedders
- Agent State
- Observability
- Miscellaneous
Models
- Anthropic
- AWS Bedrock
- AWS Bedrock Claude
- Azure AI Foundry
- Azure OpenAI
- Cerebras
- Cerebras OpenAI
- Cohere
- DeepInfra
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- IBM
- LM Studio
- LiteLLM
- LiteLLM OpenAI
- Meta
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Perplexity
- Together
- XAI
- Vercel
Vector Databases
Couchbase Integration
Code
cookbook/agent_concepts/vector_dbs/couchbase.py
import os
import time
from agno.agent import Agent
from agno.embedder.openai import OpenAIEmbedder
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.vectordb.couchbase import CouchbaseSearch
from couchbase.options import ClusterOptions, KnownConfigProfiles
from couchbase.auth import PasswordAuthenticator
# Couchbase connection settings
username = os.getenv("COUCHBASE_USER", "Administrator")
password = os.getenv("COUCHBASE_PASSWORD", "password")
connection_string = os.getenv("COUCHBASE_CONNECTION_STRING", "couchbase://localhost")
# Create cluster options with authentication
auth = PasswordAuthenticator(username, password)
cluster_options = ClusterOptions(auth)
cluster_options.apply_profile(KnownConfigProfiles.WanDevelopment)
knowledge_base = PDFUrlKnowledgeBase(
urls=["https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
vector_db=CouchbaseSearch(
bucket_name="recipe_bucket",
scope_name="recipe_scope",
collection_name="recipes",
couchbase_connection_string=connection_string,
cluster_options=cluster_options,
search_index="vector_search_fts_index",
embedder=OpenAIEmbedder(
id="text-embedding-3-large",
dimensions=3072,
api_key=os.getenv("OPENAI_API_KEY")
),
wait_until_index_ready=60,
overwrite=True
),
)
knowledge_base.load(recreate=True)
# Wait for the vector index to sync with KV
time.sleep(20)
agent = Agent(knowledge=knowledge_base, show_tool_calls=True)
agent.print_response("How to make Thai curry?", markdown=True)
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2
Start Couchbase
docker run -d --name couchbase-server \
-p 8091-8096:8091-8096 \
-p 11210:11210 \
-e COUCHBASE_ADMINISTRATOR_USERNAME=Administrator \
-e COUCHBASE_ADMINISTRATOR_PASSWORD=password \
couchbase:latest
Then access http://localhost:8091 and create:
- Bucket:
recipe_bucket
- Scope:
recipe_scope
- Collection:
recipes
3
Install libraries
pip install -U couchbase openai agno
4
Set environment variables
export COUCHBASE_USER="Administrator"
export COUCHBASE_PASSWORD="password"
export COUCHBASE_CONNECTION_STRING="couchbase://localhost"
export OPENAI_API_KEY="your-openai-api-key"
5
Run Agent
python cookbook/agent_concepts/vector_dbs/couchbase.py
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.