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

Update app.py

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