Skip to content

AI4Bharat/Chat-Arena-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Indic LLM Arena

A production-ready platform for interacting with and comparing leading LLMs from India. Built with Django REST Framework and React.

Indic LLM Arena Python React License

🌟 Features

Core Functionality

  • πŸ€– Multi-Model Chat - Interact with various AI models from leading providers
  • πŸ”„ Comparison Mode - Compare responses from two models side-by-side
  • 🎲 Random Mode - Blind test models without knowing which is which
  • πŸ“Š Real-time Streaming - Stream AI responses as they're generated
  • 🌳 Message Branching - Create conversation branches and explore different paths
  • πŸ“€ Share & Export - Share conversations via links or export as JSON/Markdown/TXT

Advanced Features

  • ⭐ Comprehensive Feedback - Rate responses and provide detailed feedback
  • πŸ† ELO Leaderboard - Track model performance with ELO ratings
  • πŸ” Dual Authentication - Google OAuth & Anonymous sessions
  • πŸ’Ύ Session Persistence - Continue conversations across sessions
  • πŸ“± Responsive Design - Works seamlessly on desktop and mobile

πŸ—οΈ Architecture

Backend (Django)

backend/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ user/          # User authentication and profiles
β”‚   β”œβ”€β”€ ai_model/      # AI model registry and integration
β”‚   β”œβ”€β”€ chat_session/  # Session management
β”‚   β”œβ”€β”€ message/       # Message handling and streaming
β”‚   β”œβ”€β”€ feedback/      # User feedback system
β”‚   └── model_metrics/ # Performance tracking and leaderboards
β”œβ”€β”€ core/              # Core settings and configurations
└── requirements.txt   # Python dependencies

Frontend (React)

frontend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/          # App configuration and routing
β”‚   β”œβ”€β”€ features/     # Feature-based modules
β”‚   β”‚   β”œβ”€β”€ auth/     # Authentication components
β”‚   β”‚   β”œβ”€β”€ chat/     # Chat interface and logic
β”‚   β”‚   β”œβ”€β”€ models/   # Model selection and testing
β”‚   β”‚   β”œβ”€β”€ feedback/ # Feedback components
β”‚   β”‚   └── leaderboard/ # Leaderboard views
β”‚   β”œβ”€β”€ shared/       # Shared utilities and components
β”‚   └── styles/       # Global styles
└── package.json      # Node dependencies

πŸš€ Getting Started

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • PostgreSQL 14+
  • Redis 6+
  • Google Cloud account (for OAuth)

Backend Setup

  1. Clone the repository
git clone https://github.com/AI4Bharat/Chat-Arena.git
cd Chat-Arena/backend
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables
cp .env.example .env

Edit .env with your credentials:

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/ai_playground

# Redis
REDIS_URL=redis://localhost:6379

# AI Model API Keys
OPENAI_API_KEY=your-openai-key
GOOGLE_API_KEY=your-google-key
ANTHROPIC_API_KEY=your-anthropic-key
META_API_KEY=your-meta-key
MISTRAL_API_KEY=your-mistral-key

# Firebase/Auth
FIREBASE_CONFIG={"apiKey":"...","authDomain":"..."}

# Security
SECRET_KEY=your-secret-key
ALLOWED_HOSTS=localhost,127.0.0.1
  1. Run migrations
python manage.py migrate
python manage.py createsuperuser
  1. Start backend services
# Terminal 1: Django server
python manage.py runserver

# Terminal 2: Celery worker
celery -A core worker -l info

# Terminal 3: Celery beat (for scheduled tasks)
celery -A core beat -l info

Frontend Setup

  1. Navigate to frontend directory
cd ../frontend
  1. Install dependencies
npm install
  1. Set up environment variables
cp .env.example .env

Edit .env:

REACT_APP_API_URL=http://localhost:8000/api
REACT_APP_WS_URL=ws://localhost:8000/ws
REACT_APP_GOOGLE_CLIENT_ID=your-google-client-id
  1. Start development server
npm run dev

The application will be available at http://localhost:5173

Google OAuth Setup

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable Google Identity Toolkit API
  4. Create OAuth 2.0 credentials
  5. Add authorized origins:
    • http://localhost:5173 (development)
    • https://your-domain.com (production)

πŸ“± Usage

Chat Modes

  1. Direct Mode - Chat with a single AI model
  2. Compare Mode - Get responses from two models simultaneously
  3. Random Mode - Blind test with randomly selected models

Providing Feedback

  • Star Ratings - Rate individual responses (1-5 stars)
  • Preferences - Choose which model gave a better response
  • Categories - Tag feedback with categories (accuracy, creativity, etc.)

Viewing Leaderboards

  • Filter by category (Overall, Creative Writing, Coding, Reasoning)
  • View different time periods (Daily, Weekly, All-time)
  • See detailed model performance metrics

πŸ”§ Configuration

Adding New AI Models

  1. Create a model adapter in backend/apps/ai_model/adapters/
  2. Register the model in Django admin
  3. Add API credentials to environment variables

Customizing Categories

Edit backend/apps/feedback/constants.py to add/modify feedback categories.

🚒 Deployment

Backend Deployment (Example with Railway/Render)

  1. Set up PostgreSQL and Redis instances
  2. Configure environment variables
  3. Deploy using provided Dockerfile or railway.toml

Frontend Deployment (Example with Vercel)

npm run build
vercel --prod

πŸ“Š API Documentation

The API documentation is available at:

  • Swagger UI: http://localhost:8000/api/docs/
  • ReDoc: http://localhost:8000/api/redoc/

πŸ§ͺ Testing

Backend Tests

python manage.py test

Frontend Tests

npm run test

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with assistance from Claude (Anthropic) - AI pair programming and architecture design
  • Thanks to all the AI model providers for their APIs
  • The open-source community for the amazing tools and libraries

πŸ‘¨β€πŸ’» Credits

This project was developed with significant assistance from Claude 3 Opus, an AI assistant by Anthropic. Claude helped with:

  • System architecture design
  • Code implementation
  • Best practices and patterns
  • Documentation
  • Problem-solving and debugging

Special thanks to the Anthropic team for creating such a capable AI assistant that made building this complex project possible!

πŸ“ž Support

For support, please open an issue in the GitHub repository or contact the maintainers.


Built with ❀️ and AI assistance

About

Chat arena for Indian language models.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages