SarahXia0405 commited on
Commit
c2b40cb
·
verified ·
1 Parent(s): 52e07b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -829,7 +829,9 @@ with gr.Blocks(
829
  cognitive_state = update_cognitive_state_from_message(message, cognitive_state)
830
 
831
  # RAG 始终基于 (预加载 Module10 + 可选上传)
832
- rag_context = retrieve_relevant_chunks(message, rag_chunks or [])
 
 
833
 
834
  start_ts = time.time()
835
  answer, new_history = chat_with_clare(
@@ -842,13 +844,11 @@ with gr.Blocks(
842
  course_outline=course_outline,
843
  weaknesses=weaknesses,
844
  cognitive_state=cognitive_state,
845
- rag_context=rag_context,
846
  )
847
- end_ts = time.time()
848
- latency_ms = (end_ts - start_ts) * 1000.0
849
-
850
  # === 在这里附上 References ===
851
- ref_text = format_references(rag_context)
852
  if ref_text and new_history:
853
  last_user, last_assistant = new_history[-1]
854
  if "References (RAG context used):" not in (last_assistant or ""):
@@ -955,6 +955,13 @@ with gr.Blocks(
955
  resolved_lang = lang_pref
956
 
957
  start_ts = time.time()
 
 
 
 
 
 
 
958
  answer, new_history = chat_with_clare(
959
  message=quiz_instruction,
960
  history=chat_history,
@@ -965,9 +972,7 @@ with gr.Blocks(
965
  course_outline=course_outline,
966
  weaknesses=weaknesses,
967
  cognitive_state=cognitive_state,
968
- rag_context=retrieve_relevant_chunks(
969
- "Module 10 quiz", rag_chunks or []
970
- ),
971
  )
972
  end_ts = time.time()
973
  latency_ms = (end_ts - start_ts) * 1000.0
 
829
  cognitive_state = update_cognitive_state_from_message(message, cognitive_state)
830
 
831
  # RAG 始终基于 (预加载 Module10 + 可选上传)
832
+ rag_context_text, rag_used_chunks = retrieve_relevant_chunks(
833
+ message, rag_chunks or []
834
+ )
835
 
836
  start_ts = time.time()
837
  answer, new_history = chat_with_clare(
 
844
  course_outline=course_outline,
845
  weaknesses=weaknesses,
846
  cognitive_state=cognitive_state,
847
+ rag_context=rag_context_text, # 这里传文本
848
  )
849
+
 
 
850
  # === 在这里附上 References ===
851
+ ref_text = format_references(rag_used_chunks)
852
  if ref_text and new_history:
853
  last_user, last_assistant = new_history[-1]
854
  if "References (RAG context used):" not in (last_assistant or ""):
 
955
  resolved_lang = lang_pref
956
 
957
  start_ts = time.time()
958
+
959
+
960
+ quiz_ctx_text, _quiz_ctx_chunks = retrieve_relevant_chunks(
961
+ "Module 10 quiz", rag_chunks or []
962
+ )
963
+
964
+
965
  answer, new_history = chat_with_clare(
966
  message=quiz_instruction,
967
  history=chat_history,
 
972
  course_outline=course_outline,
973
  weaknesses=weaknesses,
974
  cognitive_state=cognitive_state,
975
+ rag_context=quiz_ctx_text,
 
 
976
  )
977
  end_ts = time.time()
978
  latency_ms = (end_ts - start_ts) * 1000.0