Spaces:
Sleeping
Sleeping
File size: 2,946 Bytes
2eef9ea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | # Setup Guide
## Prerequisites
- Python 3.10+
- Node.js 16+ (for frontend)
- Redis (optional, for production)
- PostgreSQL (optional, for production)
## Local Development Setup
### Using Scripts (Recommended)
**Windows:**
```bash
cd backend
scripts\setup.bat
scripts\run.bat
```
**Linux/macOS:**
```bash
cd backend
chmod +x scripts/setup.sh scripts/run.sh
./scripts/setup.sh
./scripts/run.sh
```
### Manual Setup
#### Backend
1. **Create virtual environment:**
```bash
python -m venv venv
# Windows
venv\Scripts\activate.bat
# Linux/macOS
source venv/bin/activate
```
2. **Install dependencies:**
```bash
pip install -r requirements.txt
pip install -r requirements-dev.txt
```
3. **Setup environment:**
```bash
cp .env.example .env
# Edit .env with your OpenAI API key and settings
```
4. **Run backend:**
```bash
uvicorn backend.api.main:app --reload
```
Backend will be available at: `http://localhost:8000`
API Documentation: `http://localhost:8000/docs`
#### Frontend
1. **Install dependencies:**
```bash
cd frontend
npm install
```
2. **Start development server:**
```bash
npm run dev
```
Frontend will be available at: `http://localhost:3000`
## Using Docker
### Docker Compose (All Services)
```bash
docker-compose up --build
```
This starts:
- Backend: `http://localhost:8000`
- Redis: `localhost:6379`
- PostgreSQL: `localhost:5432`
### Single Container
```bash
docker build -t multi-agent .
docker run -p 8000:8000 -e OPENAI_API_KEY=your_key multi-agent
```
## Configuration
### Environment Variables
See `.env.example` for all available options:
- `OPENAI_API_KEY` - Required: Your OpenAI API key
- `DATABASE_URL` - Database connection string
- `REDIS_HOST/PORT` - Redis configuration
- `LOG_LEVEL` - Logging level (INFO, DEBUG, etc.)
### Database
#### SQLite (Development Default)
Automatically created as `multi_agent.db`
#### PostgreSQL (Production)
```bash
# Update DATABASE_URL in .env
DATABASE_URL=postgresql://user:password@localhost:5432/multi_agent
```
## Running Tests
```bash
# All tests
pytest
# With coverage
pytest --cov=backend tests/
# Specific test file
pytest tests/test_agents.py -v
```
## Troubleshooting
### Port Already in Use
```bash
# Find process using port 8000
lsof -i :8000
# Kill process (Linux/macOS)
kill -9 <PID>
# Or change port
uvicorn backend.api.main:app --port 8001
```
### OpenAI API Key Not Working
- Ensure key is set in `.env` file
- Check key is valid at https://platform.openai.com/account/api-keys
- Verify key has available credits
### Redis Connection Issues
- Ensure Redis is running: `redis-cli ping`
- Check REDIS_HOST and REDIS_PORT in `.env`
- For Docker: use service name `redis` instead of `localhost`
## Next Steps
- Check [API Documentation](./API.md)
- Review [Deployment Guide](./DEPLOYMENT.md)
- See [Architecture Overview](./ARCHITECTURE.md)
|