Spaces:
Paused
Paused
Fix undo button
Browse files- Tabs/Gemini_Chabot_Stable.py +9 -1
- app.py +4 -1
Tabs/Gemini_Chabot_Stable.py
CHANGED
|
@@ -64,6 +64,9 @@ chat = model.start_chat(history=[])
|
|
| 64 |
|
| 65 |
def clear_chat_history():
|
| 66 |
chat.history = []
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
def transform_history(history):
|
| 69 |
new_history = []
|
|
@@ -103,9 +106,14 @@ clear_chat_button = gr.ClearButton(
|
|
| 103 |
value="🗑️ Clear"
|
| 104 |
)
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
gemini_chatbot = gr.ChatInterface(
|
| 107 |
fn=chatbot_stable,
|
| 108 |
chatbot=gemini_chatbot_interface,
|
| 109 |
multimodal=True,
|
| 110 |
-
clear_btn=clear_chat_button
|
|
|
|
| 111 |
)
|
|
|
|
| 64 |
|
| 65 |
def clear_chat_history():
|
| 66 |
chat.history = []
|
| 67 |
+
|
| 68 |
+
def undo_chat():
|
| 69 |
+
last_send, last_received = chat.rewind()
|
| 70 |
|
| 71 |
def transform_history(history):
|
| 72 |
new_history = []
|
|
|
|
| 106 |
value="🗑️ Clear"
|
| 107 |
)
|
| 108 |
|
| 109 |
+
undo_chat_button = gr.Button(
|
| 110 |
+
value="↩️ Undo"
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
gemini_chatbot = gr.ChatInterface(
|
| 114 |
fn=chatbot_stable,
|
| 115 |
chatbot=gemini_chatbot_interface,
|
| 116 |
multimodal=True,
|
| 117 |
+
clear_btn=clear_chat_button,
|
| 118 |
+
undo_btn=undo_chat_button
|
| 119 |
)
|
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from Tabs.Gemini_Chabot_Stable import gemini_chatbot, clear_chat_button, clear_chat_history, TITLE, NOTICE, ERRORS, FUTURE_IMPLEMENTATIONS, ABOUT
|
| 3 |
|
| 4 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 5 |
# ============================== Stable - START ==============================
|
|
@@ -14,6 +14,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 14 |
clear_chat_button.click(
|
| 15 |
fn=clear_chat_history
|
| 16 |
)
|
|
|
|
|
|
|
|
|
|
| 17 |
# ============================== Stable - END ==============================
|
| 18 |
|
| 19 |
with gr.Tab("Chat with Gemma 2"):
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from Tabs.Gemini_Chabot_Stable import gemini_chatbot, clear_chat_button, undo_chat_button, clear_chat_history, undo_chat, TITLE, NOTICE, ERRORS, FUTURE_IMPLEMENTATIONS, ABOUT
|
| 3 |
|
| 4 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 5 |
# ============================== Stable - START ==============================
|
|
|
|
| 14 |
clear_chat_button.click(
|
| 15 |
fn=clear_chat_history
|
| 16 |
)
|
| 17 |
+
undo_chat_button.click(
|
| 18 |
+
fn=undo_chat
|
| 19 |
+
)
|
| 20 |
# ============================== Stable - END ==============================
|
| 21 |
|
| 22 |
with gr.Tab("Chat with Gemma 2"):
|