stream_closed_captioner_phoenix icon indicating copy to clipboard operation
stream_closed_captioner_phoenix copied to clipboard

Allow users to bring their own Azure translation service key

Open Copilot opened this issue 9 months ago • 0 comments

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_key field to users table
  • Added translation_enabled field to stream_settings table

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-translation for dashboard toggle functionality
  • Updated Azure.Cognitive.translate/4 to accept user key parameter
  • Enhanced user settings controller to handle Azure key updates

Key Features

  1. Credit-Free Translations: Users with their own Azure key can translate without using platform credits
  2. Dashboard Control: Simple toggle to enable/disable translations when user has provided key
  3. Backward Compatibility: Existing bits-based system remains unchanged for users without Azure keys
  4. 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

  1. User goes to Settings → enters their Azure Cognitive Services key
  2. Dashboard now shows "Enable Translations" button instead of credit requirements
  3. User clicks to enable translations
  4. 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.

Copilot avatar May 29 '25 04:05 Copilot