Update conversation_logic.py
Browse files- conversation_logic.py +32 -19
conversation_logic.py
CHANGED
|
@@ -173,25 +173,38 @@ def _looks_like_question_text(text: str) -> bool:
|
|
| 173 |
|
| 174 |
|
| 175 |
def _is_topic_query(text: str) -> bool:
|
| 176 |
-
low =
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
|
| 197 |
def _specific_topic_from_question(question_text: str, fallback_topic: str, classified_topic: str) -> str:
|
|
|
|
| 173 |
|
| 174 |
|
| 175 |
def _is_topic_query(text: str) -> bool:
|
| 176 |
+
low = (text or "").strip().lower()
|
| 177 |
+
|
| 178 |
+
exact_patterns = [
|
| 179 |
+
"what topic is this question",
|
| 180 |
+
"what topic is this",
|
| 181 |
+
"what is the topic",
|
| 182 |
+
"what type of question is this",
|
| 183 |
+
"what kind of question is this",
|
| 184 |
+
"what area is this",
|
| 185 |
+
"what is this testing",
|
| 186 |
+
"what skill is this testing",
|
| 187 |
+
"what concept is this testing",
|
| 188 |
+
"identify the topic",
|
| 189 |
+
"identify the type of question",
|
| 190 |
+
]
|
| 191 |
+
if any(p in low for p in exact_patterns):
|
| 192 |
+
return True
|
| 193 |
+
|
| 194 |
+
# shorter / looser phrasing
|
| 195 |
+
if "topic" in low and "this" in low:
|
| 196 |
+
return True
|
| 197 |
+
|
| 198 |
+
if "testing" in low and "this" in low:
|
| 199 |
+
return True
|
| 200 |
+
|
| 201 |
+
if "type" in low and "question" in low:
|
| 202 |
+
return True
|
| 203 |
+
|
| 204 |
+
if "kind" in low and "question" in low:
|
| 205 |
+
return True
|
| 206 |
+
|
| 207 |
+
return False
|
| 208 |
|
| 209 |
|
| 210 |
def _specific_topic_from_question(question_text: str, fallback_topic: str, classified_topic: str) -> str:
|