File size: 1,871 Bytes
9edd305
659b387
 
9edd305
90fe093
659b387
 
 
 
c0bd45a
687e309
d54b713
 
 
 
c0bd45a
 
 
659b387
c0bd45a
d54b713
b2f9c41
c0bd45a
 
687e309
c0bd45a
b2f9c41
c0bd45a
687e309
 
9edd305
c0bd45a
659b387
90fe093
c0bd45a
d54b713
c0bd45a
 
d54b713
90fe093
c0bd45a
90fe093
 
 
 
659b387
d54b713
c0bd45a
 
659b387
90fe093
 
 
9edd305
 
90fe093
c0bd45a
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
55
56
57
import gradio as gr
from transformers import pipeline
import torch

# 1. ЗАГРУЗКА МОЗГА (Он уже в кэше, запустится быстро)
model_name = "HuggingFaceTB/SmolLM-135M-Instruct"
device = 0 if torch.cuda.is_available() else -1
generator = pipeline("text-generation", model=model_name, device=device)

# 2. ДИЗАЙН (Твой градиент)
css = """
body {
    background: linear-gradient(135deg, #FF00CC 0%, #9932CC 40%, #0000FF 70%, #00FFFF 100%) !important;
    background-attachment: fixed;
}
.gradio-container {
    background: rgba(0, 0, 0, 0.7) !important;
    border-radius: 20px;
    border: 1px solid #00FFFF;
    color: white !important;
}
.quality-text {
    color: #00FFFF;
    text-shadow: 0 0 15px #00FFFF;
    font-weight: bold;
    font-size: 32px;
    text-align: center;
    margin: 20px;
}
"""

# 3. ЛОГИКА УМНОГО ЧАТА
def axis_chat(message, history):
    # Промпт для общения
    prompt = f"<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
    
    # Генерация ответа
    output = generator(prompt, max_new_tokens=150, do_sample=True, temperature=0.7)
    
    # Очистка текста от тегов
    full_text = output[0]['generated_text']
    if "<|im_start|>assistant\n" in full_text:
        answer = full_text.split("<|im_start|>assistant\n")[-1].replace("<|im_end|>", "").strip()
    else:
        answer = full_text
    return answer

# 4. СОЗДАНИЕ ИНТЕРФЕЙСА
with gr.Blocks() as demo:
    gr.HTML("<div class='quality-text'>PROJECT AXIS: EVOLVED AI</div>")
    
    # Простое и надежное создание чата
    gr.ChatInterface(fn=axis_chat)

if __name__ == "__main__":
    # Передаем CSS в launch, как просил сервер в прошлый раз
    demo.launch(css=css)