JairoCesar commited on
Commit
491e5e8
verified
1 Parent(s): 7303bec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -4,13 +4,13 @@ from huggingface_hub import InferenceClient
4
  # Initialize the client
5
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
6
 
7
- # Function to format the prompt
8
  def format_prompt(message, history):
9
  prompt = "<s>"
10
  for user_prompt, bot_response in history:
11
  prompt += f"[INST] {user_prompt} [/INST]"
12
  prompt += f" {bot_response} "
13
- prompt += f"[INST] {message} [/INST]"
14
  return prompt
15
 
16
  # Function to generate response
@@ -36,24 +36,23 @@ def generate(prompt, history, temperature=0.3, max_new_tokens=256, top_p=0.95, r
36
  return output
37
 
38
  # Streamlit interface
39
- st.title("Preguntale al Buho")
40
 
41
  # Chat history
42
  if 'history' not in st.session_state:
43
  st.session_state.history = []
44
 
45
  # User input
46
- Entrada_usuario = st.text_input("Tu duda:", key="Entrada_usuario")
47
 
48
  # Generate response and update history
49
  if st.button("Enviar"):
50
- if Entrada_usuario:
51
- bot_response = generate(Entrada_usuario, st.session_state.history)
52
- st.session_state.history.append((Entrada_usuario, bot_response))
53
- # st.session_state.user_input = ""
54
 
55
  # Display conversation
56
  chat_text = ""
57
  for user_msg, bot_msg in st.session_state.history:
58
- chat_text += f"Tu: {user_msg}\nBuhIA: {bot_msg}\n\n"
59
- st.text_area("La respuesta", value=chat_text, height=300, disabled=False)
 
4
  # Initialize the client
5
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
6
 
7
+ # Function to format the prompt for Rorschach interpretation
8
  def format_prompt(message, history):
9
  prompt = "<s>"
10
  for user_prompt, bot_response in history:
11
  prompt += f"[INST] {user_prompt} [/INST]"
12
  prompt += f" {bot_response} "
13
+ prompt += f"[INST] Interpretaci贸n Rorschach: {message} [/INST]"
14
  return prompt
15
 
16
  # Function to generate response
 
36
  return output
37
 
38
  # Streamlit interface
39
+ st.title("Interpretaci贸n del Test de Rorschach")
40
 
41
  # Chat history
42
  if 'history' not in st.session_state:
43
  st.session_state.history = []
44
 
45
  # User input
46
+ entrada_usuario = st.text_input("Tu interpretaci贸n del Rorschach:", key="entrada_usuario")
47
 
48
  # Generate response and update history
49
  if st.button("Enviar"):
50
+ if entrada_usuario:
51
+ bot_response = generate(entrada_usuario, st.session_state.history)
52
+ st.session_state.history.append((entrada_usuario, bot_response))
 
53
 
54
  # Display conversation
55
  chat_text = ""
56
  for user_msg, bot_msg in st.session_state.history:
57
+ chat_text += f"Tu: {user_msg}\nPsic贸logo: {bot_msg}\n\n"
58
+ st.text_area("Respuestas del Psic贸logo", value=chat_text, height=300, disabled=False)