Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import torch
|
|
| 6 |
|
| 7 |
# Define the API schema for the request body
|
| 8 |
class EmbeddingRequest(BaseModel):
|
| 9 |
-
|
| 10 |
|
| 11 |
# Initialize FastAPI app
|
| 12 |
app = FastAPI()
|
|
@@ -21,7 +21,7 @@ model = SentenceTransformer(model_name, device=device, trust_remote_code=True)
|
|
| 21 |
async def get_embeddings(request: EmbeddingRequest):
|
| 22 |
try:
|
| 23 |
# Get embeddings for the input text
|
| 24 |
-
embeddings = model.encode(request.
|
| 25 |
return {"embeddings": embeddings}
|
| 26 |
except Exception as e:
|
| 27 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
| 6 |
|
| 7 |
# Define the API schema for the request body
|
| 8 |
class EmbeddingRequest(BaseModel):
|
| 9 |
+
inputs: list[str]
|
| 10 |
|
| 11 |
# Initialize FastAPI app
|
| 12 |
app = FastAPI()
|
|
|
|
| 21 |
async def get_embeddings(request: EmbeddingRequest):
|
| 22 |
try:
|
| 23 |
# Get embeddings for the input text
|
| 24 |
+
embeddings = model.encode(request.inputs, convert_to_numpy=True).tolist()
|
| 25 |
return {"embeddings": embeddings}
|
| 26 |
except Exception as e:
|
| 27 |
raise HTTPException(status_code=500, detail=str(e))
|