j-js commited on
Commit
28ef36e
·
verified ·
1 Parent(s): 5bc2407

Update conversation_logic.py

Browse files
Files changed (1) hide show
  1. conversation_logic.py +25 -62
conversation_logic.py CHANGED
@@ -852,49 +852,17 @@ class ConversationEngine:
852
 
853
  selected_chunks: List[RetrievedChunk] = []
854
 
855
- # -----------------------------
856
- # EXPLAINER PATH (runs before solver)
857
- # -----------------------------
858
- if is_explainer_request(user_text or solver_input):
859
- explainer_result = route_explainer(solver_input)
860
-
861
- if explainer_result is not None and getattr(explainer_result, "understood", False):
862
- reply = format_explainer_response(
863
- result=explainer_result,
864
- tone=tone,
865
- verbosity=verbosity,
866
- transparency=transparency,
867
- )
868
-
869
- result.domain = "quant" if inferred_category == "Quantitative" or is_quant_question(solver_input) else "general"
870
- result.solved = False
871
- result.help_mode = getattr(explainer_result, "help_mode", "explain")
872
- result.topic = getattr(explainer_result, "topic", None) or question_topic
873
- result.answer_letter = None
874
- result.answer_value = None
875
- result.internal_answer = None
876
- result.used_retrieval = False
877
- result.used_generator = False
878
- result.reply = reply
879
- result.meta = {
880
- "intent": "explain_question",
881
- "question_text": question_text or "",
882
- "options_count": len(options_text or []),
883
- "category": inferred_category,
884
- "question_type": question_type,
885
- "classified_topic": question_topic,
886
- "explainer_used": True,
887
- }
888
- return result
889
 
890
  # 1. set up input / classification / intent
891
  solver_input = (question_text or raw_user_text or "").strip()
892
  user_text = (raw_user_text or "").strip()
893
-
 
 
894
  # 2. explainer path FIRST
895
  if is_explainer_request(user_text or solver_input):
896
  explainer_result = route_explainer(solver_input)
897
-
898
  if explainer_result is not None and getattr(explainer_result, "understood", False):
899
  reply = format_explainer_response(
900
  result=explainer_result,
@@ -902,25 +870,26 @@ class ConversationEngine:
902
  verbosity=verbosity,
903
  transparency=transparency,
904
  )
905
-
906
- result.domain = "quant" if inferred_category == "Quantitative" or is_quant_question(solver_input) else "general"
907
- result.solved = False
908
- result.help_mode = "explain"
909
- result.topic = explainer_result.topic or question_topic
910
- result.answer_letter = None
911
- result.answer_value = None
912
- result.internal_answer = None
913
- result.reply = reply
914
- result.meta = {
915
- "intent": "explain_question",
916
- "question_text": question_text or "",
917
- "options_count": len(options_text or []),
918
- "category": inferred_category,
919
- "question_type": question_type,
920
- "classified_topic": question_topic,
921
- "explainer_used": True,
922
- }
923
- return result
 
924
 
925
  # 3. normal solver path AFTER
926
  if inferred_category == "Quantitative" or is_quant_question(solver_input):
@@ -944,13 +913,6 @@ class ConversationEngine:
944
  category=inferred_category,
945
  )
946
 
947
- reply = format_reply(
948
- reply,
949
- tone,
950
- verbosity,
951
- transparency,
952
- resolved_help_mode,
953
- )
954
 
955
  allow_retrieval = should_retrieve(
956
  intent=resolved_intent,
@@ -1013,6 +975,7 @@ class ConversationEngine:
1013
  self.generator is not None
1014
  and not result.solved
1015
  and resolved_help_mode not in {"hint", "instruction"}
 
1016
  )
1017
 
1018
  if should_try_generator:
 
852
 
853
  selected_chunks: List[RetrievedChunk] = []
854
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
 
856
  # 1. set up input / classification / intent
857
  solver_input = (question_text or raw_user_text or "").strip()
858
  user_text = (raw_user_text or "").strip()
859
+
860
+ is_quant = inferred_category == "Quantitative" or is_quant_question(solver_input)
861
+
862
  # 2. explainer path FIRST
863
  if is_explainer_request(user_text or solver_input):
864
  explainer_result = route_explainer(solver_input)
865
+
866
  if explainer_result is not None and getattr(explainer_result, "understood", False):
867
  reply = format_explainer_response(
868
  result=explainer_result,
 
870
  verbosity=verbosity,
871
  transparency=transparency,
872
  )
873
+ result.domain = "quant" if is_quant else "general"
874
+ result.solved = False
875
+ result.help_mode = "explain"
876
+ result.topic = getattr(explainer_result, "topic", None) or question_topic
877
+ result.answer_letter = None
878
+ result.answer_value = None
879
+ result.internal_answer = None
880
+ result.used_retrieval = False
881
+ result.used_generator = False
882
+ result.reply = reply
883
+ result.meta = {
884
+ "intent": "explain_question",
885
+ "question_text": question_text or "",
886
+ "options_count": len(options_text or []),
887
+ "category": inferred_category,
888
+ "question_type": question_type,
889
+ "classified_topic": question_topic,
890
+ "explainer_used": True,
891
+ }
892
+ return result
893
 
894
  # 3. normal solver path AFTER
895
  if inferred_category == "Quantitative" or is_quant_question(solver_input):
 
913
  category=inferred_category,
914
  )
915
 
 
 
 
 
 
 
 
916
 
917
  allow_retrieval = should_retrieve(
918
  intent=resolved_intent,
 
975
  self.generator is not None
976
  and not result.solved
977
  and resolved_help_mode not in {"hint", "instruction"}
978
+ and result.domain != "quant"
979
  )
980
 
981
  if should_try_generator: