SCANSKY commited on
Commit
b8ba708
·
verified ·
1 Parent(s): 13ffec1

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -1
handler.py CHANGED
@@ -37,10 +37,15 @@ class EndpointHandler:
37
  for topic, prob in zip(topics, probabilities):
38
  topic_info = self.topic_model.get_topic(topic)
39
  topic_words = [word for word, _ in topic_info] if topic_info else []
 
 
 
 
40
  results.append({
41
  "topic": int(topic),
42
  "probability": float(prob),
43
- "top_words": topic_words[:5] # Top 5 words
 
44
  })
45
 
46
  return results
 
37
  for topic, prob in zip(topics, probabilities):
38
  topic_info = self.topic_model.get_topic(topic)
39
  topic_words = [word for word, _ in topic_info] if topic_info else []
40
+
41
+ # Get custom label for the topic
42
+ custom_label = self.topic_model.custom_labels_[topic + 1] if hasattr(self.topic_model, "custom_labels_") else f"Topic {topic}"
43
+
44
  results.append({
45
  "topic": int(topic),
46
  "probability": float(prob),
47
+ "top_words": topic_words[:5], # Top 5 words
48
+ "customLabel": custom_label # Add custom label
49
  })
50
 
51
  return results