AnatoliiG commited on
Commit ·
d411c57
1
Parent(s): 4ac3340
chat window
Browse files- src/ui/components.py +6 -7
- src/ui/styles.py +101 -84
src/ui/components.py
CHANGED
|
@@ -6,16 +6,16 @@ from src.ui.styles import CSS
|
|
| 6 |
|
| 7 |
|
| 8 |
def create_ui():
|
| 9 |
-
|
|
|
|
| 10 |
gr.HTML(f"<style>{CSS}</style>")
|
| 11 |
gr.HTML("<script>document.title = 'Code LLM Agent';</script>")
|
| 12 |
|
| 13 |
with gr.Row(elem_id="main-row", variant="panel"):
|
| 14 |
-
#
|
| 15 |
-
with gr.Sidebar(elem_id="sidebar-container"):
|
| 16 |
gr.Markdown("## 🛠️ Dashboard")
|
| 17 |
|
| 18 |
-
# НОВЫЕ ИНСТРУМЕНТЫ
|
| 19 |
gr.Markdown("### 🧰 Agent Tools")
|
| 20 |
use_search = gr.Checkbox(
|
| 21 |
label="🌐 Включить поиск в интернете", value=False
|
|
@@ -23,10 +23,9 @@ def create_ui():
|
|
| 23 |
uploaded_file = gr.File(
|
| 24 |
label="📎 Загрузить файл",
|
| 25 |
file_types=[".txt", ".pdf", ".py", ".md", ".json"],
|
| 26 |
-
type="filepath",
|
| 27 |
)
|
| 28 |
|
| 29 |
-
# Настройки модели
|
| 30 |
gr.Markdown("### ⚙️ Model Settings")
|
| 31 |
sys_pt = gr.Textbox(
|
| 32 |
label="System Prompt",
|
|
@@ -49,6 +48,7 @@ def create_ui():
|
|
| 49 |
|
| 50 |
# Основная область чата
|
| 51 |
with gr.Column(elem_id="col-chat-main"):
|
|
|
|
| 52 |
chatbot = gr.Chatbot(elem_id="chatbot", show_label=False)
|
| 53 |
|
| 54 |
with gr.Row(elem_id="input-area"):
|
|
@@ -61,7 +61,6 @@ def create_ui():
|
|
| 61 |
)
|
| 62 |
submit = gr.Button("Run ➤", variant="primary", scale=1)
|
| 63 |
|
| 64 |
-
# Обратите внимание, мы добавили use_search и uploaded_file в gen_args!
|
| 65 |
input_args = [msg, chatbot]
|
| 66 |
output_args = [msg, chatbot]
|
| 67 |
gen_args = [chatbot, sys_pt, temp, tokens, use_search, uploaded_file]
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def create_ui():
|
| 9 |
+
# fill_height=True заставит приложение занять весь экран по высоте
|
| 10 |
+
with gr.Blocks(theme=gr.themes.Soft(), css=CSS, fill_height=True) as demo:
|
| 11 |
gr.HTML(f"<style>{CSS}</style>")
|
| 12 |
gr.HTML("<script>document.title = 'Code LLM Agent';</script>")
|
| 13 |
|
| 14 |
with gr.Row(elem_id="main-row", variant="panel"):
|
| 15 |
+
# Задаем ширину сайдбара через Python, чтобы Gradio корректно рассчитывал его скрытие
|
| 16 |
+
with gr.Sidebar(elem_id="sidebar-container", width=280):
|
| 17 |
gr.Markdown("## 🛠️ Dashboard")
|
| 18 |
|
|
|
|
| 19 |
gr.Markdown("### 🧰 Agent Tools")
|
| 20 |
use_search = gr.Checkbox(
|
| 21 |
label="🌐 Включить поиск в интернете", value=False
|
|
|
|
| 23 |
uploaded_file = gr.File(
|
| 24 |
label="📎 Загрузить файл",
|
| 25 |
file_types=[".txt", ".pdf", ".py", ".md", ".json"],
|
| 26 |
+
type="filepath",
|
| 27 |
)
|
| 28 |
|
|
|
|
| 29 |
gr.Markdown("### ⚙️ Model Settings")
|
| 30 |
sys_pt = gr.Textbox(
|
| 31 |
label="System Prompt",
|
|
|
|
| 48 |
|
| 49 |
# Основная область чата
|
| 50 |
with gr.Column(elem_id="col-chat-main"):
|
| 51 |
+
# Безопасное создание чат-бота без конфликтующих аргументов
|
| 52 |
chatbot = gr.Chatbot(elem_id="chatbot", show_label=False)
|
| 53 |
|
| 54 |
with gr.Row(elem_id="input-area"):
|
|
|
|
| 61 |
)
|
| 62 |
submit = gr.Button("Run ➤", variant="primary", scale=1)
|
| 63 |
|
|
|
|
| 64 |
input_args = [msg, chatbot]
|
| 65 |
output_args = [msg, chatbot]
|
| 66 |
gen_args = [chatbot, sys_pt, temp, tokens, use_search, uploaded_file]
|
src/ui/styles.py
CHANGED
|
@@ -1,41 +1,43 @@
|
|
| 1 |
CSS = """
|
|
|
|
| 2 |
html, body, .gradio-container {
|
| 3 |
-
height:
|
|
|
|
| 4 |
margin: 0 !important;
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
}
|
| 9 |
|
| 10 |
-
/*
|
| 11 |
-
.gradio-container
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
height:
|
|
|
|
| 16 |
display: flex !important;
|
| 17 |
-
flex-direction:
|
| 18 |
-
|
| 19 |
background-color: #212121 !important;
|
| 20 |
}
|
| 21 |
|
| 22 |
-
/* 2.
|
| 23 |
#main-row {
|
| 24 |
display: flex !important;
|
| 25 |
-
flex:
|
|
|
|
| 26 |
height: 100% !important;
|
| 27 |
margin: 0 !important;
|
| 28 |
gap: 0 !important;
|
| 29 |
-
background-color: #212121 !important;
|
| 30 |
overflow: hidden !important;
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
-
/* 3.
|
| 34 |
#sidebar-container {
|
| 35 |
-
|
| 36 |
-
min-width: 280px !important;
|
| 37 |
-
max-width: 280px !important;
|
| 38 |
-
background-color: #171717 !important; /* Более темный левый сайдбар */
|
| 39 |
border-right: 1px solid #2f2f2f !important;
|
| 40 |
padding: 1.5rem 1.25rem !important;
|
| 41 |
height: 100% !important;
|
|
@@ -44,109 +46,107 @@ html, body, .gradio-container {
|
|
| 44 |
overflow-y: auto !important;
|
| 45 |
}
|
| 46 |
|
| 47 |
-
/*
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
color: #ececec !important;
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
#sidebar-container button {
|
| 62 |
-
border-radius: 20px !important;
|
| 63 |
-
font-weight: 500 !important;
|
| 64 |
-
transition: all 0.2s ease !important;
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
#sidebar-container .gr-button-stop {
|
| 68 |
-
background-color: #442a2a !important;
|
| 69 |
-
border: none !important;
|
| 70 |
-
}
|
| 71 |
-
#sidebar-container .gr-button-stop:hover {
|
| 72 |
-
background-color: #663a3a !important;
|
| 73 |
}
|
| 74 |
|
| 75 |
-
|
| 76 |
-
.
|
| 77 |
-
|
| 78 |
-
filter: none !important;
|
| 79 |
}
|
| 80 |
|
| 81 |
-
/* 4.
|
| 82 |
#col-chat-main {
|
| 83 |
display: flex !important;
|
| 84 |
flex-direction: column !important;
|
|
|
|
| 85 |
height: 100% !important;
|
| 86 |
-
|
| 87 |
-
margin: 0 !important;
|
| 88 |
background-color: #212121 !important;
|
| 89 |
-
flex: 1 1 auto !important;
|
| 90 |
overflow: hidden !important;
|
| 91 |
-
|
| 92 |
}
|
| 93 |
|
| 94 |
-
/* О
|
| 95 |
#chatbot {
|
| 96 |
flex: 1 1 auto !important;
|
|
|
|
|
|
|
| 97 |
width: 100% !important;
|
| 98 |
-
max-width: 800px !important;
|
| 99 |
margin: 0 auto !important;
|
| 100 |
background: transparent !important;
|
| 101 |
border: none !important;
|
| 102 |
box-shadow: none !important;
|
| 103 |
overflow-y: auto !important;
|
|
|
|
| 104 |
}
|
| 105 |
|
| 106 |
-
/* Внутренняя обертка чата */
|
| 107 |
#chatbot > .wrapper {
|
| 108 |
-
flex: 1 1 auto !important;
|
| 109 |
-
display: flex !important;
|
| 110 |
-
flex-direction: column !important;
|
| 111 |
background: transparent !important;
|
| 112 |
border: none !important;
|
| 113 |
}
|
| 114 |
|
| 115 |
-
/*
|
| 116 |
-
#chatbot .message,
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
font-size: 0.98rem !important;
|
|
|
|
| 123 |
}
|
| 124 |
|
| 125 |
-
/* Сообщения пользователя:
|
| 126 |
#chatbot .user, #chatbot [data-testid="user"] {
|
| 127 |
background-color: #2f2f2f !important;
|
| 128 |
-
color: #
|
|
|
|
|
|
|
| 129 |
border-bottom-right-radius: 4px !important;
|
| 130 |
align-self: flex-end !important;
|
| 131 |
margin-left: auto !important;
|
| 132 |
-
box-shadow: 0
|
| 133 |
}
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
#chatbot .bot, #chatbot [data-testid="bot"] {
|
| 137 |
background-color: transparent !important;
|
| 138 |
color: #ececec !important;
|
| 139 |
align-self: flex-start !important;
|
| 140 |
margin-right: auto !important;
|
| 141 |
-
padding-left: 0 !important;
|
| 142 |
max-width: 100% !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
}
|
| 144 |
|
| 145 |
-
/*
|
| 146 |
#input-area {
|
| 147 |
width: 100% !important;
|
| 148 |
max-width: 800px !important;
|
| 149 |
-
margin: 0 auto
|
| 150 |
padding: 0 1rem !important;
|
| 151 |
background: transparent !important;
|
| 152 |
border: none !important;
|
|
@@ -154,39 +154,52 @@ html, body, .gradio-container {
|
|
| 154 |
flex-shrink: 0 !important;
|
| 155 |
}
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
#input-area textarea {
|
| 158 |
border-radius: 26px !important;
|
| 159 |
border: 1px solid #424242 !important;
|
| 160 |
background-color: #2f2f2f !important;
|
| 161 |
-
color: #
|
| 162 |
padding: 14px 20px !important;
|
| 163 |
font-size: 1rem !important;
|
| 164 |
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.
|
| 165 |
transition: border-color 0.2s, box-shadow 0.2s !important;
|
| 166 |
-
resize: none !important;
|
| 167 |
}
|
| 168 |
|
| 169 |
#input-area textarea:focus {
|
| 170 |
border-color: #676767 !important;
|
| 171 |
-
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.
|
| 172 |
}
|
| 173 |
|
| 174 |
-
/*
|
|
|
|
| 175 |
#input-area .gr-button-primary {
|
| 176 |
border-radius: 22px !important;
|
| 177 |
background-color: #ececec !important;
|
| 178 |
color: #171717 !important;
|
| 179 |
font-weight: 600 !important;
|
| 180 |
border: none !important;
|
| 181 |
-
padding:
|
| 182 |
-
|
|
|
|
|
|
|
| 183 |
}
|
| 184 |
|
|
|
|
| 185 |
#input-area .gr-button-primary:hover {
|
| 186 |
-
background-color: #
|
|
|
|
| 187 |
}
|
| 188 |
|
| 189 |
-
/*
|
| 190 |
::-webkit-scrollbar {
|
| 191 |
width: 6px;
|
| 192 |
height: 6px;
|
|
@@ -202,7 +215,11 @@ html, body, .gradio-container {
|
|
| 202 |
background: #4f4f4f;
|
| 203 |
}
|
| 204 |
|
| 205 |
-
/* Скры
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
footer {
|
| 207 |
display: none !important;
|
| 208 |
}
|
|
|
|
| 1 |
CSS = """
|
| 2 |
+
/* 1. Глобальные правила растягивания на весь экран */
|
| 3 |
html, body, .gradio-container {
|
| 4 |
+
height: 100vh !important;
|
| 5 |
+
min-height: 100vh !important;
|
| 6 |
margin: 0 !important;
|
| 7 |
+
padding: 0 !important;
|
| 8 |
+
overflow: hidden !important;
|
| 9 |
+
background-color: #212121 !important; /* Общий темный фон */
|
| 10 |
}
|
| 11 |
|
| 12 |
+
/* Растягиваем все внутренние обертки Gradio, чтобы чат занимал всю высоту */
|
| 13 |
+
.gradio-container .main,
|
| 14 |
+
.gradio-container .wrap,
|
| 15 |
+
.gradio-container .contain,
|
| 16 |
+
.gradio-container .sidebar-parent {
|
| 17 |
+
height: 100% !important;
|
| 18 |
+
min-height: 100% !important;
|
| 19 |
display: flex !important;
|
| 20 |
+
flex-direction: row !important;
|
| 21 |
+
flex: 1 1 auto !important;
|
| 22 |
background-color: #212121 !important;
|
| 23 |
}
|
| 24 |
|
| 25 |
+
/* 2. Главный ряд (сайдбар + чат) */
|
| 26 |
#main-row {
|
| 27 |
display: flex !important;
|
| 28 |
+
flex-direction: row !important;
|
| 29 |
+
width: 100% !important;
|
| 30 |
height: 100% !important;
|
| 31 |
margin: 0 !important;
|
| 32 |
gap: 0 !important;
|
|
|
|
| 33 |
overflow: hidden !important;
|
| 34 |
+
flex: 1 1 auto !important;
|
| 35 |
+
background-color: #212121 !important;
|
| 36 |
}
|
| 37 |
|
| 38 |
+
/* 3. Стилизация сайдбара */
|
| 39 |
#sidebar-container {
|
| 40 |
+
background-color: #171717 !important; /* Контрастный темный фон */
|
|
|
|
|
|
|
|
|
|
| 41 |
border-right: 1px solid #2f2f2f !important;
|
| 42 |
padding: 1.5rem 1.25rem !important;
|
| 43 |
height: 100% !important;
|
|
|
|
| 46 |
overflow-y: auto !important;
|
| 47 |
}
|
| 48 |
|
| 49 |
+
/* Кнопка сворачивания/разворачивания сайдбара (круглая, темная, всегда поверх) */
|
| 50 |
+
.sidebar-parent button.toggle-button,
|
| 51 |
+
.sidebar-parent > button {
|
| 52 |
+
background-color: #171717 !important;
|
| 53 |
color: #ececec !important;
|
| 54 |
+
border: 1px solid #3a3a3a !important;
|
| 55 |
+
border-radius: 50% !important;
|
| 56 |
+
width: 36px !important;
|
| 57 |
+
height: 36px !important;
|
| 58 |
+
display: flex !important;
|
| 59 |
+
align-items: center !important;
|
| 60 |
+
justify-content: center !important;
|
| 61 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
|
| 62 |
+
z-index: 999 !important; /* Кнопка всегда видна на переднем плане */
|
| 63 |
+
cursor: pointer !important;
|
| 64 |
+
transition: background-color 0.2s !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
}
|
| 66 |
|
| 67 |
+
.sidebar-parent button.toggle-button:hover,
|
| 68 |
+
.sidebar-parent > button:hover {
|
| 69 |
+
background-color: #2f2f2f !important;
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
+
/* 4. Стилизация чат-зоны */
|
| 73 |
#col-chat-main {
|
| 74 |
display: flex !important;
|
| 75 |
flex-direction: column !important;
|
| 76 |
+
flex: 1 1 auto !important;
|
| 77 |
height: 100% !important;
|
| 78 |
+
min-height: 0 !important;
|
|
|
|
| 79 |
background-color: #212121 !important;
|
|
|
|
| 80 |
overflow: hidden !important;
|
| 81 |
+
position: relative !important;
|
| 82 |
}
|
| 83 |
|
| 84 |
+
/* Окно чата занимает все доступное ме��то */
|
| 85 |
#chatbot {
|
| 86 |
flex: 1 1 auto !important;
|
| 87 |
+
height: calc(100vh - 140px) !important;
|
| 88 |
+
max-height: calc(100vh - 140px) !important;
|
| 89 |
width: 100% !important;
|
| 90 |
+
max-width: 800px !important;
|
| 91 |
margin: 0 auto !important;
|
| 92 |
background: transparent !important;
|
| 93 |
border: none !important;
|
| 94 |
box-shadow: none !important;
|
| 95 |
overflow-y: auto !important;
|
| 96 |
+
padding: 20px 10px !important;
|
| 97 |
}
|
| 98 |
|
|
|
|
| 99 |
#chatbot > .wrapper {
|
|
|
|
|
|
|
|
|
|
| 100 |
background: transparent !important;
|
| 101 |
border: none !important;
|
| 102 |
}
|
| 103 |
|
| 104 |
+
/* 5. Четкие контрастные цвета для текста сообщений */
|
| 105 |
+
#chatbot .message,
|
| 106 |
+
#chatbot [data-testid="user"],
|
| 107 |
+
#chatbot [data-testid="bot"],
|
| 108 |
+
#chatbot .message p,
|
| 109 |
+
#chatbot .message span,
|
| 110 |
+
#chatbot .message li {
|
| 111 |
font-size: 0.98rem !important;
|
| 112 |
+
line-height: 1.6 !important;
|
| 113 |
}
|
| 114 |
|
| 115 |
+
/* Сообщения пользователя: темно-серый пузырь справа, белый текст */
|
| 116 |
#chatbot .user, #chatbot [data-testid="user"] {
|
| 117 |
background-color: #2f2f2f !important;
|
| 118 |
+
color: #ffffff !important;
|
| 119 |
+
border: 1px solid #3c3c3c !important;
|
| 120 |
+
border-radius: 20px !important;
|
| 121 |
border-bottom-right-radius: 4px !important;
|
| 122 |
align-self: flex-end !important;
|
| 123 |
margin-left: auto !important;
|
| 124 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
|
| 125 |
}
|
| 126 |
|
| 127 |
+
#chatbot .user *, #chatbot [data-testid="user"] * {
|
| 128 |
+
color: #ffffff !important; /* Гарантирует белый текст для внутренних тегов */
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/* Сообщения Агента: прозрачный фон, светло-серый контрастный текст */
|
| 132 |
#chatbot .bot, #chatbot [data-testid="bot"] {
|
| 133 |
background-color: transparent !important;
|
| 134 |
color: #ececec !important;
|
| 135 |
align-self: flex-start !important;
|
| 136 |
margin-right: auto !important;
|
|
|
|
| 137 |
max-width: 100% !important;
|
| 138 |
+
padding-left: 0 !important;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
#chatbot .bot *, #chatbot [data-testid="bot"] * {
|
| 142 |
+
color: #ececec !important; /* Гарантирует светло-серый текст для внутренних тегов */
|
| 143 |
}
|
| 144 |
|
| 145 |
+
/* 6. Очистка области ввода от белых углов */
|
| 146 |
#input-area {
|
| 147 |
width: 100% !important;
|
| 148 |
max-width: 800px !important;
|
| 149 |
+
margin: 0 auto 1.5rem auto !important;
|
| 150 |
padding: 0 1rem !important;
|
| 151 |
background: transparent !important;
|
| 152 |
border: none !important;
|
|
|
|
| 154 |
flex-shrink: 0 !important;
|
| 155 |
}
|
| 156 |
|
| 157 |
+
#input-area > div,
|
| 158 |
+
#input-area .form,
|
| 159 |
+
#input-area .gr-box {
|
| 160 |
+
background-color: transparent !important;
|
| 161 |
+
border: none !important;
|
| 162 |
+
box-shadow: none !important;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/* Само текстовое поле в стиле ChatGPT */
|
| 166 |
#input-area textarea {
|
| 167 |
border-radius: 26px !important;
|
| 168 |
border: 1px solid #424242 !important;
|
| 169 |
background-color: #2f2f2f !important;
|
| 170 |
+
color: #ffffff !important;
|
| 171 |
padding: 14px 20px !important;
|
| 172 |
font-size: 1rem !important;
|
| 173 |
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
|
| 174 |
transition: border-color 0.2s, box-shadow 0.2s !important;
|
|
|
|
| 175 |
}
|
| 176 |
|
| 177 |
#input-area textarea:focus {
|
| 178 |
border-color: #676767 !important;
|
| 179 |
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35) !important;
|
| 180 |
}
|
| 181 |
|
| 182 |
+
/* Минималистичная кнопка Run (светло-серая, с темным текстом) */
|
| 183 |
+
#input-area button,
|
| 184 |
#input-area .gr-button-primary {
|
| 185 |
border-radius: 22px !important;
|
| 186 |
background-color: #ececec !important;
|
| 187 |
color: #171717 !important;
|
| 188 |
font-weight: 600 !important;
|
| 189 |
border: none !important;
|
| 190 |
+
padding: 0 20px !important;
|
| 191 |
+
height: 44px !important;
|
| 192 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
|
| 193 |
+
transition: all 0.2s ease !important;
|
| 194 |
}
|
| 195 |
|
| 196 |
+
#input-area button:hover,
|
| 197 |
#input-area .gr-button-primary:hover {
|
| 198 |
+
background-color: #ffffff !important;
|
| 199 |
+
transform: translateY(-1px) !important;
|
| 200 |
}
|
| 201 |
|
| 202 |
+
/* Настройки скроллбара */
|
| 203 |
::-webkit-scrollbar {
|
| 204 |
width: 6px;
|
| 205 |
height: 6px;
|
|
|
|
| 215 |
background: #4f4f4f;
|
| 216 |
}
|
| 217 |
|
| 218 |
+
/* Скрытие дублирующих элементов */
|
| 219 |
+
.stale {
|
| 220 |
+
opacity: 1 !important;
|
| 221 |
+
filter: none !important;
|
| 222 |
+
}
|
| 223 |
footer {
|
| 224 |
display: none !important;
|
| 225 |
}
|