Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,12 +31,11 @@ def extract_main_topic(text: str) -> str:
|
|
| 31 |
str: The extracted main topic as keywords.
|
| 32 |
"""
|
| 33 |
topics, probs = topic_model.transform([text])
|
| 34 |
-
topic_id = topics[0]
|
| 35 |
|
| 36 |
if topic_id == -1: # BERTopic assigns -1 to noise (no topic detected)
|
| 37 |
return "No clear topic detected."
|
| 38 |
|
| 39 |
-
topic_words = topic_model.get_topic(
|
| 40 |
|
| 41 |
if topic_words:
|
| 42 |
keywords = ", ".join([word for word, _ in topic_words])
|
|
@@ -61,7 +60,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 61 |
|
| 62 |
agent = CodeAgent(
|
| 63 |
model=model,
|
| 64 |
-
tools=[final_answer, my_custom_tool],
|
| 65 |
max_steps=6,
|
| 66 |
verbosity_level=1,
|
| 67 |
grammar=None,
|
|
|
|
| 31 |
str: The extracted main topic as keywords.
|
| 32 |
"""
|
| 33 |
topics, probs = topic_model.transform([text])
|
|
|
|
| 34 |
|
| 35 |
if topic_id == -1: # BERTopic assigns -1 to noise (no topic detected)
|
| 36 |
return "No clear topic detected."
|
| 37 |
|
| 38 |
+
topic_words = topic_model.get_topic(topics[0])
|
| 39 |
|
| 40 |
if topic_words:
|
| 41 |
keywords = ", ".join([word for word, _ in topic_words])
|
|
|
|
| 60 |
|
| 61 |
agent = CodeAgent(
|
| 62 |
model=model,
|
| 63 |
+
tools=[final_answer, my_custom_tool, extract_main_topic],
|
| 64 |
max_steps=6,
|
| 65 |
verbosity_level=1,
|
| 66 |
grammar=None,
|