adride00 commited on
Commit
45c4182
·
1 Parent(s): 535ccc5

Update app.py to improve the answer function with enhanced documentation and a more coherent response format. Adjust the Gradio interface description for consistency and set a default concurrency limit for the queue method to optimize performance.

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -1,17 +1,22 @@
1
- # app.py versión 100 % funcional
2
  import gradio as gr
3
- import random
4
- import datetime
5
 
6
  def answer(message: str, history: list):
7
- """Devuelve un saludo simple con la fecha actual."""
8
- return f"({datetime.date.today()}) Gracias por tu pregunta. {random.choice(['¡Claro!', 'Por supuesto!'])}"
 
 
 
 
 
 
9
 
10
  demo = gr.ChatInterface(
11
  fn=answer,
12
  title="IA de Cikode",
13
- description="Haz cualquier pregunta sobre automatización o ecommerce.",
14
- chatbot=gr.Chatbot(type="messages")
15
  )
16
 
17
- demo.queue().launch() # la cola evita errores bajo carga
 
1
+ # app.py versión estable abril-2025
2
  import gradio as gr
3
+ import random, datetime
 
4
 
5
  def answer(message: str, history: list):
6
+ """
7
+ Responde con la fecha + saludo.
8
+ Con type='messages' basta devolver un str
9
+ (Gradio lo envolverá en {'role':'assistant','content':...}).
10
+ """
11
+ today = datetime.date.today()
12
+ saludo = random.choice(["¡Claro!", "Por supuesto!"])
13
+ return f"({today}) Gracias por tu pregunta. {saludo}"
14
 
15
  demo = gr.ChatInterface(
16
  fn=answer,
17
  title="IA de Cikode",
18
+ description="Haz cualquier pregunta sobre automatización o e-commerce.",
19
+ type="messages" # ◀── formato coherente
20
  )
21
 
22
+ demo.queue(default_concurrency_limit=1).launch() # ◀── nuevo nombre del parámetro