Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,19 +84,6 @@ header {
|
|
| 84 |
max-height: 300px;
|
| 85 |
overflow-y: auto;
|
| 86 |
}
|
| 87 |
-
.copy-btn {
|
| 88 |
-
margin-left: 5px;
|
| 89 |
-
background: #ff7eb3;
|
| 90 |
-
color: white;
|
| 91 |
-
border: none;
|
| 92 |
-
border-radius: 5px;
|
| 93 |
-
padding: 5px 10px;
|
| 94 |
-
cursor: pointer;
|
| 95 |
-
font-size: 0.9rem;
|
| 96 |
-
}
|
| 97 |
-
.copy-btn:hover {
|
| 98 |
-
background: #ff4f81;
|
| 99 |
-
}
|
| 100 |
""")
|
| 101 |
|
| 102 |
with chat_interface:
|
|
@@ -116,24 +103,12 @@ with chat_interface:
|
|
| 116 |
with gr.Column() as chat_container:
|
| 117 |
chatbot_output = gr.Chatbot(label="Chat History")
|
| 118 |
|
| 119 |
-
# Add copy-to-clipboard button
|
| 120 |
-
def add_copy_buttons(history):
|
| 121 |
-
enhanced_history = []
|
| 122 |
-
for user, bot in history:
|
| 123 |
-
copy_button = (
|
| 124 |
-
f'<button class="copy-btn" onclick="navigator.clipboard.writeText(`{bot}`)">Copy</button>'
|
| 125 |
-
)
|
| 126 |
-
bot_with_copy = f"{bot} {copy_button}"
|
| 127 |
-
enhanced_history.append((user, bot_with_copy))
|
| 128 |
-
return enhanced_history
|
| 129 |
-
|
| 130 |
# Add functionality to handle interactions
|
| 131 |
def handle_chat(user_input, category, history):
|
| 132 |
if not user_input.strip():
|
| 133 |
return history, history
|
| 134 |
updated_history, _ = chatbot(user_input, category, history)
|
| 135 |
-
|
| 136 |
-
return enhanced_history, enhanced_history
|
| 137 |
|
| 138 |
send_button.click(
|
| 139 |
handle_chat,
|
|
|
|
| 84 |
max-height: 300px;
|
| 85 |
overflow-y: auto;
|
| 86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
""")
|
| 88 |
|
| 89 |
with chat_interface:
|
|
|
|
| 103 |
with gr.Column() as chat_container:
|
| 104 |
chatbot_output = gr.Chatbot(label="Chat History")
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
# Add functionality to handle interactions
|
| 107 |
def handle_chat(user_input, category, history):
|
| 108 |
if not user_input.strip():
|
| 109 |
return history, history
|
| 110 |
updated_history, _ = chatbot(user_input, category, history)
|
| 111 |
+
return updated_history, updated_history
|
|
|
|
| 112 |
|
| 113 |
send_button.click(
|
| 114 |
handle_chat,
|