Update app.py
Browse files
app.py
CHANGED
|
@@ -81,7 +81,7 @@ def chat_with_groq(message, history, model, temperature, system_prompt):
|
|
| 81 |
with gr.Blocks() as demo:
|
| 82 |
sidebar_state = gr.State(False)
|
| 83 |
|
| 84 |
-
# Header Section
|
| 85 |
with gr.Row():
|
| 86 |
with gr.Column(scale=20):
|
| 87 |
gr.Markdown("# 🌿🤖 SageBot")
|
|
@@ -117,6 +117,8 @@ with gr.Blocks() as demo:
|
|
| 117 |
lines=1,
|
| 118 |
elem_id="system-prompt-container"
|
| 119 |
)
|
|
|
|
|
|
|
| 120 |
|
| 121 |
# LinkedIn Support
|
| 122 |
gr.HTML("""
|
|
@@ -128,7 +130,7 @@ with gr.Blocks() as demo:
|
|
| 128 |
</div>
|
| 129 |
""")
|
| 130 |
|
| 131 |
-
# Sidebar Toggle
|
| 132 |
def toggle_sidebar(current_state):
|
| 133 |
new_state = not current_state
|
| 134 |
return gr.update(visible=new_state), new_state
|
|
@@ -149,14 +151,16 @@ with gr.Blocks() as demo:
|
|
| 149 |
hist[-1]["content"] = chunk
|
| 150 |
yield hist
|
| 151 |
|
|
|
|
| 152 |
msg_input.submit(user_turn, [msg_input, chatbot], [msg_input, chatbot], queue=False).then(
|
| 153 |
bot_turn, [chatbot, model_choice, temp, sys_msg], chatbot
|
| 154 |
)
|
| 155 |
submit_btn.click(user_turn, [msg_input, chatbot], [msg_input, chatbot], queue=False).then(
|
| 156 |
bot_turn, [chatbot, model_choice, temp, sys_msg], chatbot
|
| 157 |
)
|
| 158 |
-
|
|
|
|
| 159 |
|
| 160 |
-
#
|
| 161 |
if __name__ == "__main__":
|
| 162 |
demo.launch(css=custom_css)
|
|
|
|
| 81 |
with gr.Blocks() as demo:
|
| 82 |
sidebar_state = gr.State(False)
|
| 83 |
|
| 84 |
+
# Header Section
|
| 85 |
with gr.Row():
|
| 86 |
with gr.Column(scale=20):
|
| 87 |
gr.Markdown("# 🌿🤖 SageBot")
|
|
|
|
| 117 |
lines=1,
|
| 118 |
elem_id="system-prompt-container"
|
| 119 |
)
|
| 120 |
+
# Re-added the clear button to fix your event logic
|
| 121 |
+
clear_btn = gr.Button("Clear Chat", variant="stop", min_width=100)
|
| 122 |
|
| 123 |
# LinkedIn Support
|
| 124 |
gr.HTML("""
|
|
|
|
| 130 |
</div>
|
| 131 |
""")
|
| 132 |
|
| 133 |
+
# Sidebar Toggle Logic
|
| 134 |
def toggle_sidebar(current_state):
|
| 135 |
new_state = not current_state
|
| 136 |
return gr.update(visible=new_state), new_state
|
|
|
|
| 151 |
hist[-1]["content"] = chunk
|
| 152 |
yield hist
|
| 153 |
|
| 154 |
+
# Link Actions
|
| 155 |
msg_input.submit(user_turn, [msg_input, chatbot], [msg_input, chatbot], queue=False).then(
|
| 156 |
bot_turn, [chatbot, model_choice, temp, sys_msg], chatbot
|
| 157 |
)
|
| 158 |
submit_btn.click(user_turn, [msg_input, chatbot], [msg_input, chatbot], queue=False).then(
|
| 159 |
bot_turn, [chatbot, model_choice, temp, sys_msg], chatbot
|
| 160 |
)
|
| 161 |
+
# Linked to clear_btn
|
| 162 |
+
clear_btn.click(lambda: [], None, chatbot, queue=False)
|
| 163 |
|
| 164 |
+
# Final Launch
|
| 165 |
if __name__ == "__main__":
|
| 166 |
demo.launch(css=custom_css)
|