riabayonaor commited on
Commit
8fed2af
1 Parent(s): 148d193

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -2,13 +2,13 @@
2
  from transformers import pipeline
3
  import gradio as gr
4
 
5
- # Crear la pipeline de generación de texto con el modelo español
6
  pipe = pipeline("text-generation", model="datificate/gpt2-small-spanish")
7
 
8
- # Función que el chatbot utilizará para responder
9
  def chatbot_response(prompt):
10
- # Genera la respuesta del modelo
11
- result = pipe(prompt, max_length=50)
12
  # Retorna solo el texto de la respuesta generada
13
  return result[0]['generated_text']
14
 
@@ -18,8 +18,9 @@ iface = gr.Interface(
18
  inputs="text",
19
  outputs="text",
20
  title="Chatbot en Español",
21
- description="Este chatbot responde a tus preguntas. Está basado en el modelo GPT-2 pequeño en español."
 
22
  )
23
 
24
- # Lanzar la interfaz
25
- iface.launch()
 
2
  from transformers import pipeline
3
  import gradio as gr
4
 
5
+ # Crear la pipeline de generación de texto con el modelo español especificado
6
  pipe = pipeline("text-generation", model="datificate/gpt2-small-spanish")
7
 
8
+ # Función que el chatbot utilizará para responder a los prompts
9
  def chatbot_response(prompt):
10
+ # Genera la respuesta del modelo, activando explícitamente el truncamiento
11
+ result = pipe(prompt, max_length=50, truncation=True)
12
  # Retorna solo el texto de la respuesta generada
13
  return result[0]['generated_text']
14
 
 
18
  inputs="text",
19
  outputs="text",
20
  title="Chatbot en Español",
21
+ description="Este chatbot responde a tus preguntas. Está basado en el modelo GPT-2 pequeño en español.",
22
+ theme="default" # Puedes cambiar el tema de la interfaz si lo deseas
23
  )
24
 
25
+ # Lanzar la interfaz, activando la opción para compartir si se desea un enlace público
26
+ iface.launch(share=True)