Implement real OpenAI integration for the AI task suggestions feature: - Create aiService.js with GPT-3.5/GPT-4 integration - Add context-aware prompt engineering (street data, past tasks, weather, priorities) - Implement automatic fallback to high-quality mock suggestions - Add graceful degradation when API key not configured - Create comprehensive error handling and timeout protection - Add input validation with aiValidator middleware - Implement /api/ai/status endpoint for service monitoring - Add 12 passing test cases covering all functionality - Document OpenAI model configuration in .env.example - Create detailed AI_SERVICE.md documentation Key features: - Uses axios to call OpenAI API directly (no SDK dependency) - Analyzes street conditions and past 30 days of completed tasks - Generates structured JSON responses with task metadata - 10-second timeout with automatic fallback - Comprehensive logging using centralized logger service - Returns warnings when running in mock mode All tests pass (12/12). Ready for production use with or without API key. 🤖 Generated with AI Assistant Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
35 lines
1007 B
Plaintext
35 lines
1007 B
Plaintext
# CouchDB Configuration (Primary database)
|
|
COUCHDB_URL=http://localhost:5984
|
|
COUCHDB_DB_NAME=adopt-a-street
|
|
COUCHDB_USER=admin
|
|
COUCHDB_PASSWORD=admin
|
|
|
|
# Optional: CouchDB Connection Pool Settings
|
|
COUCHDB_MAX_CONNECTIONS=10
|
|
COUCHDB_REQUEST_TIMEOUT=30000
|
|
|
|
# JWT Authentication
|
|
JWT_SECRET=your_jwt_secret_key_here_change_in_production
|
|
|
|
# Server Configuration
|
|
PORT=5000
|
|
NODE_ENV=development
|
|
|
|
# Frontend URL (for CORS)
|
|
FRONTEND_URL=http://localhost:3000
|
|
|
|
# Cloudinary Configuration (for image uploads)
|
|
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
|
|
CLOUDINARY_API_KEY=your_cloudinary_api_key
|
|
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
|
|
|
|
# Stripe Configuration (for premium subscriptions)
|
|
STRIPE_SECRET_KEY=your_stripe_secret_key
|
|
STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
|
|
|
|
# OpenAI Configuration (optional - for AI features)
|
|
# If not set, AI features will return mock data
|
|
OPENAI_API_KEY=your_openai_api_key
|
|
OPENAI_MODEL=gpt-3.5-turbo
|
|
# Available models: gpt-3.5-turbo, gpt-4, gpt-4-turbo-preview
|