Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,18 @@ import time
|
|
6 |
from load_llms import model_choices, llm_intro, load_model
|
7 |
from config import space_hardware
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Construct chatbot
|
11 |
def generate_response(model_name, message, chat_history):
|
@@ -17,10 +29,11 @@ def generate_response(model_name, message, chat_history):
|
|
17 |
|
18 |
# Create Gradio UI
|
19 |
with gr.Blocks(
|
20 |
-
css=
|
21 |
-
"
|
22 |
-
"#
|
23 |
-
"#
|
|
|
24 |
"#clear { background-color: darkred !important; }",
|
25 |
theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Martel Sans")])
|
26 |
) as demo:
|
|
|
6 |
from load_llms import model_choices, llm_intro, load_model
|
7 |
from config import space_hardware
|
8 |
|
9 |
+
javascript_code = """
|
10 |
+
<script>
|
11 |
+
function resizeChatbotColumn() {
|
12 |
+
var windowHeight = window.innerHeight;
|
13 |
+
var colElement = document.getElementById("col");
|
14 |
+
var newHeight = windowHeight * 0.8; // Adjust as needed
|
15 |
+
colElement.style.height = newHeight + "px";
|
16 |
+
}
|
17 |
+
window.onload = resizeChatbotColumn;
|
18 |
+
window.onresize = resizeChatbotColumn;
|
19 |
+
</script>
|
20 |
+
"""
|
21 |
|
22 |
# Construct chatbot
|
23 |
def generate_response(model_name, message, chat_history):
|
|
|
29 |
|
30 |
# Create Gradio UI
|
31 |
with gr.Blocks(
|
32 |
+
css=javascript_code +
|
33 |
+
".contain { display: flex !important; flex-direction: column !important; }" +
|
34 |
+
"#chatbot { flex-grow: 1 !important; overflow: auto !important; }" +
|
35 |
+
"#col { height: calc(100vh - 112px - 16px) !important; }" +
|
36 |
+
"#submit:hover { background-color: green !important; }" +
|
37 |
"#clear { background-color: darkred !important; }",
|
38 |
theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Martel Sans")])
|
39 |
) as demo:
|