File size: 2,316 Bytes
924a603
5bab3a0
640422d
 
c1bf4fa
640422d
c1bf4fa
 
 
 
 
640422d
 
649ba78
c1bf4fa
640422d
c1bf4fa
 
 
640422d
691a822
640422d
c1bf4fa
640422d
 
 
 
 
c1bf4fa
640422d
 
c1bf4fa
640422d
c1bf4fa
640422d
691a822
2eeeb6d
835409a
640422d
 
c1bf4fa
640422d
 
c1bf4fa
640422d
c1bf4fa
 
640422d
 
c1bf4fa
 
 
640422d
691a822
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import gradio as gr

# 1. Твоя системна інструкція для Flare
SYSTEM_PROMPT = "Твоє ім'я — Flare. Ти персональний ШІ-помічник. Відповідай українською мовою."

# 2. Дизайн: Синій, Жовтий, Чорний
theme = gr.themes.Soft(
    primary_hue="blue",
    secondary_hue="yellow",
    neutral_hue="slate",
).set(
    body_background_fill="*neutral_950",        # Чорний фон
    block_background_fill="*neutral_900",       # Темні блоки
    button_primary_background_fill="#0057B7",   # Синій (UA Blue)
    button_primary_text_color="white",
    block_title_text_color="#FFD700",           # Жовтий текст (UA Gold)
    input_background_fill="*neutral_800",
)

css = "footer {visibility: hidden} h1 {color: #FFD700 !important;}"

# Функція для роботи чату (замість gr.load)
def predict(message, history):
    # Підключаємо модель через провайдера novita (як у тебе в коді)
    client = gr.load("models/moonshotai/Kimi-K2-Thinking", provider="novita")
    
    # Формуємо запит так, щоб модель знала, що вона Flare
    full_prompt = f"System: {SYSTEM_PROMPT}\n"
    for human, ai in history:
        full_prompt += f"User: {human}\nAssistant: {ai}\n"
    full_prompt += f"User: {message}\nAssistant:"
    
    return client(full_prompt)

# ТВОЯ СТРУКТУРА КОДУ:
with gr.Blocks(fill_height=True) as demo:
    with gr.Sidebar():
        gr.Markdown("# FlareAI")
        gr.Markdown("Flare — твій персональний помічник")
        # Твоя кнопка
        button = gr.LoginButton("Увійти")
        gr.Markdown("---")
        gr.Markdown("🇺🇦 Український інтерфейс")

    # Твій чат (адаптований під Gradio 6)
    gr.ChatInterface(
        predict,
        chatbot=gr.Chatbot(label="Чат Flare", show_label=False, height=600),
        textbox=gr.Textbox(placeholder="Запитай Flare про що завгодно...", container=False, scale=7),
    )

if __name__ == "__main__":
    # У Gradio 6 theme та css передаються сюди
    demo.launch(theme=theme, css=css)