I have change input to feedback
Browse files- handler.py +3 -3
handler.py
CHANGED
|
@@ -14,14 +14,14 @@ class EndpointHandler:
|
|
| 14 |
predicted_rating = self.model.predict(review_tfidf)[0]
|
| 15 |
return predicted_rating
|
| 16 |
|
| 17 |
-
def __call__(self,
|
| 18 |
try:
|
| 19 |
# Ensure inputs is a JSON string
|
| 20 |
-
if not isinstance(
|
| 21 |
return json.dumps({"error": "Input must be a JSON string"})
|
| 22 |
|
| 23 |
# Using regex to extract the value of "inputs" from the JSON string
|
| 24 |
-
match = re.search(r'\"
|
| 25 |
|
| 26 |
if not match:
|
| 27 |
return json.dumps({"error": "No valid review provided or incorrect format"})
|
|
|
|
| 14 |
predicted_rating = self.model.predict(review_tfidf)[0]
|
| 15 |
return predicted_rating
|
| 16 |
|
| 17 |
+
def __call__(self, feedback):
|
| 18 |
try:
|
| 19 |
# Ensure inputs is a JSON string
|
| 20 |
+
if not isinstance(feedback, str):
|
| 21 |
return json.dumps({"error": "Input must be a JSON string"})
|
| 22 |
|
| 23 |
# Using regex to extract the value of "inputs" from the JSON string
|
| 24 |
+
match = re.search(r'\"feedback\"\s*:\s*\"(.*?)\"', feedback)
|
| 25 |
|
| 26 |
if not match:
|
| 27 |
return json.dumps({"error": "No valid review provided or incorrect format"})
|