HaveAI commited on
Commit
835409a
·
verified ·
1 Parent(s): 2eeeb6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -51
app.py CHANGED
@@ -1,54 +1,10 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
- import os
4
 
5
- MODEL_ID = "Qwen/Qwen2.5-72B-Instruct"
6
-
7
- def predict(message, history):
8
- token = os.getenv("HF_TOKEN")
9
- client = InferenceClient(MODEL_ID, token=token)
10
-
11
- messages = [{"role": "system", "content": "Тебя зовут Gemini. Ты ассистент FlareAI. Отвечай кратко и понятно на русском языке."}]
12
-
13
- for user_msg, bot_msg in history:
14
- messages.append({"role": "user", "content": user_msg})
15
- messages.append({"role": "assistant", "content": bot_msg})
16
-
17
- messages.append({"role": "user", "content": message})
18
-
19
- response = ""
20
- try:
21
- for message_chunk in client.chat_completion(messages, max_tokens=1024, stream=True):
22
- token_text = message_chunk.choices[0].delta.content
23
- if token_text:
24
- response += token_text
25
- yield response
26
- except Exception as e:
27
- yield f"⚠️ Ошибка: {str(e)}. Подожди 10 секунд и попробуй снова."
28
-
29
- custom_theme = gr.themes.Soft(
30
- primary_hue="yellow",
31
- secondary_hue="blue",
32
- ).set(
33
- body_background_fill="#0057b7",
34
- block_background_fill="#ffdd00",
35
- block_title_text_color="#000000",
36
- button_primary_text_color="#000000"
37
- )
38
-
39
- # ИСПРАВЛЕНИЕ 1: Убрали theme отсюда
40
- with gr.Blocks(title="FlareAI") as demo:
41
  with gr.Sidebar():
42
- gr.Markdown("# **FlareAI**")
43
- gr.Markdown("---")
44
- gr.Markdown("Твой ассистент на базе Gemini")
45
- gr.LoginButton()
46
- gr.Markdown("---")
47
- gr.Markdown("Если бот молчит, нажми 'Login' или проверь HF_TOKEN в настройках.")
48
-
49
- # ИСПРАВЛЕНИЕ 2: Убрали параметры type и save_history, оставили только функцию
50
- gr.ChatInterface(fn=predict)
51
-
52
- if __name__ == "__main__":
53
- # ИСПРАВЛЕНИЕ 3: Перенесли theme сюда, как просило предупреждение в логах
54
- demo.launch(theme=custom_theme)
 
1
  import gradio as gr
 
 
2
 
3
+ with gr.Blocks(fill_height=True) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  with gr.Sidebar():
5
+ gr.Markdown("# FlareAI")
6
+ gr.Markdown("Flare - your personal assistant")
7
+ button = gr.LoginButton("Sign in")
8
+ gr.load("models/moonshotai/Kimi-K2-Thinking", accept_token=button, provider="novita")
9
+
10
+ demo.launch()