Spaces:
Build error
Build error
Update src/components/ai_tutor.py
Browse files
src/components/ai_tutor.py
CHANGED
|
@@ -55,18 +55,15 @@ class AITutor:
|
|
| 55 |
if message["role"] == "assistant" and voice_active:
|
| 56 |
self.service.speak(message["content"])
|
| 57 |
|
| 58 |
-
# Refresh chat history
|
| 59 |
-
if st.button("Refresh Chat", key="refresh_chat"):
|
| 60 |
-
st.rerun() # Updated to st.rerun()
|
| 61 |
-
|
| 62 |
# Chat input
|
| 63 |
if prompt := st.text_input("Ask your question...", key="chat_input"):
|
| 64 |
self.handle_user_input(prompt)
|
| 65 |
|
| 66 |
def handle_user_input(self, user_input: str):
|
| 67 |
"""Process user input and generate response"""
|
| 68 |
-
# Add user message
|
| 69 |
context = get_tutor_context()
|
|
|
|
|
|
|
| 70 |
context['chat_history'].append({
|
| 71 |
"role": "user",
|
| 72 |
"content": user_input
|
|
@@ -82,5 +79,4 @@ class AITutor:
|
|
| 82 |
"speak": True
|
| 83 |
})
|
| 84 |
|
| 85 |
-
#
|
| 86 |
-
st.rerun() # Updated to st.rerun()
|
|
|
|
| 55 |
if message["role"] == "assistant" and voice_active:
|
| 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"""
|
|
|
|
| 64 |
context = get_tutor_context()
|
| 65 |
+
|
| 66 |
+
# Add user message
|
| 67 |
context['chat_history'].append({
|
| 68 |
"role": "user",
|
| 69 |
"content": user_input
|
|
|
|
| 79 |
"speak": True
|
| 80 |
})
|
| 81 |
|
| 82 |
+
# No need to rerun here, Streamlit will update automatically
|
|
|