Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,10 +19,24 @@ async def root():
|
|
| 19 |
return {"message": "Embedding API is running."}
|
| 20 |
|
| 21 |
# Embedding endpoint
|
| 22 |
-
@app.post("/
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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__":
|