Spaces:
Sleeping
Sleeping
ffreemt
commited on
Commit
·
ff18592
1
Parent(s):
670ac68
Update markdown in description in m3_server.py
Browse files- Dockerfile +3 -2
- m3_server.py +18 -1
- start-m3-server.sh +1 -1
Dockerfile
CHANGED
|
@@ -19,8 +19,9 @@ RUN pip install --no-cache-dir --upgrade pip && \
|
|
| 19 |
|
| 20 |
# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 21 |
# CMD ["TRANSFORMERS_CACHE=./", "infinity_emb", "--model-name-or-path", "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2", "--port", "7860"]
|
| 22 |
-
# CMD ["python", "app.py"]
|
| 23 |
|
| 24 |
-
CMD ["sh", "start-m3-server.sh"]
|
| 25 |
# CMD ["sh", "-c", "HF_HOME=/tmp/cache", "python", "m3_server.py"]
|
| 26 |
# ["sh", "-c", "'FOO=BAR python app.py'"]
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 21 |
# CMD ["TRANSFORMERS_CACHE=./", "infinity_emb", "--model-name-or-path", "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2", "--port", "7860"]
|
|
|
|
| 22 |
|
|
|
|
| 23 |
# CMD ["sh", "-c", "HF_HOME=/tmp/cache", "python", "m3_server.py"]
|
| 24 |
# ["sh", "-c", "'FOO=BAR python app.py'"]
|
| 25 |
+
|
| 26 |
+
# CMD ["sh", "start-m3-server.sh"] # OK
|
| 27 |
+
CMD ["python", "app.py"]
|
m3_server.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
import time
|
| 4 |
from concurrent.futures import ThreadPoolExecutor
|
| 5 |
from pathlib import Path
|
|
|
|
| 6 |
from typing import List, Tuple, Union
|
| 7 |
from uuid import uuid4
|
| 8 |
|
|
@@ -168,9 +169,25 @@ class RequestProcessor:
|
|
| 168 |
raise HTTPException(status_code=500, detail=f"Internal Server Error {e}")
|
| 169 |
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
app = FastAPI(
|
| 172 |
title="baai m3, serving embed and rerank",
|
| 173 |
-
description="Swagger UI at https://mikeee-baai-m3.hf.space/docs",
|
|
|
|
| 174 |
version="0.1.0a0",
|
| 175 |
)
|
| 176 |
|
|
|
|
| 3 |
import time
|
| 4 |
from concurrent.futures import ThreadPoolExecutor
|
| 5 |
from pathlib import Path
|
| 6 |
+
from textwrap import dedent
|
| 7 |
from typing import List, Tuple, Union
|
| 8 |
from uuid import uuid4
|
| 9 |
|
|
|
|
| 169 |
raise HTTPException(status_code=500, detail=f"Internal Server Error {e}")
|
| 170 |
|
| 171 |
|
| 172 |
+
description = dedent(
|
| 173 |
+
"""\
|
| 174 |
+
```bash
|
| 175 |
+
curl -X 'POST' \
|
| 176 |
+
'https://mikeee-baai-m3.hf.space/embeddings/' \
|
| 177 |
+
-H 'accept: application/json' \
|
| 178 |
+
-H 'Content-Type: application/json' \
|
| 179 |
+
-d '{
|
| 180 |
+
"sentences": [
|
| 181 |
+
"string", "string1"
|
| 182 |
+
]
|
| 183 |
+
}'
|
| 184 |
+
```"""
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
app = FastAPI(
|
| 188 |
title="baai m3, serving embed and rerank",
|
| 189 |
+
# description="Swagger UI at https://mikeee-baai-m3.hf.space/docs",
|
| 190 |
+
description=description,
|
| 191 |
version="0.1.0a0",
|
| 192 |
)
|
| 193 |
|
start-m3-server.sh
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
export HF_HOME=/tmp/cache
|
| 2 |
-
export TRANSFORMERS_CACHE=/tmp/cache
|
| 3 |
python m3_server.py
|
|
|
|
| 1 |
export HF_HOME=/tmp/cache
|
| 2 |
+
# export TRANSFORMERS_CACHE=/tmp/cache
|
| 3 |
python m3_server.py
|