SamiKoen commited on
Commit
f30965b
·
verified ·
1 Parent(s): 8b61968

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -36
app.py CHANGED
@@ -26,7 +26,6 @@ for item in root.findall('item'):
26
  # name: ilk kelime (marka), item_info: (stok durumu, fiyat)
27
  products.append((name, item_info, full_name))
28
 
29
-
30
  def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
31
  headers = {
32
  "Content-Type": "application/json",
@@ -97,75 +96,86 @@ def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=[], hi
97
  token_counter += 1
98
  yield chat, history, chat_counter, response
99
 
100
-
101
  def reset_textbox():
102
  return gr.update(value='')
103
 
104
-
105
  def set_visible_false():
106
  return gr.update(visible=False)
107
 
108
-
109
  def set_visible_true():
110
  return gr.update(visible=False)
111
 
112
-
113
- # WhatsApp tarzı görünüm için özel CSS
114
  css = """
115
- /* Chat Başlığı: WhatsApp koyu yeşili */
116
  .chat-header {
117
- background-color: #075e54;
118
- color: #fff;
119
  padding: 15px;
120
  text-align: center;
121
- font-size: 20px;
122
- font-weight: bold;
 
123
  }
124
 
125
- /* Chat penceresi: arka plan rengi */
126
  #chatbot {
127
- background-color: #ece5dd;
128
  border: none;
129
- padding: 10px;
130
  }
131
 
132
- /* Kullanıcı mesajı (sağa hizalı, açık yeşil) */
133
  .chat-bubble.user {
134
- background-color: #dcf8c6 !important;
135
  align-self: flex-end;
136
- border-radius: 20px;
137
- padding: 10px 15px;
138
  margin: 8px 0;
139
  max-width: 70%;
140
- word-wrap: break-word;
 
 
141
  }
142
 
143
- /* Bot mesajı (sola hizalı, beyaz) */
144
  .chat-bubble.bot {
145
- background-color: #fff !important;
146
  align-self: flex-start;
147
- border: 1px solid #ccc;
148
- border-radius: 20px;
149
- padding: 10px 15px;
150
  margin: 8px 0;
151
  max-width: 70%;
152
- word-wrap: break-word;
 
 
153
  }
154
 
155
- /* Mesaj gönderme alanı */
156
  .chat-input-container {
157
  display: flex;
158
- padding: 10px;
159
- border-top: 1px solid #ddd;
160
- background-color: #f0f0f0;
 
 
 
 
 
 
 
 
 
 
161
  }
162
 
163
- /* Gönder butonu */
164
  .send-button {
165
- background-color: #075e54;
166
  border: none;
167
  color: #fff;
168
- padding: 10px 15px;
169
  margin-left: 10px;
170
  border-radius: 20px;
171
  font-size: 16px;
@@ -173,15 +183,15 @@ css = """
173
  }
174
  """
175
 
176
- # Tema ayarını güncelliyoruz: neutral_hue 'green' ile WhatsApp benzeri yeşil ton
177
  theme = gr.themes.Base(
178
- neutral_hue="green",
179
  text_size="sm",
180
  spacing_size="sm",
181
  )
182
 
183
  with gr.Blocks(theme=theme, css=css) as demo:
184
- # WhatsApp tarzı chat başlığı
185
  gr.Markdown("<div class='chat-header'>Trek Bike Finder Chatbot</div>")
186
 
187
  with gr.Column(elem_id="col_container"):
@@ -189,7 +199,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
189
  system_msg = gr.Textbox(value="")
190
  new_msg = gr.Textbox(value="")
191
  accordion_msg = gr.HTML(value="", visible=False)
192
- # Gradio'nun Chatbot bileşeni; özel CSS #chatbot ile stil veriyoruz
193
  chatbot = gr.Chatbot(label='Trek Bike Finder', elem_id="chatbot")
194
  inputs = gr.Textbox(
195
  placeholder="Buraya yazın, istediğiniz modeli beraber bulalım.", show_label=False)
 
26
  # name: ilk kelime (marka), item_info: (stok durumu, fiyat)
27
  products.append((name, item_info, full_name))
28
 
 
29
  def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
30
  headers = {
31
  "Content-Type": "application/json",
 
96
  token_counter += 1
97
  yield chat, history, chat_counter, response
98
 
 
99
  def reset_textbox():
100
  return gr.update(value='')
101
 
 
102
  def set_visible_false():
103
  return gr.update(visible=False)
104
 
 
105
  def set_visible_true():
106
  return gr.update(visible=False)
107
 
108
+ # Yeni jenerasyon, okunaklı ve modern tasarım için özel CSS
 
109
  css = """
