A production-ready distributed MLX inference system with multi-turn conversation support, optimized for Apple Silicon and 235B parameter thinking models.
- Full conversation history and context preservation
- Intelligent message cleaning for API compatibility
- Contextual reasoning that builds upon previous exchanges
- Live streaming of model thinking process (
<think>blocks) - Intelligent text wrapping and formatting
- Context-aware status indicators
- Fixed 1200px chatbot width with comprehensive blue theme
- Enhanced Gradio interface with logo header
- Responsive design with proper text wrapping
- 5-minute timeouts for complex reasoning tasks
- Up to 5,000 tokens per response
- Efficient streaming with graceful fallbacks
- OpenAI-compatible API integration
- 🔄 Real-time Streaming: Live text streaming from thinking models
- 🧠 Optimized for Reasoning: 5-minute timeouts, 5K token responses
- 🌐 Web Interface: Clean Gradio UI at http://127.0.0.1:7866
- ⚙️ Flexible Controls: Streaming toggle, model selection, response length
- 📖 Enhanced Display: Formatted thinking blocks, better readability
- 📁 Document Support: PDF, DOCX, TXT summarization
- Primary Server: 172.16.0.1:80 (MLX API endpoint)
- API Format: OpenAI-compatible
/v1/chat/completions - Authentication: Bearer token via
MLX_API_KEYenvironment variable - Model: qwen3-235b-a22b-bf16 (235B parameter thinking model)
- gradio_ui.py - Main chat interface with streaming
- gradio_rag_ui.py - Advanced RAG interface with document processing
- test_api.py - API connectivity testing tool
- Various pipeline scripts - Distributed processing utilities
# Set API key
export MLX_API_KEY="your_api_key_here"
# Ensure Python environment
source mlx-env/bin/activate # if using virtual environment# Start the main chat interface
./start_gradio_ui.sh
# Or start the RAG interface
./launch_rag_ui.sh# Test API connectivity
python test_api.py "your_api_key"- Streaming Responses: Real-time text generation
- Model Selection: Choose from available ready models
- Response Control: 100-5000 token responses
- Document Upload: PDF/DOCX/TXT summarization
- Thinking Display: Formatted
<think>blocks
- Max Tokens: 100-5000 (default: 2000)
- Timeout: 300 seconds (5 minutes)
- Streaming: Enabled by default
- Model: qwen3-235b-a22b-bf16
- API Base:
http://172.16.0.1:80/v1 - Hosts:
172.16.0.1,172.16.0.2(primary, secondary) - Default Model: qwen3-235b-a22b-bf16
gradio_ui.py- Main interface (✅ Working)start_gradio_ui.sh- Launch scripthosts.json- Distributed configurationhosts.txt- Host list for MPI
- Server-Sent Events: Proper SSE parsing
- Chunked Updates: Updates every 3 chunks for smooth display
- Fallback Support: Auto-switches to non-streaming if needed
- Progress Tracking: Real-time word count and status
- Thinking Blocks:
<think>→ 💭 Thinking: code blocks - Text Formatting: Better line breaks and spacing
- Copy Support: Easy text copying for external use
- Increased Height: 500px chat area for better readability
- qwen3-235b-a22b-bf16 ✅ (Primary - 1 ready replica)
- qwen3-0.6b-gguf (0 ready replicas)
- qwen3 (0 ready replicas)
- qwen3-235b-a22b-q8_0 (0 ready replicas)
- qwen3-235b-a22b-gguf (0 ready replicas)
- DeepSeek-R1-0528-Q4_K_M (0 ready replicas)
- Port 7866 in use: Change port in gradio_ui.py line 490
- API Auth Error: Check MLX_API_KEY environment variable
- No streaming: Toggle streaming off in interface
- Timeout: Increase timeout for complex queries
# Check API status
curl -H "Authorization: Bearer ${MLX_API_KEY}" http://172.16.0.1:80/v1/models
# Check processes
ps aux | grep gradio
# Check ports
netstat -an | grep 7866- Fixed streaming parser - Proper SSE handling
- Enhanced readability - Formatted thinking blocks
- Increased timeouts - 5 minutes for thinking models
- Extended token limits - Up to 5K tokens per response
- Better error handling - Graceful fallbacks
- UI improvements - Model selector, streaming toggle
- Multi-model conversation comparison
- Advanced RAG with vector embeddings
- Conversation export/import
- Custom prompt templates
- Response regeneration
- Conversation branching
- API keys excluded from Git (see .gitignore)
- Local-only interface (127.0.0.1)
- Models and large files excluded from version control
- gradio
- requests
- PyPDF2
- python-docx
- json (built-in)
- os (built-in)
Checkpoint Created: 2025-06-18 - Fully functional streaming interface with thinking model optimization