File size: 435 Bytes
083f6db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from sentence_transformers import SentenceTransformer

app = FastAPI()
model = SentenceTransformer("MossaabDev/quran_shifaa")

@app.post("/embed")
async def embed(text: str):
    emb = model.encode(text).tolist()
    return {"embedding": emb}

# embed a list of texts
@app.post("/embed_batch")
async def embed_batch(texts: list[str]):
    embs = model.encode(texts).tolist()
    return {"embeddings": embs}