Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from pydantic import BaseModel
|
3 |
+
from sentence_transformers import SentenceTransformer
|
4 |
+
|
5 |
+
model = SentenceTransformer("sergeyzh/BERTA")
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
class TextInput(BaseModel):
|
9 |
+
text: str
|
10 |
+
|
11 |
+
@app.get("/ping")
|
12 |
+
def ping():
|
13 |
+
return {"status": "ok"}
|
14 |
+
|
15 |
+
@app.post("/embed")
|
16 |
+
async def embed_text(data: TextInput):
|
17 |
+
embedding = model.encode(data.text).tolist()
|
18 |
+
return {"embedding": embedding}
|