Update app.py
Browse files
app.py
CHANGED
@@ -114,103 +114,76 @@ def reset_textbox():
|
|
114 |
|
115 |
# CSS: Butonun sabit, yuvarlak kalması ve sağa doğru hafifçe 2px uzaklaşması için ayarlandı.
|
116 |
# Ek olarak, mobilde giriş alanının genişliğini kısıtlamak için "#input_text" id'sine genişlik ayarı ekledik.
|
|
|
|
|
117 |
demo_css = """
|
118 |
#send_button {
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
}
|
132 |
#send_button:hover {
|
133 |
-
|
134 |
}
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
/* Buton kapsayıcısındaki sol margin değerini kaldırıyoruz */
|
142 |
.fixed_button_container {
|
143 |
-
|
144 |
-
|
145 |
-
margin: 0px 0 0 0px; /* Sol boşluk kaldırıldı */
|
146 |
}
|
147 |
#custom_row {
|
148 |
-
|
149 |
-
|
150 |
}
|
151 |
-
|
152 |
/* Mobil ekranlar için özel düzenleme */
|
153 |
@media only screen and (max-width: 1000px) {
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
-
|
159 |
-
|
160 |
"""
|
161 |
|
162 |
-
|
163 |
-
|
164 |
# Tema ayarları
|
165 |
-
theme = gr.themes.Base(
|
166 |
-
neutral_hue="blue",
|
167 |
-
text_size="sm",
|
168 |
-
spacing_size="sm",
|
169 |
-
)
|
170 |
|
171 |
-
with gr.Blocks(css=demo_css
|
172 |
with gr.Column(elem_id="col_container"):
|
173 |
with gr.Accordion("", open=False, visible=False):
|
174 |
system_msg = gr.Textbox(value="")
|
175 |
new_msg = gr.Textbox(value="")
|
176 |
accordion_msg = gr.HTML(value="", visible=False)
|
177 |
-
|
178 |
chatbot = gr.Chatbot(label='Trek Asistanı', elem_id="chatbot")
|
179 |
|
180 |
-
# Row içinde, metin kutusu ve buton arasındaki boşluğu sıfırlıyoruz
|
181 |
with gr.Row(elem_id="custom_row"):
|
182 |
-
inputs = gr.Textbox(
|
183 |
-
placeholder="Buraya yazın",
|
184 |
-
show_label=False,
|
185 |
-
container=False,
|
186 |
-
|
187 |
-
)
|
188 |
-
# Butonu, genişlemesini engelleyen sabit kapsayıcı içinde yerleştiriyoruz.
|
189 |
with gr.Column(elem_classes="fixed_button_container"):
|
190 |
send_button = gr.Button(value="✈", elem_id="send_button")
|
191 |
-
|
192 |
state = gr.State([])
|
|
|
193 |
with gr.Accordion("", open=False, visible=False):
|
194 |
-
top_p = gr.Slider(minimum=0, maximum=1.0, value=0.5,
|
195 |
-
|
196 |
-
temperature = gr.Slider(minimum=0, maximum=5.0, value=0.1,
|
197 |
-
step=0.1, interactive=False, visible=False)
|
198 |
chat_counter = gr.Number(value=0, visible=False, precision=0)
|
199 |
|
200 |
# ENTER tuşuyla gönderme işlemi
|
201 |
-
inputs.submit(
|
202 |
-
predict,
|
203 |
-
[system_msg, inputs, top_p, temperature, chat_counter, chatbot, state],
|
204 |
-
[chatbot, state, chat_counter]
|
205 |
-
)
|
206 |
inputs.submit(reset_textbox, [], [inputs])
|
207 |
-
|
208 |
# Gönder butonuna tıklandığında işlemin gerçekleşmesi
|
209 |
-
send_button.click(
|
210 |
-
predict,
|
211 |
-
[system_msg, inputs, top_p, temperature, chat_counter, chatbot, state],
|
212 |
-
[chatbot, state, chat_counter]
|
213 |
-
)
|
214 |
send_button.click(reset_textbox, [], [inputs])
|
215 |
|
216 |
demo.queue(max_size=10).launch(debug=True)
|
|
|
|
114 |
|
115 |
# CSS: Butonun sabit, yuvarlak kalması ve sağa doğru hafifçe 2px uzaklaşması için ayarlandı.
|
116 |
# Ek olarak, mobilde giriş alanının genişliğini kısıtlamak için "#input_text" id'sine genişlik ayarı ekledik.
|
117 |
+
|
118 |
+
# CSS: Chatbot yüksekliğini ayarlama ve mevcut CSS'i koruma
|
119 |
demo_css = """
|
120 |
#send_button {
|
121 |
+
background-color: #0b93f6;
|
122 |
+
border: none;
|
123 |
+
color: white;
|
124 |
+
font-size: 24px;
|
125 |
+
border-radius: 10%;
|
126 |
+
width: 35px !important;
|
127 |
+
height: 37px !important;
|
128 |
+
display: inline-flex;
|
129 |
+
align-items: center;
|
130 |
+
justify-content: center;
|
131 |
+
cursor: pointer;
|
132 |
+
transition: background-color 0.3s;
|
133 |
}
|
134 |
#send_button:hover {
|
135 |
+
background-color: #0077c0;
|
136 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
/* Buton kapsayıcısındaki sol margin değerini kaldırıyoruz */
|
138 |
.fixed_button_container {
|
139 |
+
padding: 0px;
|
140 |
+
margin: 0px 0 0 0px; /* Sol boşluk kaldırıldı */
|
|
|
141 |
}
|
142 |
#custom_row {
|
143 |
+
width: 150% !important; /* İstediğiniz yüksekliği girin */
|
144 |
+
flex-wrap: nowrap !important;
|
145 |
}
|
|
|
146 |
/* Mobil ekranlar için özel düzenleme */
|
147 |
@media only screen and (max-width: 1000px) {
|
148 |
+
.custom_row { /* Eğer Row'a bu sınıf atanmışsa */
|
149 |
+
flex-wrap: nowrap !important;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
#chatbot {
|
153 |
+
height: 100vh !important; /* Bu, chatbotun yüksekliğini sayfanın tamamına yayacaktır */
|
154 |
+
overflow-y: auto; /* Bu, dikey kaydırma çubuğunu etkinleştirir */
|
155 |
}
|
|
|
|
|
156 |
"""
|
157 |
|
|
|
|
|
158 |
# Tema ayarları
|
159 |
+
theme = gr.themes.Base(neutral_hue="blue", text_size="sm", spacing_size="sm")
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
with gr.Blocks(css=demo_css) as demo:
|
162 |
with gr.Column(elem_id="col_container"):
|
163 |
with gr.Accordion("", open=False, visible=False):
|
164 |
system_msg = gr.Textbox(value="")
|
165 |
new_msg = gr.Textbox(value="")
|
166 |
accordion_msg = gr.HTML(value="", visible=False)
|
|
|
167 |
chatbot = gr.Chatbot(label='Trek Asistanı', elem_id="chatbot")
|
168 |
|
169 |
+
# Row içinde, metin kutusu ve buton arasındaki boşluğu sıfırlıyoruz
|
170 |
with gr.Row(elem_id="custom_row"):
|
171 |
+
inputs = gr.Textbox(placeholder="Buraya yazın", show_label=False, container=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
with gr.Column(elem_classes="fixed_button_container"):
|
173 |
send_button = gr.Button(value="✈", elem_id="send_button")
|
|
|
174 |
state = gr.State([])
|
175 |
+
|
176 |
with gr.Accordion("", open=False, visible=False):
|
177 |
+
top_p = gr.Slider(minimum=0, maximum=1.0, value=0.5, step=0.05, interactive=False, visible=False)
|
178 |
+
temperature = gr.Slider(minimum=0, maximum=5.0, value=0.1, step=0.1, interactive=False, visible=False)
|
|
|
|
|
179 |
chat_counter = gr.Number(value=0, visible=False, precision=0)
|
180 |
|
181 |
# ENTER tuşuyla gönderme işlemi
|
182 |
+
inputs.submit(predict, [system_msg, inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter])
|
|
|
|
|
|
|
|
|
183 |
inputs.submit(reset_textbox, [], [inputs])
|
|
|
184 |
# Gönder butonuna tıklandığında işlemin gerçekleşmesi
|
185 |
+
send_button.click(predict, [system_msg, inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter])
|
|
|
|
|
|
|
|
|
186 |
send_button.click(reset_textbox, [], [inputs])
|
187 |
|
188 |
demo.queue(max_size=10).launch(debug=True)
|
189 |
+
|