salomonsky commited on
Commit
89ff019
·
verified ·
1 Parent(s): 3071bcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -4,7 +4,7 @@ from gtts import gTTS
4
  import base64
5
 
6
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
7
- system_prompt = "Tu nombre es Chaman 3.0 una IA conductual"
8
  system_prompt_sent = False
9
 
10
  def format_prompt(message, history):
@@ -59,19 +59,17 @@ def generate(
59
  audio_file_path = text_to_speech(response)
60
  audio_file = open(audio_file_path, 'rb')
61
  audio_bytes = audio_file.read()
62
- st.markdown(
63
- f"""
64
- <audio autoplay="autoplay" controls="controls" src="data:audio/mp3;base64,{base64.b64encode(audio_bytes).decode()}" type="audio/mp3" speed="1.5" id="audio_player"></audio>
65
- """,
66
- unsafe_allow_html=True
67
- )
68
- return response
69
-
70
- def history_chat(history):
71
- st.container()
72
  with st.container():
73
- st.text_area("Salida del Chatbot", value="Aquí aparecerá la salida del chatbot...", height=200, max_chars=500, key="output_text", disabled=True)
74
 
 
 
 
 
 
 
 
75
  for user_prompt, bot_response in history:
76
  st.write(f"Usuario: {user_prompt}")
77
  st.write(f"Respuesta: {bot_response}")
@@ -84,4 +82,5 @@ user_input = st.text_input(label="Usuario", value="")
84
  output = generate(user_input, history=st.session_state.history)
85
  st.session_state.history.append((user_input, output))
86
 
87
- history_chat(st.session_state.history)
 
 
4
  import base64
5
 
6
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
7
+ system_prompt = "Tu nombre será Chaman 3.0 una IA conductual."
8
  system_prompt_sent = False
9
 
10
  def format_prompt(message, history):
 
59
  audio_file_path = text_to_speech(response)
60
  audio_file = open(audio_file_path, 'rb')
61
  audio_bytes = audio_file.read()
62
+
 
 
 
 
 
 
 
 
 
63
  with st.container():
64
+ st.text_area("Salida del Chatbot", value=response, height=200, max_chars=500, key="output_text", disabled=True)
65
 
66
+ st.markdown(
67
+ f"""
68
+ <audio autoplay="autoplay" controls="controls" src="data:audio/mp3;base64,{base64.b64encode(audio_bytes).decode()}" type="audio/mp3" speed="1.5" id="audio_player"></audio>
69
+ """,
70
+ unsafe_allow_html=True
71
+ )
72
+
73
  for user_prompt, bot_response in history:
74
  st.write(f"Usuario: {user_prompt}")
75
  st.write(f"Respuesta: {bot_response}")
 
82
  output = generate(user_input, history=st.session_state.history)
83
  st.session_state.history.append((user_input, output))
84
 
85
+ with st.container():
86
+ history_chat(st.session_state.history)