Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,15 +46,13 @@ body {
|
|
| 46 |
padding: 0;
|
| 47 |
color: #333;
|
| 48 |
}
|
| 49 |
-
|
| 50 |
@keyframes gradientBG {
|
| 51 |
0% { background-position: 0% 50%; }
|
| 52 |
50% { background-position: 100% 50%; }
|
| 53 |
100% { background-position: 0% 50%; }
|
| 54 |
}
|
| 55 |
-
|
| 56 |
button {
|
| 57 |
-
background: linear-gradient(90deg, #
|
| 58 |
color: white;
|
| 59 |
padding: 0.8rem 1.5rem;
|
| 60 |
font-size: 1rem;
|
|
@@ -64,12 +62,10 @@ button {
|
|
| 64 |
cursor: pointer;
|
| 65 |
transition: transform 0.2s ease, background 0.2s ease;
|
| 66 |
}
|
| 67 |
-
|
| 68 |
button:hover {
|
| 69 |
-
background: linear-gradient(90deg, #
|
| 70 |
transform: scale(1.1);
|
| 71 |
}
|
| 72 |
-
|
| 73 |
header {
|
| 74 |
text-align: center;
|
| 75 |
margin-bottom: 20px;
|
|
@@ -79,7 +75,6 @@ header {
|
|
| 79 |
color: white;
|
| 80 |
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
| 81 |
}
|
| 82 |
-
|
| 83 |
.chat-container {
|
| 84 |
border: 2px solid #ff7eb3;
|
| 85 |
background: rgba(255, 255, 255, 0.8);
|
|
@@ -105,21 +100,33 @@ with chat_interface:
|
|
| 105 |
with gr.Row():
|
| 106 |
send_button = gr.Button("Send")
|
| 107 |
with gr.Row():
|
| 108 |
-
|
|
|
|
| 109 |
|
| 110 |
-
chatbot_output = gr.Chatbot(label="Chat History")
|
| 111 |
-
|
| 112 |
# Add functionality to handle interactions
|
| 113 |
def handle_chat(user_input, category, history):
|
| 114 |
if not user_input.strip():
|
| 115 |
return history, history
|
| 116 |
updated_history, _ = chatbot(user_input, category, history)
|
| 117 |
return updated_history, updated_history
|
| 118 |
-
|
| 119 |
send_button.click(
|
| 120 |
handle_chat,
|
| 121 |
inputs=[user_input, category_dropdown, chatbot_output],
|
| 122 |
outputs=[chatbot_output, chatbot_output]
|
| 123 |
)
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
chat_interface.launch()
|
|
|
|
|
|
| 46 |
padding: 0;
|
| 47 |
color: #333;
|
| 48 |
}
|
|
|
|
| 49 |
@keyframes gradientBG {
|
| 50 |
0% { background-position: 0% 50%; }
|
| 51 |
50% { background-position: 100% 50%; }
|
| 52 |
100% { background-position: 0% 50%; }
|
| 53 |
}
|
|
|
|
| 54 |
button {
|
| 55 |
+
background: linear-gradient(90deg, #98c1d9, #ee9ca7);
|
| 56 |
color: white;
|
| 57 |
padding: 0.8rem 1.5rem;
|
| 58 |
font-size: 1rem;
|
|
|
|
| 62 |
cursor: pointer;
|
| 63 |
transition: transform 0.2s ease, background 0.2s ease;
|
| 64 |
}
|
|
|
|
| 65 |
button:hover {
|
| 66 |
+
background: linear-gradient(90deg, #ee9ca7, #98c1d9);
|
| 67 |
transform: scale(1.1);
|
| 68 |
}
|
|
|
|
| 69 |
header {
|
| 70 |
text-align: center;
|
| 71 |
margin-bottom: 20px;
|
|
|
|
| 75 |
color: white;
|
| 76 |
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
| 77 |
}
|
|
|
|
| 78 |
.chat-container {
|
| 79 |
border: 2px solid #ff7eb3;
|
| 80 |
background: rgba(255, 255, 255, 0.8);
|
|
|
|
| 100 |
with gr.Row():
|
| 101 |
send_button = gr.Button("Send")
|
| 102 |
with gr.Row():
|
| 103 |
+
chatbot_output = gr.Chatbot(label="Chat History")
|
| 104 |
+
copy_button = gr.Button("Copy Response")
|
| 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,
|
| 115 |
inputs=[user_input, category_dropdown, chatbot_output],
|
| 116 |
outputs=[chatbot_output, chatbot_output]
|
| 117 |
)
|
| 118 |
|
| 119 |
+
# Copy functionality
|
| 120 |
+
def copy_last_response(history):
|
| 121 |
+
if history:
|
| 122 |
+
return history[-1][1] # Returns the last bot response
|
| 123 |
+
return "No response to copy."
|
| 124 |
+
|
| 125 |
+
copy_button.click(
|
| 126 |
+
copy_last_response,
|
| 127 |
+
inputs=[chatbot_output],
|
| 128 |
+
outputs=[]
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
chat_interface.launch()
|
| 132 |
+
|