Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,16 +26,19 @@ def chat_with_ai(message, history):
|
|
26 |
|
27 |
# Check if result is valid and return the response in the correct format
|
28 |
if result:
|
29 |
-
|
|
|
|
|
30 |
else:
|
31 |
-
return
|
32 |
-
|
33 |
except Exception as e:
|
34 |
print(f"Error during model prediction: {e}")
|
35 |
-
return [{"role": "assistant", "content": "There was an error processing your message."}]
|
36 |
|
37 |
# Gradio Chat Interface
|
38 |
-
demo = gr.ChatInterface(fn=chat_with_ai)
|
39 |
|
40 |
if __name__ == "__main__":
|
41 |
demo.launch()
|
|
|
|
26 |
|
27 |
# Check if result is valid and return the response in the correct format
|
28 |
if result:
|
29 |
+
# Append new message to history
|
30 |
+
history.append((message, result))
|
31 |
+
return history, history # Return updated history for display
|
32 |
else:
|
33 |
+
return history, history
|
34 |
+
|
35 |
except Exception as e:
|
36 |
print(f"Error during model prediction: {e}")
|
37 |
+
return history, [{"role": "assistant", "content": "There was an error processing your message."}]
|
38 |
|
39 |
# Gradio Chat Interface
|
40 |
+
demo = gr.ChatInterface(fn=chat_with_ai, allow_screenshot=False)
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
demo.launch()
|
44 |
+
|