Update app.py
Browse files
app.py
CHANGED
@@ -104,13 +104,22 @@ def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=[], hi
|
|
104 |
def reset_textbox():
|
105 |
return gr.update(value='')
|
106 |
|
107 |
-
# CSS
|
108 |
-
# - Giriş kutusuna özel bir sınıf ekleyip, mobilde genişliğini sınırlandırıyoruz.
|
109 |
-
# - Buton sabit boyutlarda kalıyor.
|
110 |
demo_css = """
|
111 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
.mobile_input {
|
113 |
-
|
|
|
|
|
114 |
}
|
115 |
|
116 |
/* Gönder butonu */
|
@@ -136,17 +145,11 @@ demo_css = """
|
|
136 |
background-color: #0077c0;
|
137 |
}
|
138 |
|
139 |
-
/*
|
140 |
-
.compact_row {
|
141 |
-
gap: 0px !important;
|
142 |
-
margin: 0px;
|
143 |
-
}
|
144 |
-
|
145 |
-
/* Buton kapsayıcısı: konumlandırma için margin değerleri */
|
146 |
.fixed_button_container {
|
147 |
width: 35px !important;
|
148 |
padding: 0px;
|
149 |
-
margin: 5px 0 0 2px; /* Üstte 5px, solda 2px */
|
150 |
}
|
151 |
"""
|
152 |
|
@@ -166,9 +169,8 @@ with gr.Blocks(css=demo_css, theme=theme) as demo:
|
|
166 |
|
167 |
chatbot = gr.Chatbot(label='Trek Asistanı', elem_id="chatbot")
|
168 |
|
169 |
-
# compact_row sınıfı
|
170 |
with gr.Row(elem_classes="compact_row"):
|
171 |
-
# Giriş kutusuna .mobile_input sınıfını ekleyerek genişliğini sınırlandırıyoruz.
|
172 |
inputs = gr.Textbox(
|
173 |
placeholder="Buraya yazın, yanıtlayalım.",
|
174 |
show_label=False,
|
@@ -186,7 +188,7 @@ with gr.Blocks(css=demo_css, theme=theme) as demo:
|
|
186 |
step=0.1, interactive=False, visible=False)
|
187 |
chat_counter = gr.Number(value=0, visible=False, precision=0)
|
188 |
|
189 |
-
# ENTER
|
190 |
inputs.submit(
|
191 |
predict,
|
192 |
[system_msg, inputs, top_p, temperature, chat_counter, chatbot, state],
|
@@ -194,7 +196,7 @@ with gr.Blocks(css=demo_css, theme=theme) as demo:
|
|
194 |
)
|
195 |
inputs.submit(reset_textbox, [], [inputs])
|
196 |
|
197 |
-
# Gönder butonuna
|
198 |
send_button.click(
|
199 |
predict,
|
200 |
[system_msg, inputs, top_p, temperature, chat_counter, chatbot, state],
|
|
|
104 |
def reset_textbox():
|
105 |
return gr.update(value='')
|
106 |
|
107 |
+
# CSS
|
|
|
|
|
108 |
demo_css = """
|
109 |
+
/* Row'u esnek yapıp, satır kaymasını önlemek için */
|
110 |
+
.compact_row {
|
111 |
+
display: flex !important;
|
112 |
+
flex-wrap: nowrap !important;
|
113 |
+
align-items: center !important;
|
114 |
+
gap: 0px !important;
|
115 |
+
margin: 0px;
|
116 |
+
}
|
117 |
+
|
118 |
+
/* Giriş kutusuna mobilde genişlik sınırlaması */
|
119 |
.mobile_input {
|
120 |
+
/* Buton alanı sabit 45px olacak şekilde, kalan alanı kullan */
|
121 |
+
width: calc(100% - 45px) !important;
|
122 |
+
min-width: 0;
|
123 |
}
|
124 |
|
125 |
/* Gönder butonu */
|
|
|
145 |
background-color: #0077c0;
|
146 |
}
|
147 |
|
148 |
+
/* Buton kapsayıcısı: konumlandırma için */
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
.fixed_button_container {
|
150 |
width: 35px !important;
|
151 |
padding: 0px;
|
152 |
+
margin: 5px 0 0 2px; /* Üstte 5px, solda 2px boşluk */
|
153 |
}
|
154 |
"""
|
155 |
|
|
|
169 |
|
170 |
chatbot = gr.Chatbot(label='Trek Asistanı', elem_id="chatbot")
|
171 |
|
172 |
+
# compact_row sınıfı sayesinde aynı satırda kalmalarını sağlıyoruz.
|
173 |
with gr.Row(elem_classes="compact_row"):
|
|
|
174 |
inputs = gr.Textbox(
|
175 |
placeholder="Buraya yazın, yanıtlayalım.",
|
176 |
show_label=False,
|
|
|
188 |
step=0.1, interactive=False, visible=False)
|
189 |
chat_counter = gr.Number(value=0, visible=False, precision=0)
|
190 |
|
191 |
+
# ENTER tuşuyla gönderme işlemi
|
192 |
inputs.submit(
|
193 |
predict,
|
194 |
[system_msg, inputs, top_p, temperature, chat_counter, chatbot, state],
|
|
|
196 |
)
|
197 |
inputs.submit(reset_textbox, [], [inputs])
|
198 |
|
199 |
+
# Gönder butonuna tıklanıldığında
|
200 |
send_button.click(
|
201 |
predict,
|
202 |
[system_msg, inputs, top_p, temperature, chat_counter, chatbot, state],
|