Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,11 @@ def query(payload):
|
|
| 11 |
|
| 12 |
def chatbot(input_text):
|
| 13 |
response = query({"inputs": input_text})
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|