HaveAI commited on
Commit
66f8cd7
·
verified ·
1 Parent(s): f9224ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -19
app.py CHANGED
@@ -1,38 +1,51 @@
1
  import gradio as gr
2
 
3
- # Кастомный CSS для сине-желтого дизайна
 
 
 
 
 
 
 
 
 
 
4
  css = """
5
- .gradio-container {
6
- background-color: #0057b7 !important; /* Синий фон */
7
- }
8
  #side-bar {
9
- background-color: #ffdd00 !important; /* Желтый сайдбар */
10
  padding: 15px;
11
- border-radius: 10px;
12
  }
13
- footer {display: none !important;}
 
 
14
  """
15
 
16
  def predict(message, history):
17
- # Добавляем системную инструкцию перед сообщением пользователя
18
- system_prompt = "Тебя зовут Flare "
19
- full_prompt = f"{system_prompt} {message}"
20
 
21
- # Загружаем модель (используем интерфейс через функцию для контроля промпта)
 
 
22
  client = gr.load("models/moonshotai/Kimi-K2-Thinking", provider="novita")
23
- return client(full_prompt)
 
 
 
24
 
25
- with gr.Blocks(css=css, fill_height=True) as demo:
 
26
  with gr.Sidebar(elem_id="side-bar"):
27
  gr.Markdown("# **FlareAI**")
28
  gr.Markdown("Flare — твой персональный ассистент")
29
  button = gr.LoginButton("Войти")
30
-
 
31
  gr.ChatInterface(
32
- predict,
33
- additional_inputs=None,
34
- # Настройка цветов текстовых пузырей через тему
35
- theme=gr.themes.Soft(primary_hue="yellow", secondary_hue="blue")
36
  )
37
 
38
- demo.launch()
 
 
1
  import gradio as gr
2
 
3
+ # Цветовая схема: синий и желтый
4
+ # Используем стандартные именованные цвета Gradio для стабильности
5
+ custom_theme = gr.themes.Soft(
6
+ primary_hue="yellow",
7
+ secondary_hue="blue",
8
+ ).set(
9
+ body_background_fill="#0057b7", # Насыщенный синий фон
10
+ block_background_fill="#ffdd00", # Желтые блоки
11
+ button_primary_background_fill="#ffdd00"
12
+ )
13
+
14
  css = """
 
 
 
15
  #side-bar {
16
+ background-color: #ffdd00 !important;
17
  padding: 15px;
 
18
  }
19
+ .gradio-container {
20
+ color: white; /* Чтобы текст на синем фоне читался лучше */
21
+ }
22
  """
23
 
24
  def predict(message, history):
25
+ # Системная инструкция
26
+ system_prompt = "Тебя зовут Flare."
 
27
 
28
+ # Загружаем модель
29
+ # Важно: gr.load внутри функции может работать медленно.
30
+ # Если будет тормозить, лучше вынести инициализацию клиента наружу.
31
  client = gr.load("models/moonshotai/Kimi-K2-Thinking", provider="novita")
32
+
33
+ # Формируем запрос с учетом имени
34
+ full_query = f"{system_prompt}\n\nПользователь: {message}"
35
+ return client(full_query)
36
 
37
+ # Тема теперь передается в Blocks
38
+ with gr.Blocks(theme=custom_theme, fill_height=True) as demo:
39
  with gr.Sidebar(elem_id="side-bar"):
40
  gr.Markdown("# **FlareAI**")
41
  gr.Markdown("Flare — твой персональный ассистент")
42
  button = gr.LoginButton("Войти")
43
+
44
+ # В ChatInterface убираем аргумент theme, он наследуется от Blocks
45
  gr.ChatInterface(
46
+ fn=predict,
47
+ type="messages" # Рекомендуемый тип для новых версий Gradio
 
 
48
  )
49
 
50
+ # CSS теперь передается в launch() согласно предупреждению
51
+ demo.launch(css=css)