cryogenic22 commited on
Commit
63c1cea
·
verified ·
1 Parent(s): b5ed3e9

Update src/components/ai_tutor.py

Browse files
Files changed (1) hide show
  1. src/components/ai_tutor.py +5 -2
src/components/ai_tutor.py CHANGED
@@ -5,6 +5,7 @@ from src.utils.session import get_tutor_context
5
  class AITutor:
6
  def __init__(self):
7
  self.service = AITutorService()
 
8
 
9
  def display_chat_interface(self):
10
  """Display the enhanced chat interface with voice output"""
@@ -56,8 +57,10 @@ class AITutor:
56
  self.service.speak(message["content"])
57
 
58
  # Chat input
59
- if prompt := st.text_input("Ask your question...", key="chat_input"):
 
60
  self.handle_user_input(prompt)
 
61
 
62
  def handle_user_input(self, user_input: str):
63
  """Process user input and generate response"""
@@ -76,7 +79,7 @@ class AITutor:
76
  context['chat_history'].append({
77
  "role": "assistant",
78
  "content": response,
79
- "speak": True
80
  })
81
 
82
  # No need to rerun here, Streamlit will update automatically
 
5
  class AITutor:
6
  def __init__(self):
7
  self.service = AITutorService()
8
+ self.last_question = None # Store the last question asked
9
 
10
  def display_chat_interface(self):
11
  """Display the enhanced chat interface with voice output"""
 
57
  self.service.speak(message["content"])
58
 
59
  # Chat input
60
+ prompt = st.text_input("Ask your question...", key="chat_input")
61
+ if prompt and prompt != self.last_question: # Check if the question is new
62
  self.handle_user_input(prompt)
63
+ self.last_question = prompt # Update the last question asked
64
 
65
  def handle_user_input(self, user_input: str):
66
  """Process user input and generate response"""
 
79
  context['chat_history'].append({
80
  "role": "assistant",
81
  "content": response,
82
+ "speak": True # You might want to remove this if not using voice output
83
  })
84
 
85
  # No need to rerun here, Streamlit will update automatically