SarahXia0405 commited on
Commit
21a9f67
·
verified ·
1 Parent(s): c2b40cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -825,6 +825,7 @@ with gr.Blocks(
825
  )
826
  return "", chat_history, weaknesses, cognitive_state, new_status
827
 
 
828
  weaknesses = update_weaknesses_from_message(message, weaknesses or [])
829
  cognitive_state = update_cognitive_state_from_message(message, cognitive_state)
830
 
@@ -833,6 +834,7 @@ with gr.Blocks(
833
  message, rag_chunks or []
834
  )
835
 
 
836
  start_ts = time.time()
837
  answer, new_history = chat_with_clare(
838
  message=message,
@@ -844,9 +846,11 @@ with gr.Blocks(
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:
@@ -857,6 +861,7 @@ with gr.Blocks(
857
  answer = last_assistant # 同步给日志
858
  # ==============================
859
 
 
860
  student_id = user_id_val or "ANON"
861
  experiment_id = "RESP_AI_W10"
862
 
@@ -881,6 +886,8 @@ with gr.Blocks(
881
  new_status = render_session_status(mode_val, weaknesses, cognitive_state)
882
  return "", new_history, weaknesses, cognitive_state, new_status
883
 
 
 
884
  user_input.submit(
885
  respond,
886
  [
 
825
  )
826
  return "", chat_history, weaknesses, cognitive_state, new_status
827
 
828
+ # 更新学生状态
829
  weaknesses = update_weaknesses_from_message(message, weaknesses or [])
830
  cognitive_state = update_cognitive_state_from_message(message, cognitive_state)
831
 
 
834
  message, rag_chunks or []
835
  )
836
 
837
+ # 计时
838
  start_ts = time.time()
839
  answer, new_history = chat_with_clare(
840
  message=message,
 
846
  course_outline=course_outline,
847
  weaknesses=weaknesses,
848
  cognitive_state=cognitive_state,
849
+ rag_context=rag_context_text, # 这里传检索文本
850
  )
851
+ end_ts = time.time()
852
+ latency_ms = (end_ts - start_ts) * 1000.0
853
+
854
  # === 在这里附上 References ===
855
  ref_text = format_references(rag_used_chunks)
856
  if ref_text and new_history:
 
861
  answer = last_assistant # 同步给日志
862
  # ==============================
863
 
864
+ # 日志
865
  student_id = user_id_val or "ANON"
866
  experiment_id = "RESP_AI_W10"
867
 
 
886
  new_status = render_session_status(mode_val, weaknesses, cognitive_state)
887
  return "", new_history, weaknesses, cognitive_state, new_status
888
 
889
+
890
+
891
  user_input.submit(
892
  respond,
893
  [