Update handler.py
Browse files- handler.py +7 -2
handler.py
CHANGED
@@ -38,8 +38,11 @@ class EndpointHandler:
|
|
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 |
-
|
|
|
|
|
|
|
43 |
|
44 |
results.append({
|
45 |
"topic": int(topic),
|
@@ -76,3 +79,5 @@ class EndpointHandler:
|
|
76 |
except Exception as e:
|
77 |
return [{"error": str(e)}] # Returning error as a list with a dictionary
|
78 |
|
|
|
|
|
|
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 (with fallback if custom_labels_ is not available)
|
42 |
+
if hasattr(self.topic_model, "custom_labels_") and self.topic_model.custom_labels_ is not None:
|
43 |
+
custom_label = self.topic_model.custom_labels_[topic + 1]
|
44 |
+
else:
|
45 |
+
custom_label = f"Topic {topic}" # Fallback label
|
46 |
|
47 |
results.append({
|
48 |
"topic": int(topic),
|
|
|
79 |
except Exception as e:
|
80 |
return [{"error": str(e)}] # Returning error as a list with a dictionary
|
81 |
|
82 |
+
# Create an instance of the handler
|
83 |
+
handler = EndpointHandler()
|