DanilNikolin commited on
Commit
953b312
·
verified ·
1 Parent(s): a91cf53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -11,7 +11,11 @@ def query(payload):
11
 
12
  def chatbot(input_text):
13
  response = query({"inputs": input_text})
14
- return response[0]['generated_text']
 
 
 
 
15
 
16
  demo = gr.Interface(fn=chatbot, inputs="text", outputs="text")
17
  demo.launch()
 
11
 
12
  def chatbot(input_text):
13
  response = query({"inputs": input_text})
14
+ print(response) # Выводим ответ от API в консоль для отладки
15
+ try:
16
+ return response[0]['generated_text']
17
+ except (KeyError, IndexError):
18
+ return "Error: Unable to generate text. Please try again."
19
 
20
  demo = gr.Interface(fn=chatbot, inputs="text", outputs="text")
21
  demo.launch()