SCANSKY commited on
Commit
9c08e94
·
verified ·
1 Parent(s): 3719c75

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +11 -12
handler.py CHANGED
@@ -8,18 +8,17 @@ class EndpointHandler:
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
- # Parse the incoming data
18
- body = json.loads(data)
19
- text_input = body.get("text", "")
20
- return text_input
21
- except Exception as e:
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
  """