Yuchan5386 commited on
Commit
5409b76
ยท
verified ยท
1 Parent(s): 303424a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +99 -27
app.py CHANGED
@@ -8,70 +8,142 @@ def chat_respond(message, history):
8
  return format_history(history), history, ""
9
 
10
  def format_history(history):
11
- html = "<div style='padding: 16px;'>"
12
  for i in range(0, len(history) - 1, 2):
13
  user = history[i].replace("User: ", "")
14
  bot = history[i+1].replace("Kossistant: ", "")
15
  html += f"""
16
- <div style='margin-bottom: 20px;'>
17
- <div style='text-align: right;'>
18
- <span style='background-color:#0F9D58; color: white; padding:10px 14px;
19
- border-radius:20px; display:inline-block; max-width:75%;
20
- word-break: break-word;'>{user}</span>
21
- </div>
22
- <div style='text-align: left;'>
23
- <span style='background-color:#3C4043; color: white; padding:10px 14px;
24
- border-radius:20px; display:inline-block; max-width:75%;
25
- word-break: break-word;'>{bot}</span>
26
- </div>
27
  </div>
28
  """
29
  html += "</div>"
30
  return html
31
 
32
  with gr.Blocks(css="""
 
 
 
33
  body {
34
  background-color: #121212;
 
35
  color: white;
36
- font-family: 'Segoe UI', sans-serif;
 
37
  }
38
  .gradio-container {
39
  background-color: #121212 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  color: white;
 
41
  }
42
- .chat-wrapper {
43
- background-color: #1E1E1E;
44
- border-radius: 16px;
45
- padding: 20px;
46
- max-width: 720px;
47
- margin: 0 auto;
48
- margin-top: 40px;
49
- box-shadow: 0 0 10px rgba(0,0,0,0.4);
50
  }
51
  textarea, input[type="text"] {
52
  background-color: #2C2C2C !important;
53
  color: white !important;
54
  border: 1px solid #444 !important;
55
- border-radius: 10px !important;
56
- padding: 10px !important;
 
57
  }
58
  button {
59
  background-color: #0F9D58 !important;
60
  color: white !important;
61
  border: none !important;
62
- border-radius: 10px !important;
63
- padding: 10px 16px !important;
 
 
64
  }
65
  button:hover {
66
  background-color: #0c7a46 !important;
67
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  """) as demo:
 
 
69
 
70
- gr.HTML("<h1 style='text-align:center;'>Kossistant ์ฑ—๋ด‡</h1>")
71
  with gr.Column(elem_classes="chat-wrapper"):
72
  chatbox = gr.HTML(value="", label="๋Œ€ํ™”")
73
  with gr.Row():
74
- msg = gr.Textbox(placeholder="์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜์„ธ์š”", lines=1, scale=8)
75
  send_button = gr.Button("์ „์†ก", scale=2)
76
 
77
  state = gr.State([])
 
8
  return format_history(history), history, ""
9
 
10
  def format_history(history):
11
+ html = "<div class='chat-container'>"
12
  for i in range(0, len(history) - 1, 2):
13
  user = history[i].replace("User: ", "")
14
  bot = history[i+1].replace("Kossistant: ", "")
15
  html += f"""
16
+ <div class='message user'>
17
+ <div class='bubble user-bubble'>{user}</div>
18
+ </div>
19
+ <div class='message bot'>
20
+ <div class='bubble bot-bubble'>{bot}</div>
 
 
 
 
 
 
21
  </div>
22
  """
23
  html += "</div>"
24
  return html
25
 
26
  with gr.Blocks(css="""
27
+ * {
28
+ box-sizing: border-box;
29
+ }
30
  body {
31
  background-color: #121212;
32
+ font-family: 'Segoe UI', 'Pretendard', sans-serif;
33
  color: white;
34
+ margin: 0;
35
+ padding: 0;
36
  }
37
  .gradio-container {
38
  background-color: #121212 !important;
39
+ }
40
+ h1 {
41
+ text-align: center;
42
+ color: #00ffcc;
43
+ margin-top: 20px;
44
+ }
45
+ .chat-container {
46
+ padding: 16px;
47
+ display: flex;
48
+ flex-direction: column;
49
+ gap: 10px;
50
+ max-height: 70vh;
51
+ overflow-y: auto;
52
+ scroll-behavior: smooth;
53
+ }
54
+ .message {
55
+ display: flex;
56
+ flex-direction: column;
57
+ }
58
+ .user {
59
+ align-items: flex-end;
60
+ }
61
+ .bot {
62
+ align-items: flex-start;
63
+ }
64
+ .bubble {
65
+ max-width: 80%;
66
+ padding: 12px 16px;
67
+ border-radius: 20px;
68
+ line-height: 1.5;
69
+ word-wrap: break-word;
70
+ white-space: pre-wrap;
71
+ }
72
+ .user-bubble {
73
+ background-color: #0F9D58;
74
  color: white;
75
+ border-bottom-right-radius: 0;
76
  }
77
+ .bot-bubble {
78
+ background-color: #3C4043;
79
+ color: white;
80
+ border-bottom-left-radius: 0;
 
 
 
 
81
  }
82
  textarea, input[type="text"] {
83
  background-color: #2C2C2C !important;
84
  color: white !important;
85
  border: 1px solid #444 !important;
86
+ border-radius: 12px !important;
87
+ padding: 12px !important;
88
+ font-size: 1rem;
89
  }
90
  button {
91
  background-color: #0F9D58 !important;
92
  color: white !important;
93
  border: none !important;
94
+ border-radius: 12px !important;
95
+ padding: 12px 16px !important;
96
+ font-weight: bold;
97
+ font-size: 1rem;
98
  }
99
  button:hover {
100
  background-color: #0c7a46 !important;
101
  }
102
+ .chat-wrapper {
103
+ background-color: #1E1E1E;
104
+ border-radius: 20px;
105
+ padding: 20px;
106
+ max-width: 720px;
107
+ margin: 0 auto;
108
+ box-shadow: 0 0 12px rgba(0,0,0,0.5);
109
+ }
110
+ @media screen and (max-width: 768px) {
111
+ .chat-wrapper {
112
+ padding: 12px;
113
+ border-radius: 0;
114
+ }
115
+ .chat-container {
116
+ padding: 8px;
117
+ }
118
+ .bubble {
119
+ font-size: 0.95rem;
120
+ }
121
+ textarea, input[type="text"] {
122
+ font-size: 1rem !important;
123
+ }
124
+ button {
125
+ font-size: 1rem !important;
126
+ }
127
+ }
128
+ ::-webkit-scrollbar {
129
+ width: 6px;
130
+ }
131
+ ::-webkit-scrollbar-thumb {
132
+ background-color: #444;
133
+ border-radius: 3px;
134
+ }
135
+ ::selection {
136
+ background: #00b894;
137
+ color: white;
138
+ }
139
  """) as demo:
140
+
141
+ gr.HTML("<h1>Kossistant ์ฑ—๋ด‡</h1>")
142
 
 
143
  with gr.Column(elem_classes="chat-wrapper"):
144
  chatbox = gr.HTML(value="", label="๋Œ€ํ™”")
145
  with gr.Row():
146
+ msg = gr.Textbox(placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”", lines=1, scale=8)
147
  send_button = gr.Button("์ „์†ก", scale=2)
148
 
149
  state = gr.State([])