Update conversation_logic.py
Browse files- conversation_logic.py +17 -13
conversation_logic.py
CHANGED
|
@@ -1054,15 +1054,15 @@ def _should_prefer_question_support(help_mode: str, fallback_pack: Dict[str, Any
|
|
| 1054 |
if not fallback_pack:
|
| 1055 |
return False
|
| 1056 |
support_source = str(fallback_pack.get("support_source", "")).strip().lower()
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
if help_mode in {"hint", "walkthrough", "instruction", "step_by_step", "explain", "method"}:
|
| 1065 |
-
return
|
| 1066 |
return False
|
| 1067 |
|
| 1068 |
|
|
@@ -1321,8 +1321,11 @@ class ConversationEngine:
|
|
| 1321 |
if input_type in {"hint", "next_hint"}:
|
| 1322 |
hint_lines: List[str] = []
|
| 1323 |
|
| 1324 |
-
if
|
| 1325 |
-
|
|
|
|
|
|
|
|
|
|
| 1326 |
|
| 1327 |
if not hint_lines:
|
| 1328 |
custom_ladder = _question_specific_hint_ladder(
|
|
@@ -1348,7 +1351,10 @@ class ConversationEngine:
|
|
| 1348 |
hint_lines = [next_hint_text]
|
| 1349 |
|
| 1350 |
if not hint_lines and fallback_reply_core:
|
| 1351 |
-
|
|
|
|
|
|
|
|
|
|
| 1352 |
|
| 1353 |
if not hint_lines:
|
| 1354 |
hint_lines = [_minimal_generic_reply(inferred_category)]
|
|
@@ -1358,8 +1364,6 @@ class ConversationEngine:
|
|
| 1358 |
result.meta["question_support_used"] = bool(fallback_pack)
|
| 1359 |
result.meta["question_support_source"] = fallback_pack.get("support_source") if fallback_pack else None
|
| 1360 |
result.meta["question_support_topic"] = fallback_pack.get("topic") if fallback_pack else None
|
| 1361 |
-
result.meta["question_support_match"] = fallback_pack.get("support_match") if fallback_pack else None
|
| 1362 |
-
result.meta["question_support_priority"] = fallback_pack.get("support_priority") if fallback_pack else None
|
| 1363 |
|
| 1364 |
reply = format_reply(
|
| 1365 |
reply_core,
|
|
|
|
| 1054 |
if not fallback_pack:
|
| 1055 |
return False
|
| 1056 |
support_source = str(fallback_pack.get("support_source", "")).strip().lower()
|
| 1057 |
+
has_specific_content = support_source in {
|
| 1058 |
+
"question_bank",
|
| 1059 |
+
"question_bank_refined",
|
| 1060 |
+
"question_id",
|
| 1061 |
+
"question_text",
|
| 1062 |
+
"generated_question_specific",
|
| 1063 |
+
}
|
| 1064 |
if help_mode in {"hint", "walkthrough", "instruction", "step_by_step", "explain", "method"}:
|
| 1065 |
+
return has_specific_content or bool(fallback_pack)
|
| 1066 |
return False
|
| 1067 |
|
| 1068 |
|
|
|
|
| 1321 |
if input_type in {"hint", "next_hint"}:
|
| 1322 |
hint_lines: List[str] = []
|
| 1323 |
|
| 1324 |
+
if fallback_pack:
|
| 1325 |
+
fallback_hints = _safe_meta_list(fallback_pack.get("hint_ladder", []))
|
| 1326 |
+
if fallback_hints:
|
| 1327 |
+
idx = min(max(hint_stage - 1, 0), len(fallback_hints) - 1)
|
| 1328 |
+
hint_lines = [fallback_hints[idx]]
|
| 1329 |
|
| 1330 |
if not hint_lines:
|
| 1331 |
custom_ladder = _question_specific_hint_ladder(
|
|
|
|
| 1351 |
hint_lines = [next_hint_text]
|
| 1352 |
|
| 1353 |
if not hint_lines and fallback_reply_core:
|
| 1354 |
+
split_lines = [line.strip("- ").strip() for line in fallback_reply_core.splitlines() if line.strip()]
|
| 1355 |
+
if split_lines:
|
| 1356 |
+
idx = min(max(hint_stage - 1, 0), len(split_lines) - 1)
|
| 1357 |
+
hint_lines = [split_lines[idx]]
|
| 1358 |
|
| 1359 |
if not hint_lines:
|
| 1360 |
hint_lines = [_minimal_generic_reply(inferred_category)]
|
|
|
|
| 1364 |
result.meta["question_support_used"] = bool(fallback_pack)
|
| 1365 |
result.meta["question_support_source"] = fallback_pack.get("support_source") if fallback_pack else None
|
| 1366 |
result.meta["question_support_topic"] = fallback_pack.get("topic") if fallback_pack else None
|
|
|
|
|
|
|
| 1367 |
|
| 1368 |
reply = format_reply(
|
| 1369 |
reply_core,
|