Mubbashir Ahmed commited on
Commit
445701c
·
1 Parent(s): dc55189

clearing texts

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -26,7 +26,7 @@ def format_chat_history(chat_history):
26
  # Main chat handler
27
  def chat_with_model(model_choice, prompt, image_url, chat_history):
28
  if not prompt:
29
- return "Please enter a text prompt.", chat_history
30
 
31
  if chat_history is None:
32
  chat_history = []
@@ -67,9 +67,9 @@ def chat_with_model(model_choice, prompt, image_url, chat_history):
67
  chat_history.append({"role": "assistant", "content": bot_msg})
68
 
69
  else:
70
- return "Unsupported model selected.", chat_history
71
 
72
- return format_chat_history(chat_history), chat_history
73
 
74
  except Exception as e:
75
  return f"Error: {e}", chat_history
@@ -100,13 +100,13 @@ with gr.Blocks() as demo:
100
  submit_btn.click(
101
  fn=chat_with_model,
102
  inputs=[model_dropdown, prompt_input, image_url_input, state],
103
- outputs=[output_box, state]
104
  )
105
 
106
  reset_btn.click(
107
- fn=lambda: ("🧹 Conversation reset. You can start a new one.", []),
108
  inputs=[],
109
- outputs=[output_box, state]
110
  )
111
 
112
  demo.launch()
 
26
  # Main chat handler
27
  def chat_with_model(model_choice, prompt, image_url, chat_history):
28
  if not prompt:
29
+ return "Please enter a text prompt.", chat_history, "", ""
30
 
31
  if chat_history is None:
32
  chat_history = []
 
67
  chat_history.append({"role": "assistant", "content": bot_msg})
68
 
69
  else:
70
+ return "Unsupported model selected.", chat_history, "", ""
71
 
72
+ return format_chat_history(chat_history), chat_history, "", ""
73
 
74
  except Exception as e:
75
  return f"Error: {e}", chat_history
 
100
  submit_btn.click(
101
  fn=chat_with_model,
102
  inputs=[model_dropdown, prompt_input, image_url_input, state],
103
+ outputs=[output_box, state, prompt_input, image_url_input]
104
  )
105
 
106
  reset_btn.click(
107
+ fn=lambda: ("🧹 Conversation reset. You can start a new one.", [], "", ""),
108
  inputs=[],
109
+ outputs=[output_box, state, prompt_input, image_url_input]
110
  )
111
 
112
  demo.launch()