Upload hue_portal/chatbot/chatbot.py with huggingface_hub
Browse files
hue_portal/chatbot/chatbot.py
CHANGED
|
@@ -177,7 +177,15 @@ class Chatbot(CoreChatbot):
|
|
| 177 |
|
| 178 |
# Reset wizard state if new query doesn't have document code and wizard_stage is "answer"
|
| 179 |
# This handles the case where user asks a new question after completing a previous wizard flow
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
print("[WIZARD] 🔄 New query detected, resetting wizard state for fresh start")
|
| 182 |
selected_doc_code = None
|
| 183 |
selected_topic = None
|
|
@@ -197,6 +205,12 @@ class Chatbot(CoreChatbot):
|
|
| 197 |
print("[WIZARD] ✅ Wizard state reset in session metadata")
|
| 198 |
except Exception as e:
|
| 199 |
print(f"⚠️ Failed to reset wizard state: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
# Stage 1: Choose document (if no document selected and no code in query)
|
| 202 |
# Use Query Rewrite Strategy from slow_path_handler instead of old LLM suggestions
|
|
|
|
| 177 |
|
| 178 |
# Reset wizard state if new query doesn't have document code and wizard_stage is "answer"
|
| 179 |
# This handles the case where user asks a new question after completing a previous wizard flow
|
| 180 |
+
# CRITICAL: Check conditions and reset BEFORE Stage 1 check
|
| 181 |
+
should_reset = (
|
| 182 |
+
intent == "search_legal"
|
| 183 |
+
and not has_doc_code_in_query
|
| 184 |
+
and wizard_stage == "answer"
|
| 185 |
+
)
|
| 186 |
+
print(f"[WIZARD] Reset check - intent={intent}, has_doc_code={has_doc_code_in_query}, wizard_stage={wizard_stage}, should_reset={should_reset}")
|
| 187 |
+
|
| 188 |
+
if should_reset:
|
| 189 |
print("[WIZARD] 🔄 New query detected, resetting wizard state for fresh start")
|
| 190 |
selected_doc_code = None
|
| 191 |
selected_topic = None
|
|
|
|
| 205 |
print("[WIZARD] ✅ Wizard state reset in session metadata")
|
| 206 |
except Exception as e:
|
| 207 |
print(f"⚠️ Failed to reset wizard state: {e}")
|
| 208 |
+
# Also update session_metadata dict for current function scope
|
| 209 |
+
if session_metadata:
|
| 210 |
+
session_metadata["selected_document_code"] = None
|
| 211 |
+
session_metadata["selected_topic"] = None
|
| 212 |
+
session_metadata["wizard_stage"] = None
|
| 213 |
+
session_metadata["wizard_depth"] = 0
|
| 214 |
|
| 215 |
# Stage 1: Choose document (if no document selected and no code in query)
|
| 216 |
# Use Query Rewrite Strategy from slow_path_handler instead of old LLM suggestions
|