JohnKouf commited on
Commit
0abf1cd
·
verified ·
1 Parent(s): 80906c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -19,10 +19,24 @@ async def root():
19
  return {"message": "Embedding API is running."}
20
 
21
  # Embedding endpoint
22
- @app.post("/embed")
23
- async def embed_text(request: EmbeddingRequest):
24
- embeddings = model.encode(request.texts).tolist()
25
- return {"embeddings": embeddings}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  # Optional for local testing
28
  if __name__ == "__main__":
 
19
  return {"message": "Embedding API is running."}
20
 
21
  # Embedding endpoint
22
+ @app.post("/get_sim_text")
23
+ def get_sim_text_endpoint(request: TextPairRequest):
24
+ try:
25
+ # Embed the claim text
26
+ claim_embedding = similarity_model.model.encode(
27
+ request.claim,
28
+ convert_to_tensor=True,
29
+ show_progress_bar=False
30
+ )
31
+ # Call get_sim_text with defaults (min_threshold=0.4, chunk_size=1500)
32
+ results = similarity_model.get_sim_text(
33
+ request.text,
34
+ claim_embedding
35
+ )
36
+ return {"result": results}
37
+
38
+ except Exception as e:
39
+ return {"error": str(e)}
40
 
41
  # Optional for local testing
42
  if __name__ == "__main__":