ffreemt
commited on
Commit
•
96b6f2f
1
Parent(s):
042f422
Update API endpoint embeddings to embed
Browse files- m3_server.py +12 -6
m3_server.py
CHANGED
@@ -2,7 +2,6 @@ import asyncio
|
|
2 |
import os
|
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
|
@@ -179,10 +178,11 @@ class RequestProcessor:
|
|
179 |
|
180 |
|
181 |
description = dedent(
|
182 |
-
"""
|
|
|
183 |
```bash
|
184 |
curl -X 'POST' \
|
185 |
-
'https://mikeee-baai-m3.hf.space/
|
186 |
-H 'accept: application/json' \
|
187 |
-H 'Content-Type: application/json' \
|
188 |
-d '{
|
@@ -190,11 +190,16 @@ description = dedent(
|
|
190 |
"string", "string1"
|
191 |
]
|
192 |
}'
|
193 |
-
```
|
|
|
|
|
|
|
|
|
|
|
194 |
)
|
195 |
|
196 |
app = FastAPI(
|
197 |
-
title="
|
198 |
# description="Swagger UI at https://mikeee-baai-m3.hf.space/docs",
|
199 |
description=description,
|
200 |
version="0.1.0a0",
|
@@ -230,7 +235,7 @@ async def landing():
|
|
230 |
return "Swagger UI at https://mikeee-baai-m3.hf.space/docs"
|
231 |
|
232 |
|
233 |
-
@app.post("/
|
234 |
async def get_embeddings(request: EmbedRequest):
|
235 |
embeddings = await processor.process_request(request, "embed")
|
236 |
return EmbedResponse(embeddings=embeddings)
|
@@ -244,5 +249,6 @@ async def rerank(request: RerankRequest):
|
|
244 |
|
245 |
if __name__ == "__main__":
|
246 |
import uvicorn
|
|
|
247 |
print("started")
|
248 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
|
|
2 |
import os
|
3 |
import time
|
4 |
from concurrent.futures import ThreadPoolExecutor
|
|
|
5 |
from textwrap import dedent
|
6 |
from typing import List, Tuple, Union
|
7 |
from uuid import uuid4
|
|
|
178 |
|
179 |
|
180 |
description = dedent(
|
181 |
+
r"""
|
182 |
+
embed example:
|
183 |
```bash
|
184 |
curl -X 'POST' \
|
185 |
+
'https://mikeee-baai-m3.hf.space/embed/' \
|
186 |
-H 'accept: application/json' \
|
187 |
-H 'Content-Type: application/json' \
|
188 |
-d '{
|
|
|
190 |
"string", "string1"
|
191 |
]
|
192 |
}'
|
193 |
+
```
|
194 |
+
rerank example:
|
195 |
+
```bash
|
196 |
+
...
|
197 |
+
```
|
198 |
+
"""
|
199 |
)
|
200 |
|
201 |
app = FastAPI(
|
202 |
+
title="Serving BAAI/bge-m3 embed and rerank",
|
203 |
# description="Swagger UI at https://mikeee-baai-m3.hf.space/docs",
|
204 |
description=description,
|
205 |
version="0.1.0a0",
|
|
|
235 |
return "Swagger UI at https://mikeee-baai-m3.hf.space/docs"
|
236 |
|
237 |
|
238 |
+
@app.post("/embed/", response_model=EmbedResponse)
|
239 |
async def get_embeddings(request: EmbedRequest):
|
240 |
embeddings = await processor.process_request(request, "embed")
|
241 |
return EmbedResponse(embeddings=embeddings)
|
|
|
249 |
|
250 |
if __name__ == "__main__":
|
251 |
import uvicorn
|
252 |
+
|
253 |
print("started")
|
254 |
uvicorn.run(app, host="0.0.0.0", port=port)
|