HydroFlyer53 commited on
Commit
68bbad9
·
verified ·
1 Parent(s): 4f0e6ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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
- return [{"role": "assistant", "content": result}]
 
 
30
  else:
31
- return [{"role": "assistant", "content": "Sorry, I couldn't generate a response."}]
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
+