110
+ /* Chat Başlığı: Temiz ve modern görünüm */
111
  .chat-header {
112
+ background-color: #ffffff;
113
+ color: #333;
114
  padding: 15px;
115
  text-align: center;
116
+ font-size: 22px;
117
+ font-weight: 600;
118
+ border-bottom: 1px solid #e0e0e0;
119
  }
120
 
121
+ /* Chat penceresi: Açık ve ferah arka plan */
122
  #chatbot {
123
+ background-color: #fafafa;
124
  border: none;
125
+ padding: 15px;
126
  }
127
 
128
+ /* Kullanıcı mesajı: Açık mavi ton, modern görünüm */
129
  .chat-bubble.user {
130
+ background-color: #e1f5fe;
131
  align-self: flex-end;
132
+ border-radius: 16px;
133
+ padding: 12px 18px;
134
  margin: 8px 0;
135
  max-width: 70%;
136
+ box-shadow: 0px 1px 3px rgba(0,0,0,0.1);
137
+ font-size: 16px;
138
+ color: #333;
139
  }
140
 
141
+ /* Bot mesajı: Beyaz, hafif gri kenarlık, modern görünüm */
142
  .chat-bubble.bot {
143
+ background-color: #ffffff;
144
  align-self: flex-start;
145
+ border: 1px solid #e0e0e0;
146
+ border-radius: 16px;
147
+ padding: 12px 18px;
148
  margin: 8px 0;
149
  max-width: 70%;
150
+ box-shadow: 0px 1px 3px rgba(0,0,0,0.1);
151
+ font-size: 16px;
152
+ color: #333;
153
  }
154
 
155
+ /* Mesaj gönderme alanı: Temiz ve modern */
156
  .chat-input-container {
157
  display: flex;
158
+ padding: 15px;
159
+ border-top: 1px solid #e0e0e0;
160
+ background-color: #ffffff;
161
+ }
162
+
163
+ /* Chat input alanı */
164
+ .chat-input {
165
+ flex: 1;
166
+ padding: 10px 15px;
167
+ border: 1px solid #ddd;
168
+ border-radius: 20px;
169
+ font-size: 16px;
170
+ outline: none;
171
  }
172
 
173
+ /* Gönder butonu: Modern mavi ton */
174
  .send-button {
175
+ background-color: #1976d2;
176
  border: none;
177
  color: #fff;
178
+ padding: 10px 20px;
179
  margin-left: 10px;
180
  border-radius: 20px;
181
  font-size: 16px;
 
183
  }
184
  """
185
 
186
+ # Tema ayarını güncelliyoruz: modern ve temiz görünüm için neutral_hue "blue"
187
  theme = gr.themes.Base(
188
+ neutral_hue="blue",
189
  text_size="sm",
190
  spacing_size="sm",
191
  )
192
 
193
  with gr.Blocks(theme=theme, css=css) as demo:
194
+ # Modern chat başlığı
195
  gr.Markdown("<div class='chat-header'>Trek Bike Finder Chatbot</div>")
196
 
197
  with gr.Column(elem_id="col_container"):
 
199
  system_msg = gr.Textbox(value="")
200
  new_msg = gr.Textbox(value="")
201
  accordion_msg = gr.HTML(value="", visible=False)
202
+ # Gradio Chatbot bileşeni; CSS ile stil veriliyor.
203
  chatbot = gr.Chatbot(label='Trek Bike Finder', elem_id="chatbot")
204
  inputs = gr.Textbox(
205
  placeholder="Buraya yazın, istediğiniz modeli beraber bulalım.", show_label=False)