JeCabrera commited on
Commit
b7ce1d8
·
verified ·
1 Parent(s): 4084737

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -46,10 +46,10 @@ def transform_history(history):
46
  return new_history
47
 
48
  # Función para simular el efecto de escribir carácter por carácter
49
- def display_typing_effect(response_text: str, chatbot: list) -> list:
50
- chatbot[-1][1] = "" # Borrar la última respuesta en el chatbot
51
  for i in range(len(response_text)):
52
- chatbot[-1][1] += response_text[i] # Agregar un carácter
53
  time.sleep(0.05) # Controlar la velocidad de escritura
54
  yield chatbot # Mostrar el progreso en el UI
55
 
@@ -58,8 +58,8 @@ def bot_response(
58
  model_choice: str,
59
  system_instruction: str,
60
  text_prompt: str,
61
- chatbot: list,
62
- ) -> Tuple[list, str]: # Aquí se usa Tuple correctamente
63
  """
64
  Envía el mensaje al modelo, obtiene la respuesta y actualiza el historial.
65
  """
@@ -109,8 +109,8 @@ system_instruction_component = gr.Textbox(
109
 
110
  # Definir la interfaz
111
  with gr.Blocks() as demo:
112
- gr.HTML(TITLE)
113
- gr.HTML(SUBTITLE)
114
  with gr.Column():
115
  model_dropdown_component.render()
116
  chatbot_component.render()
@@ -136,3 +136,4 @@ with gr.Blocks() as demo:
136
  # Lanzar la aplicación
137
  if __name__ == "__main__":
138
  demo.queue(max_size=99).launch(debug=True, show_error=True)
 
 
46
  return new_history
47
 
48
  # Función para simular el efecto de escribir carácter por carácter
49
+ def display_typing_effect(response_text: str, chatbot: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
50
+ chatbot[-1] = (chatbot[-1][0], "") # Borrar la última respuesta en el chatbot (se modifica correctamente)
51
  for i in range(len(response_text)):
52
+ chatbot[-1] = (chatbot[-1][0], chatbot[-1][1] + response_text[i]) # Modificar el texto de la respuesta
53
  time.sleep(0.05) # Controlar la velocidad de escritura
54
  yield chatbot # Mostrar el progreso en el UI
55
 
 
58
  model_choice: str,
59
  system_instruction: str,
60
  text_prompt: str,
61
+ chatbot: List[Tuple[str, str]], # Aseguramos que sea una lista
62
+ ) -> Tuple[List[Tuple[str, str]], str]: # Aquí se usa Tuple correctamente
63
  """
64
  Envía el mensaje al modelo, obtiene la respuesta y actualiza el historial.
65
  """
 
109
 
110
  # Definir la interfaz
111
  with gr.Blocks() as demo:
112
+ gr.HTML("<h1 align='center'>Gemini Playground ✨</h1>")
113
+ gr.HTML("<h2 align='center'>Play with Gemini Pro and Gemini Pro Vision</h2>")
114
  with gr.Column():
115
  model_dropdown_component.render()
116
  chatbot_component.render()
 
136
  # Lanzar la aplicación
137
  if __name__ == "__main__":
138
  demo.queue(max_size=99).launch(debug=True, show_error=True)
139
+