Spaces:
Running
Running
File size: 5,230 Bytes
33edad8 3da013f 33edad8 3da013f 33edad8 3da013f 41ccc35 ed0b3e6 33edad8 f72b772 ed0b3e6 f72b772 ed0b3e6 41ccc35 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 41ccc35 ed0b3e6 f72b772 ed0b3e6 41ccc35 ed0b3e6 41ccc35 ed0b3e6 f72b772 ed0b3e6 33edad8 f72b772 ed0b3e6 33edad8 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 41ccc35 ed0b3e6 41ccc35 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 33edad8 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 59a7139 ed0b3e6 41ccc35 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 8c44a70 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 ed0b3e6 f72b772 33edad8 7d5fe90 33edad8 7d5fe90 33edad8 7d5fe90 33edad8 7d5fe90 f72b772 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
import gradio as gr
from chatbot import respond
def chat_respond(message, history):
response = respond(message)
history.append(f"User: {message}")
history.append(f"Kossistant: {response}")
return format_history(history), history, ""
def format_history(history):
html = "<div class='chat-container'>"
for i in range(0, len(history) - 1, 2):
user = history[i].replace("User: ", "")
bot = history[i+1].replace("Kossistant: ", "")
html += f"""
<div class='message user'>
<div class='bubble user-bubble'>{user}</div>
</div>
<div class='message bot'>
<div class='bubble bot-bubble'>{bot}</div>
</div>
"""
html += "</div>"
return html
import gradio as gr
with gr.Blocks(css="""
* {
box-sizing: border-box;
margin: 0;
padding: 0;
transition: all 0.3s ease;
}
body {
background-color: #121212;
color: #ffffff;
font-family: 'Roboto', sans-serif;
overflow: hidden;
padding: 0;
margin: 0;
}
h1 {
font-size: 3rem;
color: #00f7ff;
text-align: center;
margin-top: 40px;
text-transform: uppercase;
letter-spacing: 3px;
animation: glowingText 1.5s infinite alternate;
}
.chat-container {
background-color: #1a1a1a;
border-radius: 20px;
max-width: 850px;
margin: auto;
padding: 30px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
height: 70vh;
display: flex;
flex-direction: column;
justify-content: flex-end;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #444 #1a1a1a;
}
.chat-container::-webkit-scrollbar {
width: 6px;
}
.chat-container::-webkit-scrollbar-thumb {
background-color: #444;
border-radius: 4px;
}
.chat-wrapper {
display: flex;
flex-direction: column;
gap: 10px;
flex-grow: 1;
}
.message {
display: flex;
margin-bottom: 20px;
animation: slideIn 0.5s ease-out;
}
.user {
justify-content: flex-end;
}
.bot {
justify-content: flex-start;
}
.bubble {
max-width: 75%;
padding: 16px;
border-radius: 18px;
font-size: 1rem;
line-height: 1.6;
word-break: break-word;
white-space: pre-wrap;
position: relative;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
transition: transform 0.2s ease, background-color 0.3s ease;
}
.user-bubble {
background-color: #00796B;
color: white;
border-bottom-right-radius: 0;
}
.bot-bubble {
background-color: #2F3136;
color: white;
border-bottom-left-radius: 0;
}
.bot-bubble:after {
content: '';
position: absolute;
left: -8px;
top: 10px;
border: 6px solid transparent;
border-right-color: #2F3136;
}
.user-bubble:after {
content: '';
position: absolute;
right: -8px;
top: 10px;
border: 6px solid transparent;
border-left-color: #00796B;
}
.bubble:hover {
transform: scale(1.05);
}
.input-row {
display: flex;
gap: 10px;
margin-top: 15px;
}
textarea, input[type="text"] {
background-color: #2C2C2C;
color: black; /* ν
μ€νΈ μμ κ²μμμΌλ‘ μμ */
border: 1px solid #555;
border-radius: 14px;
padding: 12px 16px;
font-size: 1rem;
flex-grow: 1;
}
textarea:focus, input[type="text"]:focus {
outline: none;
border-color: #00f7ff;
box-shadow: 0 0 8px #00f7ff55;
}
button {
background-color: #00C896;
color: white;
font-weight: bold;
border: none;
border-radius: 14px;
padding: 14px 20px;
font-size: 1.2rem;
transition: background-color 0.3s ease, transform 0.2s ease;
}
button:hover {
background-color: #00a67e;
transform: scale(1.05) rotate(2deg);
}
@keyframes glowingText {
0% { text-shadow: 0 0 10px #00f7ff, 0 0 20px #00f7ff, 0 0 30px #00f7ff; }
50% { text-shadow: 0 0 20px #00f7ff, 0 0 40px #00f7ff, 0 0 60px #00f7ff; }
100% { text-shadow: 0 0 10px #00f7ff, 0 0 20px #00f7ff, 0 0 30px #00f7ff; }
}
@keyframes slideIn {
0% { transform: translateY(10px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
""") as demo:
gr.HTML("<h1>Kossistant μ±λ΄</h1>")
with gr.Column(elem_classes="chat-wrapper"):
chatbox = gr.HTML(value="", label="λν")
with gr.Row():
msg = gr.Textbox(placeholder="λ©μμ§λ₯Ό μ
λ ₯νμΈμ", lines=1, scale=8)
send_button = gr.Button("μ μ‘", scale=2)
state = gr.State([])
send_button.click(chat_respond, inputs=[msg, state], outputs=[chatbox, state, msg])
msg.submit(chat_respond, inputs=[msg, state], outputs=[chatbox, state, msg])
demo.launch(share=True)
|