hexanovapixel commited on
Commit
00acfcf
·
verified ·
1 Parent(s): 7a3ee34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -14,13 +14,16 @@ def respond(message, history):
14
  return "Ask me something 😊"
15
 
16
  output = query({
17
- "inputs": "Explain in Spanish like a fun and friendly teacher who uses simple words: " + message
18
  })
19
 
20
- try:
 
21
  return output[0]["generated_text"]
22
- except:
23
- return "Error 😭 try again"
 
 
24
 
25
  demo = gr.ChatInterface(fn=respond)
26
 
 
14
  return "Ask me something 😊"
15
 
16
  output = query({
17
+ "inputs": "Explain clearly in Spanish like a friendly tutor: " + message
18
  })
19
 
20
+ # 🔥 MANEJO DE ERRORES BIEN HECHO
21
+ if isinstance(output, list) and "generated_text" in output[0]:
22
  return output[0]["generated_text"]
23
+ elif isinstance(output, dict) and "error" in output:
24
+ return "La IA está cargando o hubo un error 😭 intenta otra vez"
25
+ else:
26
+ return str(output)
27
 
28
  demo = gr.ChatInterface(fn=respond)
29