salomonsky commited on
Commit
1723905
·
verified ·
1 Parent(s): 892e78b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
app.py CHANGED
@@ -5,9 +5,8 @@ import base64
5
  from pydub import AudioSegment
6
  from pydub.playback import play
7
 
8
- st.sidebar.width = 100
9
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
10
- pre_prompt = "Te llamarás Xaman 3.0 (NO LO REPITAS) tu rol como IA conductual, tus principios son: existencialismo estóico y holístico."
11
  pre_prompt_sent = False
12
 
13
  def format_prompt(message, history):
@@ -35,7 +34,7 @@ def text_to_speech(text, speed=1.3):
35
 
36
  return audio_file_path
37
 
38
- def generate(user_input, history, temperature=None, max_new_tokens=512, top_p=0.95, repetition_penalty=1.0):
39
  global pre_prompt_sent
40
  temperature = float(temperature) if temperature is not None else 0.9
41
  if temperature < 1e-2:
@@ -69,22 +68,13 @@ def generate(user_input, history, temperature=None, max_new_tokens=512, top_p=0.
69
  if "history" not in st.session_state:
70
  st.session_state.history = []
71
 
72
- if st.session_state.history:
73
- user_input = st.session_state.history[-1][0]
74
- output, audio_bytes = generate(user_input, history=st.session_state.history)
75
- st.session_state.history[-1] = (user_input, output)
76
- else:
77
- output, audio_bytes = "", ""
78
-
79
- for user, output in st.session_state.history:
80
- st.text_area(f"{user}: ", value=output, height=400, key=f"{user}_output", disabled=True)
81
-
82
- user_input = st.text_input(label="Ingresa tu mensaje", value="")
83
 
84
  if user_input:
85
- output, audio_bytes = generate(user_input, history=st.session_state.history)
86
- output_area = st.empty()
87
- output_area.text_area(f"{user_input}: ", value=output, height=100, key=f"{user_input}_output", disabled=True)
 
88
 
89
  st.markdown(
90
  f"""
 
5
  from pydub import AudioSegment
6
  from pydub.playback import play
7
 
 
8
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
9
+ pre_prompt = "Tu nombre será Chaman 3.0 una IA conductual, hablarás español tu rol es la bioética y el estoicismo holístico."
10
  pre_prompt_sent = False
11
 
12
  def format_prompt(message, history):
 
34
 
35
  return audio_file_path
36
 
37
+ def generate(user_input, history, temperature=None, max_new_tokens=1024, top_p=0.95, repetition_penalty=1.0):
38
  global pre_prompt_sent
39
  temperature = float(temperature) if temperature is not None else 0.9
40
  if temperature < 1e-2:
 
68
  if "history" not in st.session_state:
69
  st.session_state.history = []
70
 
71
+ output, audio_bytes = generate(user_input, history=st.session_state.history)
 
 
 
 
 
 
 
 
 
 
72
 
73
  if user_input:
74
+ st.session_state.history.append((user_input, output))
75
+
76
+ user_input = st.text_input(label="", value="")
77
+ st.text_area("Respuesta del Chatbot", value=output, height=400, key="output_text", disabled=True)
78
 
79
  st.markdown(
80
  f"""