Update handler.py
Browse files- handler.py +11 -12
handler.py
CHANGED
|
@@ -8,18 +8,17 @@ class EndpointHandler:
|
|
| 8 |
"""
|
| 9 |
self.topic_model = BERTopic.load(model_path)
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
raise ValueError(f"Error during preprocessing: {str(e)}")
|
| 23 |
|
| 24 |
def inference(self, text_input):
|
| 25 |
"""
|
|
|
|
| 8 |
"""
|
| 9 |
self.topic_model = BERTopic.load(model_path)
|
| 10 |
|
| 11 |
+
def preprocess(self, data):
|
| 12 |
+
"""
|
| 13 |
+
Preprocess the incoming request data.
|
| 14 |
+
- Extract text input from the request.
|
| 15 |
+
"""
|
| 16 |
+
try:
|
| 17 |
+
# Directly work with the incoming data dictionary
|
| 18 |
+
text_input = data.get("text", "")
|
| 19 |
+
return text_input
|
| 20 |
+
except Exception as e:
|
| 21 |
+
raise ValueError(f"Error during preprocessing: {str(e)}")
|
|
|
|
| 22 |
|
| 23 |
def inference(self, text_input):
|
| 24 |
"""
|