Update conversation_logic.py
Browse files- conversation_logic.py +13 -17
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,11 +1321,8 @@ class ConversationEngine:
|
|
| 1321 |
if input_type in {"hint", "next_hint"}:
|
| 1322 |
hint_lines: List[str] = []
|
| 1323 |
|
| 1324 |
-
if
|
| 1325 |
-
|
| 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,10 +1348,7 @@ class ConversationEngine:
|
|
| 1351 |
hint_lines = [next_hint_text]
|
| 1352 |
|
| 1353 |
if not hint_lines and fallback_reply_core:
|
| 1354 |
-
|
| 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,6 +1358,8 @@ class ConversationEngine:
|
|
| 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,
|
|
|
|
| 1054 |
if not fallback_pack:
|
| 1055 |
return False
|
| 1056 |
support_source = str(fallback_pack.get("support_source", "")).strip().lower()
|
| 1057 |
+
support_priority = int(fallback_pack.get("support_priority", 0) or 0)
|
| 1058 |
+
support_match = fallback_pack.get("support_match") or {}
|
| 1059 |
+
confidence = str(support_match.get("confidence", "")).strip().lower()
|
| 1060 |
+
|
| 1061 |
+
authored_source = support_source in {"question_bank", "question_bank_refined", "question_id", "question_text"}
|
| 1062 |
+
strong_match = confidence in {"exact", "high", "medium"} or support_priority >= 60
|
| 1063 |
+
|
| 1064 |
if help_mode in {"hint", "walkthrough", "instruction", "step_by_step", "explain", "method"}:
|
| 1065 |
+
return authored_source or strong_match
|
| 1066 |
return False
|
| 1067 |
|
| 1068 |
|
|
|
|
| 1321 |
if input_type in {"hint", "next_hint"}:
|
| 1322 |
hint_lines: List[str] = []
|
| 1323 |
|
| 1324 |
+
if prefer_question_support and fallback_reply_core:
|
| 1325 |
+
hint_lines = [line.strip("- ").strip() for line in fallback_reply_core.splitlines() if line.strip()]
|
|
|
|
|
|
|
|
|
|
| 1326 |
|
| 1327 |
if not hint_lines:
|
| 1328 |
custom_ladder = _question_specific_hint_ladder(
|
|
|
|
| 1348 |
hint_lines = [next_hint_text]
|
| 1349 |
|
| 1350 |
if not hint_lines and fallback_reply_core:
|
| 1351 |
+
hint_lines = [line.strip("- ").strip() for line in fallback_reply_core.splitlines() if line.strip()]
|
|
|
|
|
|
|
|
|
|
| 1352 |
|
| 1353 |
if not hint_lines:
|
| 1354 |
hint_lines = [_minimal_generic_reply(inferred_category)]
|
|
|
|
| 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,
|