Update app.py
Browse files
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:
|
50 |
-
chatbot[-1][1]
|
51 |
for i in range(len(response_text)):
|
52 |
-
chatbot[-1][1]
|
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:
|
62 |
-
) -> Tuple[
|
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(
|
113 |
-
gr.HTML(
|
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 |
+
|