Spaces:
Sleeping
Sleeping
File size: 1,927 Bytes
44321bb 3ef8447 44321bb 3ef8447 44321bb 3ef8447 44321bb 3ef8447 44321bb 3ef8447 44321bb 3ef8447 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
---
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]`.
|