Spaces:
Sleeping
Sleeping
| from typing import Dict | |
| # Supported languages | |
| LANGUAGES: Dict[str, str] = { | |
| "Arabic": "ar", | |
| "Chinese (Simplified)": "zh", | |
| "Chinese (Traditional)": "zh-TW", | |
| "Dutch": "nl", | |
| "English": "en", | |
| "French": "fr", | |
| "German": "de", | |
| "Greek": "el", | |
| "Hindi": "hi", | |
| "Indonesian": "id", | |
| "Italian": "it", | |
| "Japanese": "ja", | |
| "Korean": "ko", | |
| "Polish": "pl", | |
| "Portuguese": "pt", | |
| "Russian": "ru", | |
| "Spanish": "es", | |
| "Swedish": "sv", | |
| "Thai": "th", | |
| "Turkish": "tr", | |
| "Vietnamese": "vi" | |
| } | |
| # API providers configuration | |
| API_PROVIDERS: Dict[str, str] = { | |
| "ChatGPT": "https://api.openai.com/v1", | |
| "DeepSeek": "https://api.deepseek.com" | |
| } | |
| # Models for each provider | |
| PROVIDER_MODELS: Dict[str, str] = { | |
| "ChatGPT": "gpt-4o", | |
| "DeepSeek": "deepseek-chat" | |
| } | |
| # Strict translation system prompt to prevent extra commentary | |
| STRICT_TRANSLATION_PROMPT = """You are a professional translator. Your task is to translate text accurately while maintaining the original formatting and structure. | |
| CRITICAL RULES: | |
| 1. Return ONLY the translated text | |
| 2. Do NOT add explanations, comments, or notes | |
| 3. Do NOT add quotation marks around the translation | |
| 4. Do NOT add phrases like "Here is the translation:" or "The translation is:" | |
| 5. Preserve original formatting, line breaks, and punctuation | |
| 6. If you cannot translate something, return it unchanged | |
| 7. Do NOT be conversational - just translate | |
| Translate from {source_lang} to {target_lang}. Return only the translated text.""" | |
| # Post-processing patterns to clean unwanted LLM additions | |
| UNWANTED_PATTERNS = [ | |
| r'^(Here is the translation|The translation is|Translation|Translated text):?\s*', | |
| r'^"([^"]*)"$', # Remove surrounding quotes | |
| r'^\s*[-•]\s*', # Remove bullet points | |
| r'\n\n(Note|Comment|Explanation):.*$', # Remove trailing notes | |
| ] | |
| # File size limits (in MB) | |
| MAX_FILE_SIZE_MB = 50 | |
| # Supported file extensions | |
| SUPPORTED_EXTENSIONS = ['.pptx', '.pdf', '.docx'] |