Update conversation_logic.py
Browse files- conversation_logic.py +38 -0
conversation_logic.py
CHANGED
|
@@ -885,6 +885,44 @@ class ConversationEngine:
|
|
| 885 |
}
|
| 886 |
return result
|
| 887 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 888 |
if inferred_category == "Quantitative" or is_quant_question(solver_input):
|
| 889 |
solved_result = route_solver(solver_input)
|
| 890 |
if solved_result is not None:
|
|
|
|
| 885 |
}
|
| 886 |
return result
|
| 887 |
|
| 888 |
+
# 1. set up input / classification / intent
|
| 889 |
+
solver_input = (question_text or raw_user_text or "").strip()
|
| 890 |
+
user_text = (raw_user_text or "").strip()
|
| 891 |
+
|
| 892 |
+
# 2. explainer path FIRST
|
| 893 |
+
if is_explainer_request(user_text or solver_input):
|
| 894 |
+
explainer_result = route_explainer(solver_input)
|
| 895 |
+
|
| 896 |
+
if explainer_result is not None and getattr(explainer_result, "understood", False):
|
| 897 |
+
reply = format_explainer_response(
|
| 898 |
+
result=explainer_result,
|
| 899 |
+
tone=tone,
|
| 900 |
+
verbosity=verbosity,
|
| 901 |
+
transparency=transparency,
|
| 902 |
+
)
|
| 903 |
+
|
| 904 |
+
result.domain = "quant" if inferred_category == "Quantitative" or is_quant_question(solver_input) else "general"
|
| 905 |
+
result.solved = False
|
| 906 |
+
result.help_mode = "explain"
|
| 907 |
+
result.topic = explainer_result.topic or question_topic
|
| 908 |
+
result.answer_letter = None
|
| 909 |
+
result.answer_value = None
|
| 910 |
+
result.internal_answer = None
|
| 911 |
+
result.reply = reply
|
| 912 |
+
result.meta = {
|
| 913 |
+
"intent": "explain_question",
|
| 914 |
+
"question_text": question_text or "",
|
| 915 |
+
"options_count": len(options_text or []),
|
| 916 |
+
"category": inferred_category,
|
| 917 |
+
"question_type": question_type,
|
| 918 |
+
"classified_topic": question_topic,
|
| 919 |
+
"explainer_used": True,
|
| 920 |
+
}
|
| 921 |
+
return result
|
| 922 |
+
|
| 923 |
+
# 3. normal solver path AFTER
|
| 924 |
+
if inferred_category == "Quantitative" or is_quant_question(solver_input):
|
| 925 |
+
solved_result = route_solver(solver_input)
|
| 926 |
if inferred_category == "Quantitative" or is_quant_question(solver_input):
|
| 927 |
solved_result = route_solver(solver_input)
|
| 928 |
if solved_result is not None:
|