Contributing to ChatbotAI-Free
Thank you for your interest in contributing to ChatbotAI-Free! This guide will help you get started with development, understand the codebase structure, and submit your contributions.Getting Started
Fork and Clone
Fork the repository
Go to ChatbotAI-Free on GitHub and click the Fork button to create your own copy.
Create a feature branch
feature/add-voice-cloningfor new featuresfix/mic-device-selectionfor bug fixesdocs/update-installationfor documentationrefactor/tts-managerfor code improvements
Development Setup
Make sure you have Ollama installed and at least one model pulled before running the app:
- Visit kokoro-onnx releases
- Download
kokoro-v1.0.onnxandvoices-v1.0.bin - Place in
voices/kokoro-v1.0/
Code Structure Overview
Understanding the codebase architecture will help you navigate and make effective contributions.File Organization
Key Modules
main.py
UI Layer (1300+ lines)
ChatbotWindow: Main window classManualRecorderThread: Recording threadWorkerThread: Classic chat pipelineLiveWorkerThread: Live mode with barge-inMarkdownRenderer: HTML conversionThinkingWidget: Collapsible reasoning panelContextDonut: Token usage indicator
ai_manager.py
AI Coordination (543 lines)
- Model initialization (Whisper, Ollama, TTS)
transcribe(): STT with VAD filteringget_llm_response_streaming(): Streaming LLM with thinking supporttext_to_speech(): TTS generation- Conversation history management
- Token tracking and context size queries
tts_manager.py
TTS Router (151 lines)
- Kokoro/Sherpa voice detection (
_is_sherpa_voice()) - Engine lazy loading and caching
create(): Unified synthesis interface- Language code mapping
- Speed adjustment support
audio_utils.py
Audio I/O (298 lines)
AudioRecorder: VAD-based recording- Sample rate detection and resampling
AudioPlayer: PipeWire playback via paplay- Queue-based buffering
- Pause/resume for feedback prevention
Adding New Features
Example: Adding a New TTS Engine
Let’s walk through adding support for a new TTS engine called “NeoTTS”.Example: Adding a New UI Feature
Let’s add a “Copy to Clipboard” button for bot messages.Code Style Guidelines
Python Conventions
- PEP 8 compliance: Use 4 spaces for indentation, max line length 100 characters
- Type hints: Add type hints for function parameters and return values where helpful
- Docstrings: Use triple-quoted docstrings for classes and non-obvious functions
PyQt6 Best Practices
- Use signals/slots for thread communication: Never update UI directly from worker threads
- Clean up threads: Always call
thread.wait()or use daemon threads - Avoid blocking the UI: Move long operations to
QThreadsubclasses
Naming Conventions
- Classes:
PascalCase(e.g.,AIManager,AudioRecorder) - Functions/methods:
snake_case(e.g.,transcribe(),get_llm_response()) - Constants:
UPPER_SNAKE_CASE(e.g.,LANG_CODES,THINK_OPEN) - Private methods: Prefix with
_(e.g.,_process_stream(),_emit_thinking())
Testing Your Changes
Manual Testing Checklist
Before submitting a PR, test these scenarios:Core Functionality
Core Functionality
- App starts without errors
- Classic Chat mode: Record → Transcribe → LLM → TTS works
- Live Mode: Continuous conversation works
- Barge-in interruption works in Live Mode
- Voice selection changes TTS output
- Language switching works (English ↔ Spanish)
UI & Settings
UI & Settings
- Settings dialog saves and loads preferences
- Font size changes apply to existing messages
- Voice speed adjustment works
- Audio device selection works
- Chat history sidebar shows saved chats
- Rename/delete chat operations work
- Context donut shows correct token usage
Edge Cases
Edge Cases
- Empty/silent recordings are handled gracefully
- Very long messages don’t crash the app
- Switching models mid-conversation works
- PDF attachment with large documents shows warning
- Markdown rendering handles code blocks and tables
Automated Testing (Future)
Currently, the project doesn’t have automated tests. Contributions to add unit tests (pytest) or integration tests are highly welcome!
Submitting Your Contribution
Commit your changes
Write clear, descriptive commit messages:Good commit message format:
- First line: Brief summary (50 chars max)
- Blank line
- Detailed explanation of what and why
- List of specific changes
Open a Pull Request
- Go to your fork on GitHub
- Click “Compare & pull request”
- Fill out the PR template:
Development Tips
Debugging PyQt6 Applications
Enable verbose output:Working with Audio
Test audio pipeline in isolation:Profiling Performance
Time critical operations:Contribution Ideas
Looking for ways to contribute? Here are some areas that need work:High Priority
- Add automated tests (pytest)
- Implement voice cloning support
- Add RAG (Retrieval-Augmented Generation) for long documents
- Create a packaging script (PyInstaller, AppImage)
- Add support for more TTS engines (Coqui, Tortoise)
Medium Priority
- Improve markdown rendering (syntax highlighting for code)
- Add conversation export (PDF, HTML)
- Implement conversation search
- Add hotkey support for recording
- Create a system tray icon
Documentation
- Add video tutorials
- Create architecture diagrams
- Write API documentation for modules
- Translate README to other languages
Community Guidelines
- Be respectful: Treat all contributors with kindness and professionalism
- Stay on topic: Keep discussions focused on the project
- Ask questions: If you’re unsure about something, ask in the issue comments
- Share knowledge: Help other contributors by answering questions
License
By contributing to ChatbotAI-Free, you agree that your contributions will be licensed under The Unlicense. This means your code becomes public domain and can be used by anyone for any purpose.Read the full license at UNLICENSE.org
Getting Help
If you need help with development:- Check existing issues: Someone may have already solved your problem
- Search the codebase: Use
grepor IDE search to find similar implementations - Ask in discussions: Open a GitHub Discussion for general questions
- Open an issue: For bugs or specific technical questions