Spaces:
Build error
Build error
artificialguybr
commited on
Commit
•
a2adb84
1
Parent(s):
e3457ad
Update app.py
Browse files
app.py
CHANGED
@@ -105,6 +105,20 @@ def reset_user_input():
|
|
105 |
def reset_state(task_history):
|
106 |
task_history.clear()
|
107 |
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
with gr.Blocks() as demo:
|
110 |
gr.Markdown("<center><font size=8>Qwen-VL-Chat Bot</center>")
|
@@ -125,5 +139,7 @@ with gr.Blocks() as demo:
|
|
125 |
)
|
126 |
submit_btn.click(reset_user_input, [], [query])
|
127 |
empty_bin.click(reset_state, [task_history], [chatbot], show_progress=True)
|
|
|
|
|
128 |
|
129 |
demo.launch()
|
|
|
105 |
def reset_state(task_history):
|
106 |
task_history.clear()
|
107 |
return []
|
108 |
+
|
109 |
+
def regenerate(_chatbot, task_history):
|
110 |
+
if not task_history:
|
111 |
+
return _chatbot
|
112 |
+
item = task_history[-1]
|
113 |
+
if item[1] is None:
|
114 |
+
return _chatbot
|
115 |
+
task_history[-1] = (item[0], None)
|
116 |
+
chatbot_item = _chatbot.pop(-1)
|
117 |
+
if chatbot_item[0] is None:
|
118 |
+
_chatbot[-1] = (_chatbot[-1][0], None)
|
119 |
+
else:
|
120 |
+
_chatbot.append((chatbot_item[0], None))
|
121 |
+
return predict(_chatbot, task_history)
|
122 |
|
123 |
with gr.Blocks() as demo:
|
124 |
gr.Markdown("<center><font size=8>Qwen-VL-Chat Bot</center>")
|
|
|
139 |
)
|
140 |
submit_btn.click(reset_user_input, [], [query])
|
141 |
empty_bin.click(reset_state, [task_history], [chatbot], show_progress=True)
|
142 |
+
regen_btn.click(regenerate, [chatbot, task_history], [chatbot], show_progress=True)
|
143 |
+
addfile_btn.upload(add_file, [chatbot, task_history, addfile_btn], [chatbot, task_history], show_progress=True)
|
144 |
|
145 |
demo.launch()
|