Spaces:
Sleeping
Sleeping
Vela
commited on
Commit
·
5cb9852
1
Parent(s):
40b1f16
added try except block
Browse files
main.py
CHANGED
|
@@ -12,9 +12,12 @@ def home_page():
|
|
| 12 |
|
| 13 |
@app.get("/embeddings")
|
| 14 |
def display_embedding(message : str = "Hello guys enter a text to get embeddings"):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
@app.post("/prediction")
|
| 20 |
def display_prediction(prediction : Prediction):
|
|
|
|
| 12 |
|
| 13 |
@app.get("/embeddings")
|
| 14 |
def display_embedding(message : str = "Hello guys enter a text to get embeddings"):
|
| 15 |
+
try:
|
| 16 |
+
embedding = models.get_embedding(message)
|
| 17 |
+
dimension = len(embedding)
|
| 18 |
+
return {"Dimension" : {dimension : embedding.tolist()}}
|
| 19 |
+
except Exception as e:
|
| 20 |
+
return {f"Unable to fetch the embeddings. Error" : e.with_traceback()}
|
| 21 |
|
| 22 |
@app.post("/prediction")
|
| 23 |
def display_prediction(prediction : Prediction):
|