stream_closed_captioner_phoenix
stream_closed_captioner_phoenix copied to clipboard
Allow users to bring their own Azure translation service key
This PR implements a feature that allows users to provide their own Azure Cognitive Services translation key, enabling them to use translations without consuming platform credits.
Changes Made
Database Schema
- Added
azure_service_keyfield touserstable - Added
translation_enabledfield tostream_settingstable
User Interface
- User Settings Page: Added form section for entering Azure service key with validation (10-256 characters)
- Dashboard: Added toggle control to enable/disable translations (only visible when user has provided their own key)
- Caption Settings: Added checkbox for translation_enabled setting
Backend Logic
-
Translation Pipeline: Modified to check for user's Azure key first
- If user has key and translation enabled → use user's key, bypass credits system
- If no user key → fall back to existing bits-based translation system
- Azure Service: Updated to accept optional user-provided key parameter
- Validation: Proper validation for Azure keys with ability to clear/empty the field
API Changes
- New route:
POST /toggle-translationfor dashboard toggle functionality - Updated
Azure.Cognitive.translate/4to accept user key parameter - Enhanced user settings controller to handle Azure key updates
Key Features
- Credit-Free Translations: Users with their own Azure key can translate without using platform credits
- Dashboard Control: Simple toggle to enable/disable translations when user has provided key
- Backward Compatibility: Existing bits-based system remains unchanged for users without Azure keys
- Validation: Ensures Azure keys are properly formatted (10-256 characters) or empty to clear
Testing
- Comprehensive test suite covering all new functionality
- Tests for Azure key validation, translation pipeline logic, and dashboard controls
- Existing functionality remains unaffected
Example Usage
- User goes to Settings → enters their Azure Cognitive Services key
- Dashboard now shows "Enable Translations" button instead of credit requirements
- User clicks to enable translations
- All translation requests now use their personal Azure key instead of platform credits
Fixes #219.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.