AnatoliiG commited on
Commit ·
8fe3b97
1
Parent(s): cda17b1
Update ui.py
Browse files
ui.py
CHANGED
|
@@ -8,39 +8,56 @@ from utils import get_clean_text
|
|
| 8 |
|
| 9 |
# --- CSS стили ---
|
| 10 |
CUSTOM_CSS = """
|
| 11 |
-
/*
|
| 12 |
.gradio-container {
|
|
|
|
| 13 |
width: 100% !important;
|
| 14 |
height: 100vh !important;
|
| 15 |
-
max_height: 100vh !important;
|
| 16 |
padding: 0 !important;
|
| 17 |
margin: 0 !important;
|
| 18 |
overflow: hidden !important;
|
| 19 |
}
|
| 20 |
|
| 21 |
-
/* Настройки боковой панели
|
| 22 |
.sidebar {
|
| 23 |
height: 100vh !important;
|
| 24 |
overflow-y: auto !important;
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
/*
|
| 28 |
-
ГЛАВНОЕ
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
flex-grow отключен, чтобы избежать конфликтов.
|
| 32 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
#chatbot {
|
| 34 |
-
height:
|
| 35 |
-
min-height:
|
| 36 |
overflow-y: auto !important;
|
| 37 |
-
margin-bottom:
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
-
/* Блок ввода прижимаем ни
|
| 41 |
.input-row {
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
footer { display: none !important; }
|
|
@@ -77,11 +94,9 @@ def bot_response(history, system_prompt, temperature, max_tokens):
|
|
| 77 |
|
| 78 |
messages = [{"role": "system", "content": system_prompt}]
|
| 79 |
|
| 80 |
-
# Берем последние 15 сообщений
|
| 81 |
relevant_history = history[-15:] if len(history) > 15 else history
|
| 82 |
|
| 83 |
for msg in relevant_history:
|
| 84 |
-
# Также чистим контент перед отправкой в модель
|
| 85 |
raw_content = msg.get("content", "")
|
| 86 |
text_content = get_clean_text(raw_content)
|
| 87 |
|
|
@@ -127,9 +142,8 @@ def set_interactive(is_interactive):
|
|
| 127 |
def create_ui():
|
| 128 |
theme = gr.themes.Soft(primary_hue="blue", text_size="lg")
|
| 129 |
|
| 130 |
-
# Убрали fill_height=True, чтобы CSS работал жестко
|
| 131 |
with gr.Blocks(theme=theme, css=CUSTOM_CSS, title="Qwen Coder Pro") as demo:
|
| 132 |
-
with gr.Row():
|
| 133 |
# Боковая панель
|
| 134 |
with gr.Sidebar():
|
| 135 |
gr.Markdown("### ⚙️ Settings")
|
|
@@ -146,14 +160,14 @@ def create_ui():
|
|
| 146 |
)
|
| 147 |
clear_btn = gr.Button("🗑️ Clear Chat", variant="secondary")
|
| 148 |
|
| 149 |
-
# Основная колонка
|
| 150 |
-
with gr.Column(scale=
|
| 151 |
# Чатбот
|
| 152 |
chatbot = gr.Chatbot(
|
| 153 |
label="Code Assistant",
|
| 154 |
-
elem_id="chatbot",
|
| 155 |
avatar_images=(None, "https://api.iconify.design/noto:robot.svg"),
|
| 156 |
-
|
| 157 |
)
|
| 158 |
|
| 159 |
# Строка ввода
|
|
@@ -162,9 +176,9 @@ def create_ui():
|
|
| 162 |
show_label=False,
|
| 163 |
placeholder="Type your code question here...",
|
| 164 |
lines=1,
|
| 165 |
-
scale=
|
| 166 |
autofocus=True,
|
| 167 |
-
max_lines=
|
| 168 |
)
|
| 169 |
submit_btn = gr.Button(
|
| 170 |
"Run ➤", variant="primary", scale=1, min_width=100
|
|
|
|
| 8 |
|
| 9 |
# --- CSS стили ---
|
| 10 |
CUSTOM_CSS = """
|
| 11 |
+
/* Глобальные настройки контейнера на весь экран */
|
| 12 |
.gradio-container {
|
| 13 |
+
max-width: 100% !important;
|
| 14 |
width: 100% !important;
|
| 15 |
height: 100vh !important;
|
|
|
|
| 16 |
padding: 0 !important;
|
| 17 |
margin: 0 !important;
|
| 18 |
overflow: hidden !important;
|
| 19 |
}
|
| 20 |
|
| 21 |
+
/* Настройки боковой панели */
|
| 22 |
.sidebar {
|
| 23 |
height: 100vh !important;
|
| 24 |
overflow-y: auto !important;
|
| 25 |
+
width: 300px !important; /* Фиксируем ширину сайдбара, чтобы не съедал место */
|
| 26 |
}
|
| 27 |
|
| 28 |
/*
|
| 29 |
+
ГЛАВНОЕ: Убираем ограничение ширины текста.
|
| 30 |
+
По умолчанию Gradio сужает текст для "читаемости",
|
| 31 |
+
но для кода это вредно.
|
|
|
|
| 32 |
*/
|
| 33 |
+
.prose {
|
| 34 |
+
max-width: 100% !important;
|
| 35 |
+
width: 100% !important;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.message {
|
| 39 |
+
max-width: 100% !important;
|
| 40 |
+
width: 100% !important;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
.message-wrap {
|
| 44 |
+
max-width: 100% !important;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/* Настройки окна чата */
|
| 48 |
#chatbot {
|
| 49 |
+
height: 82vh !important; /* Увеличили высоту */
|
| 50 |
+
min-height: 82vh !important;
|
| 51 |
overflow-y: auto !important;
|
| 52 |
+
margin-bottom: 0 !important;
|
| 53 |
+
flex-grow: 1 !important;
|
| 54 |
}
|
| 55 |
|
| 56 |
+
/* Блок ввода прижимаем к низу */
|
| 57 |
.input-row {
|
| 58 |
+
padding: 10px 15px !important;
|
| 59 |
+
background: var(--background-fill-primary);
|
| 60 |
+
border-top: 1px solid var(--border-color-primary);
|
| 61 |
}
|
| 62 |
|
| 63 |
footer { display: none !important; }
|
|
|
|
| 94 |
|
| 95 |
messages = [{"role": "system", "content": system_prompt}]
|
| 96 |
|
|
|
|
| 97 |
relevant_history = history[-15:] if len(history) > 15 else history
|
| 98 |
|
| 99 |
for msg in relevant_history:
|
|
|
|
| 100 |
raw_content = msg.get("content", "")
|
| 101 |
text_content = get_clean_text(raw_content)
|
| 102 |
|
|
|
|
| 142 |
def create_ui():
|
| 143 |
theme = gr.themes.Soft(primary_hue="blue", text_size="lg")
|
| 144 |
|
|
|
|
| 145 |
with gr.Blocks(theme=theme, css=CUSTOM_CSS, title="Qwen Coder Pro") as demo:
|
| 146 |
+
with gr.Row(equal_height=True, variant="default"):
|
| 147 |
# Боковая панель
|
| 148 |
with gr.Sidebar():
|
| 149 |
gr.Markdown("### ⚙️ Settings")
|
|
|
|
| 160 |
)
|
| 161 |
clear_btn = gr.Button("🗑️ Clear Chat", variant="secondary")
|
| 162 |
|
| 163 |
+
# Основная колонка (теперь она будет растягиваться благодаря CSS)
|
| 164 |
+
with gr.Column(scale=10, elem_classes=["main-column"]):
|
| 165 |
# Чатбот
|
| 166 |
chatbot = gr.Chatbot(
|
| 167 |
label="Code Assistant",
|
| 168 |
+
elem_id="chatbot",
|
| 169 |
avatar_images=(None, "https://api.iconify.design/noto:robot.svg"),
|
| 170 |
+
layout="bubble",
|
| 171 |
)
|
| 172 |
|
| 173 |
# Строка ввода
|
|
|
|
| 176 |
show_label=False,
|
| 177 |
placeholder="Type your code question here...",
|
| 178 |
lines=1,
|
| 179 |
+
scale=15,
|
| 180 |
autofocus=True,
|
| 181 |
+
max_lines=10,
|
| 182 |
)
|
| 183 |
submit_btn = gr.Button(
|
| 184 |
"Run ➤", variant="primary", scale=1, min_width=100
|