Spaces:
Running
Running
| title: Selam Translate API | |
| emoji: ☯️ | |
| colorFrom: gray | |
| colorTo: gray | |
| sdk: docker | |
| app_port: 23333 | |
| ## Selam Translate API | |
| Multilingual Translation and Language Detection API. | |
| ## Features | |
| ✅ Implemented: | |
| - Language detection (`/detect`) | |
| - Translation via Google Translate (`/translate`) using `deep_translator` | |
| - Docker deployment | |
| 🔤 Supported languages (primary): | |
| `auto`, `en` (English), `am` (Amharic), `ar` (Arabic), `ti` (Tigrinya), `om` (Oromo), `so` (Somali), `ko` (Korean), `zh-CN` (Chinese Simplified), `zh-TW` (Chinese Traditional), `fr` (French), `it` (Italian), `ja` (Japanese), `de` (German) | |
| ## Run API service | |
| ### Run in Command Line | |
| **Install dependencies:** | |
| ```bash | |
| # pipreqs . --force --mode no-pin | |
| pip install -r requirements.txt | |
| ``` | |
| **Run API:** | |
| ```bash | |
| python -m apis.chat_api | |
| ``` | |
| ## Run via Docker | |
| **Docker build:** | |
| ```bash | |
| sudo docker build -t hf-llm-api:1.0 . --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy | |
| ``` | |
| **Docker run:** | |
| ```bash | |
| # no proxy | |
| sudo docker run -p 23333:23333 hf-llm-api:1.0 | |
| # with proxy | |
| sudo docker run -p 23333:23333 --env http_proxy="http://<server>:<port>" hf-llm-api:1.0 | |
| ``` | |
| ## API Usage | |
| ### API Usage | |
| - Detect language | |
| ```bash | |
| curl -X POST http://127.0.0.1:23333/detect \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"input_text": "Hello, how are you?"}' | |
| ``` | |
| - Translate | |
| ```bash | |
| curl -X POST http://127.0.0.1:23333/translate \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"to_language": "ar", "input_text": "Hello"}' | |
| ``` | |
| - Stream translate (OpenAI-compatible SSE) | |
| ```bash | |
| curl -N -X POST http://127.0.0.1:23333/translate/stream \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"to_language": "am", "input_text": "Hello, nice to meet you!"}' | |
| ``` | |
| Response is a stream of `data: {json}\n\n` chunks ending with `data: [DONE]`. | |