futranbg commited on
Commit
76af122
·
verified ·
1 Parent(s): 3a7803b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -6,7 +6,7 @@ import torch
6
 
7
  # Define the API schema for the request body
8
  class EmbeddingRequest(BaseModel):
9
- text: list[str]
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.text, convert_to_numpy=True).tolist()
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))