Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -202,7 +202,7 @@ def clear_chat():
|
|
202 |
# カスタムCSS
|
203 |
custom_css = """
|
204 |
#chatbot {
|
205 |
-
|
206 |
overflow-y: auto;
|
207 |
}
|
208 |
"""
|
@@ -213,35 +213,18 @@ custom_js = """
|
|
213 |
function adjustChatbotHeight() {
|
214 |
var chatbot = document.querySelector('#chatbot');
|
215 |
if (chatbot) {
|
216 |
-
|
217 |
-
var newHeight = Math.max(300, windowHeight * 0.5);
|
218 |
-
chatbot.style.height = newHeight + 'px';
|
219 |
}
|
220 |
}
|
|
|
221 |
// ページ読み込み時と画面サイズ変更時にチャットボットの高さを調整
|
222 |
window.addEventListener('load', adjustChatbotHeight);
|
223 |
window.addEventListener('resize', adjustChatbotHeight);
|
224 |
-
|
225 |
-
// Mutation Observerを使用してDOMの変更を監視し、チャットボットが表示されたときに高さを調整
|
226 |
-
var observer = new MutationObserver(function(mutations) {
|
227 |
-
mutations.forEach(function(mutation) {
|
228 |
-
if (mutation.type === 'childList') {
|
229 |
-
var chatbot = document.querySelector('#chatbot');
|
230 |
-
if (chatbot) {
|
231 |
-
adjustChatbotHeight();
|
232 |
-
observer.disconnect();
|
233 |
-
}
|
234 |
-
}
|
235 |
-
});
|
236 |
-
});
|
237 |
-
|
238 |
-
observer.observe(document.body, { childList: true, subtree: true });
|
239 |
</script>
|
240 |
"""
|
241 |
|
242 |
# Gradioインターフェースの設定
|
243 |
with gr.Blocks(css=custom_css) as iface:
|
244 |
-
gr.HTML(custom_js) # カスタムJavaScriptを追加
|
245 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
246 |
|
247 |
with gr.Tab("チャット"):
|
|
|
202 |
# カスタムCSS
|
203 |
custom_css = """
|
204 |
#chatbot {
|
205 |
+
height: 60vh !important;
|
206 |
overflow-y: auto;
|
207 |
}
|
208 |
"""
|
|
|
213 |
function adjustChatbotHeight() {
|
214 |
var chatbot = document.querySelector('#chatbot');
|
215 |
if (chatbot) {
|
216 |
+
chatbot.style.height = window.innerHeight * 0.6 + 'px';
|
|
|
|
|
217 |
}
|
218 |
}
|
219 |
+
|
220 |
// ページ読み込み時と画面サイズ変更時にチャットボットの高さを調整
|
221 |
window.addEventListener('load', adjustChatbotHeight);
|
222 |
window.addEventListener('resize', adjustChatbotHeight);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
</script>
|
224 |
"""
|
225 |
|
226 |
# Gradioインターフェースの設定
|
227 |
with gr.Blocks(css=custom_css) as iface:
|
|
|
228 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
229 |
|
230 |
with gr.Tab("チャット"):
|