AI-powered debate system with multiple models, cost tracking, and web interface.
- Multi-Model Debates: Conduct debates between different AI models (GPT-4, GPT-5, etc.)
- Intelligent Judging: Automated judgment system to evaluate debate quality
- Cost Tracking: Real-time cost estimation and tracking for API usage
- Configurable Rounds: Adjustable debate rounds (1-3) for different complexity levels
- Token Management: Configurable token limits (100-4000) for response control
- Modern Web Interface: Built with Gradio for an intuitive user experience
- Environment Configuration: Secure API key management via .env files
- Python 3.11+: Core programming language
- OpenAI API: Integration with various GPT models
- Gradio: Modern web interface framework
- Python-dotenv: Environment variable management
- Logging: Comprehensive application logging
- Python 3.11 or higher
- OpenAI API key
- Virtual environment (recommended)
-
Clone the repository
git clone <repository-url> cd ai-debate
-
Create and activate virtual environment
python -m venv venv # On Windows .\venv\Scripts\Activate.ps1 # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables Create a
.envfile in the project root:OPENAI_API_KEY=your_openai_api_key_here
-
Start the application
python main.py
-
Access the web interface Open your browser and navigate to
http://localhost:7860 -
Configure debate settings
- Enter your debate question
- Select AI models for debaters and judge
- Adjust token limits and debate rounds
- Set cost limits if desired
-
Launch the debate Click "Start Debate" to begin the AI-powered discussion
- GPT-5 Models:
gpt-5-mini,gpt-5-nano - GPT-4 Models:
gpt-4o-mini,gpt-4o,gpt-4-turbo,gpt-4 - GPT-3.5 Models:
gpt-3.5-turbo,gpt-3.5-turbo-16k
The system tracks costs based on OpenAI's pricing:
- Input tokens: $0.0015 - $0.30 per 1M tokens
- Output tokens: $0.002 - $2.00 per 1M tokens
- Rounds: 1-3 debate rounds
- Token Limits: 100-4000 tokens per response
- Cost Limits: Optional budget constraints
ai-debate/
├── main.py # Main application logic and orchestration
├── ui.py # Gradio UI components and interface
├── config.py # Configuration constants and settings
├── styles.css # Custom CSS styling
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── .env # Environment variables (create this)
└── venv/ # Virtual environment
enhanced_debate_function: Main debate orchestration with loggingvalidate_inputs: Universal input validationestimate_cost_for_question: Cost estimation before debateCostTracker: Class-based cost managementLogManager: Centralized logging with performance tracking
DebateUI: Main UI class with Gradio componentscreate_interface: Web interface setup and event handlerssetup_event_handlers: UI interaction management
- Model configurations: Available AI models and pricing
- UI settings: Interface configuration and defaults
- Validation limits: Input constraints and presets
The system includes comprehensive error handling for:
- Invalid API keys
- Network connectivity issues
- Input validation errors
- Cost limit exceeded scenarios
- Model availability issues
Enhanced logging system with centralized management:
- Decorator-based logging: Automatic function entry/exit tracking
- Performance metrics: Execution time monitoring for all operations
- Cost tracking: Real-time API usage and cost calculation
- Error handling: Centralized error logging with context
- Operation stack: Nested operation tracking for complex workflows
- API keys are stored in environment variables
- Input sanitization prevents injection attacks
- Rate limiting considerations for API usage
- Secure token handling
To test the system:
- Ensure all dependencies are installed
- Verify your OpenAI API key is valid
- Start with simple questions to test functionality
- Monitor the logs for any issues
The application can be deployed using:
- Local Development: Direct Python execution
- Docker: Containerized deployment (Dockerfile not included)
- Cloud Platforms: Deploy to Heroku, AWS, or similar platforms
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the logs for error messages
- Verify your API key and configuration
- Ensure all dependencies are properly installed
- Check OpenAI API status and quotas
- Multi-language Support: Support for debates in different languages
- Advanced Analytics: Detailed debate analysis and insights
- Custom Model Integration: Support for other AI providers
- Debate Templates: Pre-configured debate scenarios
- Export Functionality: Save debates in various formats
- Real-time Collaboration: Multi-user debate participation
Note: This system requires an active OpenAI API key and internet connectivity to function properly.