Update app.py
Browse files
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ığı:
|
116 |
.chat-header {
|
117 |
-
background-color: #
|
118 |
-
color: #
|
119 |
padding: 15px;
|
120 |
text-align: center;
|
121 |
-
font-size:
|
122 |
-
font-weight:
|
|
|
123 |
}
|
124 |
|
125 |
-
/* Chat penceresi: arka plan
|
126 |
#chatbot {
|
127 |
-
background-color: #
|
128 |
border: none;
|
129 |
-
padding:
|
130 |
}
|
131 |
|
132 |
-
/* Kullanıcı
|
133 |
.chat-bubble.user {
|
134 |
-
background-color: #
|
135 |
align-self: flex-end;
|
136 |
-
border-radius:
|
137 |
-
padding:
|
138 |
margin: 8px 0;
|
139 |
max-width: 70%;
|
140 |
-
|
|
|
|
|
141 |
}
|
142 |
|
143 |
-
/* Bot
|
144 |
.chat-bubble.bot {
|
145 |
-
background-color: #
|
146 |
align-self: flex-start;
|
147 |
-
border: 1px solid #
|
148 |
-
border-radius:
|
149 |
-
padding:
|
150 |
margin: 8px 0;
|
151 |
max-width: 70%;
|
152 |
-
|
|
|
|
|
153 |
}
|
154 |
|
155 |
-
/* Mesaj gönderme
|
156 |
.chat-input-container {
|
157 |
display: flex;
|
158 |
-
padding:
|
159 |
-
border-top: 1px solid #
|
160 |
-
background-color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
}
|
162 |
|
163 |
-
/* Gönder butonu */
|
164 |
.send-button {
|
165 |
-
background-color: #
|
166 |
border: none;
|
167 |
color: #fff;
|
168 |
-
padding: 10px
|
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:
|
177 |
theme = gr.themes.Base(
|
178 |
-
neutral_hue="
|
179 |
text_size="sm",
|
180 |
spacing_size="sm",
|
181 |
)
|
182 |
|
183 |
with gr.Blocks(theme=theme, css=css) as demo:
|
184 |
-
#
|
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
|
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)
|