Spaces:
Runtime error
Runtime error
Commit
Β·
083f6db
1
Parent(s):
2836322
init
Browse files- app.py +16 -0
- requirements.txt +0 -0
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from sentence_transformers import SentenceTransformer
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
model = SentenceTransformer("MossaabDev/quran_shifaa")
|
| 6 |
+
|
| 7 |
+
@app.post("/embed")
|
| 8 |
+
async def embed(text: str):
|
| 9 |
+
emb = model.encode(text).tolist()
|
| 10 |
+
return {"embedding": emb}
|
| 11 |
+
|
| 12 |
+
# embed a list of texts
|
| 13 |
+
@app.post("/embed_batch")
|
| 14 |
+
async def embed_batch(texts: list[str]):
|
| 15 |
+
embs = model.encode(texts).tolist()
|
| 16 |
+
return {"embeddings": embs}
|
requirements.txt
ADDED
|
Binary file (11.2 kB). View file
|
|
|