Setup Development Environment
Difficulty: โญ Beginner | Time: 30-45 minutes
๐ฏ The Problemโ
You want to start building with RecoAgent but don't have the development environment configured. You need Python, dependencies, vector stores, and tools all working together - but setting this up from scratch is time-consuming and error-prone.
This guide solves: Getting from zero to a working development environment where you can run RecoAgent examples and build applications.
โก TL;DR - Quick Startโ
# 1. Create virtual environment
python -m venv venv && source venv/bin/activate
# 2. Install RecoAgent
pip install recoagent
# 3. Set environment variables
export OPENAI_API_KEY="your-key"
export LANGSMITH_API_KEY="your-key"
# 4. Start local OpenSearch (optional)
docker-compose up -d opensearch
# 5. Test installation
python -c "from packages.rag import HybridRetriever; print('โ
Ready!')"
Expected result: "โ Ready!" message means you're set up!
Full Setup Guideโ
This guide will walk you through setting up a complete development environment for RecoAgent, including Python, dependencies, vector stores, and development tools.
Prerequisitesโ
Before starting, ensure you have:
- Python 3.8+ installed
- Node.js 18+ (for documentation)
- Git for version control
- Docker (optional, for local services)
- API Keys for your chosen providers
Step 1: Python Environment Setupโ
Install Pythonโ
macOS (using Homebrew):
brew install python@3.11
Ubuntu/Debian:
sudo apt update
sudo apt install python3.11 python3.11-venv python3.11-pip
Windows: Download from python.org or use:
winget install Python.Python.3.11
Verify Installationโ
python --version
# Should show Python 3.8 or higher
pip --version
Create Virtual Environmentโ
# Create project directory
mkdir recoagent-dev
cd recoagent-dev
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Verify activation (should show venv path)
which python
Step 2: Install RecoAgentโ
Install Core Packageโ
# Install RecoAgent
pip install recoagent
# Install development dependencies
pip install recoagent[dev]
# Install additional tools
pip install black isort flake8 mypy pytest pytest-cov pre-commit
Verify Installationโ
python -c "import recoagent; print('RecoAgent installed successfully!')"
Step 3: Configure API Keysโ
Create Environment Fileโ
# Create .env file
touch .env
Add Configurationโ
# .env file contents
# LLM Configuration
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4-turbo-preview
OPENAI_TEMPERATURE=0.1
# Alternative LLM Providers
ANTHROPIC_API_KEY=your_anthropic_key_here
GOOGLE_API_KEY=your_google_key_here
# Vector Store Configuration
VECTOR_STORE_TYPE=opensearch # opensearch, azure_ai_search, vertex_ai
OPENSEARCH_URL=http://localhost:9200
OPENSEARCH_INDEX_NAME=recoagent_dev
# Azure AI Search (if using)
AZURE_SEARCH_ENDPOINT=https://your-search-service.search.windows.net
AZURE_SEARCH_KEY=your_search_key_here
AZURE_SEARCH_INDEX_NAME=recoagent-dev-index
# Vertex AI (if using)
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_CLOUD_LOCATION=us-central1
# Observability
LANGSMITH_API_KEY=your_langsmith_key_here
LANGSMITH_PROJECT=recoagent-development
LANGSMITH_TRACING=true
# Development Settings
DEBUG=true
LOG_LEVEL=INFO
Test API Keysโ
# Test OpenAI API key
python -c "
import openai
import os
from dotenv import load_dotenv
load_dotenv()
openai.api_key = os.getenv('OPENAI_API_KEY')
print('OpenAI API key valid!' if openai.api_key else 'OpenAI API key not set')
"
Step 4: Set Up Vector Storeโ
Option A: OpenSearch (Recommended for Development)โ
Using Docker Compose:
# Create docker-compose.yml
cat > docker-compose.yml << EOF
version: '3.8'
services:
opensearch:
image: opensearchproject/opensearch:2.11.0
container_name: opensearch
environment:
- discovery.type=single-node
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
- "DISABLE_INSTALL_DEMO_CONFIG=true"
- "DISABLE_SECURITY_PLUGIN=true"
ports:
- 9200:9200
- 9600:9600
volumes:
- opensearch-data:/usr/share/opensearch/data
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:2.11.0
container_name: opensearch-dashboards
ports:
- 5601:5601
environment:
- 'OPENSEARCH_HOSTS=["http://opensearch:9200"]'
depends_on:
- opensearch
volumes:
opensearch-data:
EOF
# Start OpenSearch
docker-compose up -d
# Verify OpenSearch is running
curl -X GET "localhost:9200/_cluster/health?pretty"
Manual Installation:
# Download and install OpenSearch
wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.11.0/opensearch-2.11.0-linux-x64.tar.gz
tar -xzf opensearch-2.11.0-linux-x64.tar.gz
cd opensearch-2.11.0
# Start OpenSearch
./bin/opensearch
Option B: Azure AI Searchโ
# Install Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# Login to Azure
az login
# Create resource group
az group create --name recoagent-rg --location eastus
# Create search service
az search service create \
--resource-group recoagent-rg \
--name recoagent-search \
--sku Standard \
--partition-count 1 \
--replica-count 1
Option C: Vertex AI Vector Searchโ
# Install Google Cloud CLI
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
# Authenticate
gcloud auth application-default login
# Set project
gcloud config set project your-project-id
# Enable APIs
gcloud services enable aiplatform.googleapis.com
Step 5: Development Tools Setupโ
Code Quality Toolsโ
Black (Code Formatter):
# Install Black
pip install black
# Create configuration
cat > pyproject.toml << EOF
[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
extend-exclude = '''
/(
# directories
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| build
| dist
)/
'''
EOF
# Test Black
black --check .
isort (Import Sorter):
# Install isort
pip install isort
# Create configuration
cat > .isort.cfg << EOF
[settings]
profile = black
multi_line_output = 3
line_length = 88
known_first_party = recoagent
EOF
# Test isort
isort --check-only .
Flake8 (Linter):
# Install flake8
pip install flake8
# Create configuration
cat > .flake8 << EOF
[flake8]
max-line-length = 88
extend-ignore = E203, W503
exclude =
.git,
__pycache__,
.venv,
build,
dist
EOF
# Test flake8
flake8 .
MyPy (Type Checker):
# Install mypy
pip install mypy
# Create configuration
cat > mypy.ini << EOF
[mypy]
python_version = 3.8
warn_return_any = True
warn_unused_configs = True
disallow_untyped_defs = True
ignore_missing_imports = True
EOF
# Test mypy
mypy .
Pre-commit Hooksโ
# Install pre-commit
pip install pre-commit
# Create configuration
cat > .pre-commit-config.yaml << EOF
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
additional_dependencies: [types-requests]
EOF
# Install pre-commit hooks
pre-commit install
# Test pre-commit
pre-commit run --all-files
Step 6: IDE Configurationโ
VS Code Setupโ
Install Extensions:
# Install VS Code extensions
code --install-extension ms-python.python
code --install-extension ms-python.black-formatter
code --install-extension ms-python.isort
code --install-extension ms-python.flake8
code --install-extension ms-python.mypy-type-checker
code --install-extension ms-toolsai.jupyter
code --install-extension ms-vscode.vscode-json
Create VS Code Settings:
mkdir -p .vscode
cat > .vscode/settings.json << EOF
{
"python.defaultInterpreterPath": "./venv/bin/python",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "black",
"python.sortImports.args": ["--profile", "black"],
"python.terminal.activateEnvironment": true,
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/venv": true,
"**/.venv": true
},
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestArgs": [
"tests"
]
}
EOF
PyCharm Setupโ
- Open Project: File โ Open โ Select your project directory
- Configure Interpreter: File โ Settings โ Project โ Python Interpreter
- Add Virtual Environment: Click gear โ Add โ Existing Environment โ Select
venv/bin/python
- Configure Code Style: File โ Settings โ Editor โ Code Style โ Python
- Set Black as Formatter: File โ Settings โ Tools โ External Tools โ Add Black