Dineflow commited on
Commit
779ab46
·
verified ·
1 Parent(s): d08e49e

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +3 -1
handler.py CHANGED
@@ -41,13 +41,16 @@ class EndpointHandler:
41
  if not isinstance(review, str) or not review.strip():
42
  return json.dumps({"error": "Review must be a non-empty string."})
43
 
 
44
  predicted_rating = self.predict_rating(review)
45
 
 
46
  response = {
47
  "review": review,
48
  "predicted_rating": predicted_rating
49
  }
50
 
 
51
  return json.dumps(response)
52
 
53
  except json.JSONDecodeError:
@@ -55,4 +58,3 @@ class EndpointHandler:
55
 
56
  except Exception as e:
57
  return json.dumps({"error": str(e)})
58
-
 
41
  if not isinstance(review, str) or not review.strip():
42
  return json.dumps({"error": "Review must be a non-empty string."})
43
 
44
+ # Perform prediction
45
  predicted_rating = self.predict_rating(review)
46
 
47
+ # Prepare response
48
  response = {
49
  "review": review,
50
  "predicted_rating": predicted_rating
51
  }
52
 
53
+ # Return JSON response
54
  return json.dumps(response)
55
 
56
  except json.JSONDecodeError:
 
58
 
59
  except Exception as e:
60
  return json.dumps({"error": str(e)})