Almaatla commited on
Commit
2b6d798
·
verified ·
1 Parent(s): 107dfba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -15,13 +15,13 @@ def read_root(request: Request):
15
  return templates.TemplateResponse("index.html", {"request": request})
16
 
17
  @app.post("/embed")
18
- def embed_string(query: str):
19
- embedding = model.encode([query])
20
  index.add(np.array(embedding))
21
  return {"message": "String embedded and added to FAISS database"}
22
 
23
  @app.post("/search")
24
- def search_string(query: str, n: int = 5):
25
  embedding = model.encode([text])
26
  distances, indices = index.search(np.array(embedding), n)
27
  return {"distances": distances[0].tolist(), "indices": indices[0].tolist()}
 
15
  return templates.TemplateResponse("index.html", {"request": request})
16
 
17
  @app.post("/embed")
18
+ def embed_string(text: str):
19
+ embedding = model.encode([text])
20
  index.add(np.array(embedding))
21
  return {"message": "String embedded and added to FAISS database"}
22
 
23
  @app.post("/search")
24
+ def search_string(text: str, n: int = 5):
25
  embedding = model.encode([text])
26
  distances, indices = index.search(np.array(embedding), n)
27
  return {"distances": distances[0].tolist(), "indices": indices[0].tolist()}