Update API metadata: Change to Multilingual Translation API
- Updated API title from "Malaysian Language Translation API" to "Multilingual Translation API" - Updated API description to mention 105+ languages and M2M100 model - Updated /api/translate endpoint docstring to reflect multilingual support - Updated startup/shutdown log messages - Added commercial license note (Apache 2.0) in API description This ensures the Swagger UI (http://localhost:8001/docs) shows correct information. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -8,9 +8,9 @@ class Settings(BaseSettings):
|
|||||||
# API Configuration
|
# API Configuration
|
||||||
api_host: str = "0.0.0.0"
|
api_host: str = "0.0.0.0"
|
||||||
api_port: int = 8000
|
api_port: int = 8000
|
||||||
api_title: str = "Malaysian Language Translation API"
|
api_title: str = "Multilingual Translation API"
|
||||||
api_version: str = "1.0.0"
|
api_version: str = "1.0.0"
|
||||||
api_description: str = "API for translating between Malay and English using neural machine translation"
|
api_description: str = "API for translating between 105+ languages using Facebook M2M100 model (Apache 2.0 License - Commercial use allowed)"
|
||||||
|
|
||||||
# Model Configuration
|
# Model Configuration
|
||||||
model_cache_dir: str = "./models"
|
model_cache_dir: str = "./models"
|
||||||
|
|||||||
12
app/main.py
12
app/main.py
@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
|
|||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
"""Lifecycle event handler for startup and shutdown"""
|
"""Lifecycle event handler for startup and shutdown"""
|
||||||
# Startup
|
# Startup
|
||||||
logger.info("Starting Malaysian Translation API...")
|
logger.info("Starting Multilingual Translation API...")
|
||||||
try:
|
try:
|
||||||
# Preload translation models
|
# Preload translation models
|
||||||
logger.info("Preloading translation models...")
|
logger.info("Preloading translation models...")
|
||||||
@ -32,7 +32,7 @@ async def lifespan(app: FastAPI):
|
|||||||
yield
|
yield
|
||||||
|
|
||||||
# Shutdown
|
# Shutdown
|
||||||
logger.info("Shutting down Malaysian Translation API...")
|
logger.info("Shutting down Multilingual Translation API...")
|
||||||
|
|
||||||
|
|
||||||
# Create FastAPI app
|
# Create FastAPI app
|
||||||
@ -83,11 +83,13 @@ async def health_check():
|
|||||||
@app.post("/api/translate", response_model=TranslationResponse)
|
@app.post("/api/translate", response_model=TranslationResponse)
|
||||||
async def translate_text(request: TranslationRequest):
|
async def translate_text(request: TranslationRequest):
|
||||||
"""
|
"""
|
||||||
Translate text between Malay and English
|
Translate text between 105+ languages using M2M100 model
|
||||||
|
|
||||||
- **text**: Text to translate (1-5000 characters)
|
- **text**: Text to translate (1-5000 characters)
|
||||||
- **source_lang**: Source language code ('ms' for Malay, 'en' for English)
|
- **source_lang**: Source language code (e.g., 'en', 'ko', 'ms', 'bn', 'ja', 'zh', etc.)
|
||||||
- **target_lang**: Target language code ('ms' for Malay, 'en' for English)
|
- **target_lang**: Target language code (e.g., 'en', 'ko', 'ms', 'bn', 'ja', 'zh', etc.)
|
||||||
|
|
||||||
|
Supports any-to-any translation between 105 languages. See /api/supported-languages for full list.
|
||||||
"""
|
"""
|
||||||
# Validate language pair
|
# Validate language pair
|
||||||
if request.source_lang == request.target_lang:
|
if request.source_lang == request.target_lang:
|
||||||
|
|||||||
Reference in New Issue
Block a user