cryogenic22 commited on
Commit
dc67156
·
verified ·
1 Parent(s): a153fc6

Update src/components/ai_tutor.py

Browse files
Files changed (1) hide show
  1. src/components/ai_tutor.py +30 -1
src/components/ai_tutor.py CHANGED
@@ -2,6 +2,14 @@ import streamlit as st
2
  from src.services.ai_service import AITutorService
3
  from src.utils.session import get_tutor_context
4
 
 
 
 
 
 
 
 
 
5
  class AITutor:
6
  def __init__(self):
7
  self.service = AITutorService()
@@ -14,6 +22,20 @@ class AITutor:
14
  col1, col2 = st.columns([3, 2])
15
  with col1:
16
  voice_active = st.checkbox("Enable Voice", value=False, key="voice_active")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  with col2:
18
  if self.service.tts_mode:
19
  st.info(f"Using {self.service.tts_mode.upper()} TTS")
@@ -40,6 +62,10 @@ class AITutor:
40
  st.write(message["content"])
41
  if message["role"] == "assistant" and voice_active:
42
  self.service.speak(message["content"])
 
 
 
 
43
 
44
  # Chat input
45
  if prompt := st.text_input("Ask your question...", key="chat_input"):
@@ -62,4 +88,7 @@ class AITutor:
62
  "role": "assistant",
63
  "content": response,
64
  "speak": True
65
- })
 
 
 
 
2
  from src.services.ai_service import AITutorService
3
  from src.utils.session import get_tutor_context
4
 
5
+ class AITutor:
6
+ def __init__(self):
7
+ self.service = AITutorService()
8
+
9
+ import streamlit as st
10
+ from src.services.ai_service import AITutorService
11
+ from src.utils.session import get_tutor_context
12
+
13
  class AITutor:
14
  def __init__(self):
15
  self.service = AITutorService()
 
22
  col1, col2 = st.columns([3, 2])
23
  with col1:
24
  voice_active = st.checkbox("Enable Voice", value=False, key="voice_active")
25
+ if voice_active:
26
+ st.markdown("""
27
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
28
+ <path d="M15 8V16M11 8V16M7 12H5C3.89543 12 3 12.8954 3 14V16C3 17.1046 3.89543 18 5 18H7V12ZM19 12V16C19 17.1046 18.1046 18 17 18H15" stroke="#4A90E2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
29
+ </svg>
30
+ Voice On
31
+ """, unsafe_allow_html=True)
32
+ else:
33
+ st.markdown("""
34
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
35
+ <path d="M15 8V16M11 8V16M7 12H5C3.89543 12 3 12.8954 3 14V16C3 17.1046 3.89543 18 5 18H7V12ZM19 12V16C19 17.1046 18.1046 18 17 18H15" stroke="#B0B0B0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
36
+ </svg>
37
+ Voice Off
38
+ """, unsafe_allow_html=True)
39
  with col2:
40
  if self.service.tts_mode:
41
  st.info(f"Using {self.service.tts_mode.upper()} TTS")
 
62
  st.write(message["content"])
63
  if message["role"] == "assistant" and voice_active:
64
  self.service.speak(message["content"])
65
+
66
+ # Refresh chat history
67
+ if st.button("Refresh Chat", key="refresh_chat"):
68
+ st.experimental_rerun()
69
 
70
  # Chat input
71
  if prompt := st.text_input("Ask your question...", key="chat_input"):
 
88
  "role": "assistant",
89
  "content": response,
90
  "speak": True
91
+ })
92
+
93
+ # Refresh chat history
94
+ st.experimental_rerun()