File size: 1,804 Bytes
9cf6111
 
5259f50
70323ec
 
 
 
44df078
5259f50
fc0c78d
 
4f5b2da
 
5259f50
4f5b2da
5259f50
 
 
fc0c78d
56c42d2
70323ec
56c42d2
70323ec
 
5259f50
56c42d2
70323ec
56c42d2
70323ec
 
fc0c78d
5259f50
70323ec
 
 
 
fc0c78d
70323ec
fc0c78d
 
 
70323ec
 
fc0c78d
 
70323ec
 
fc0c78d
70323ec
 
44df078
5259f50
70323ec
44df078
4f5b2da
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
import gradio as gr

# MiniMax AI modeli
chat = gr.load(
    "models/MiniMaxAI/MiniMax-M1-80k",
    provider="novita"
)

# Giriş ekranı kontrol fonksiyonu
def start_chat(approved):
    if approved:
        return gr.update(visible=False), gr.update(visible=True)
    else:
        raise gr.Error("Kutucuğu işaretlemeden devam edemezsin Patron!")

# Arayüz başlatılıyor
with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as app:
    # Giriş bölümü
    with gr.Group(visible=True) as intro:
        gr.Markdown("""
        ## 🧠 AlpDroid'e Hoş Geldin!

        Bu yapay zekâ tamamen deneysel amaçlıdır.  
        Tıbbi, hukuki, finansal ya da etik kararlar için **kullanılamaz**.  
        Tüm sorumluluk kullanıcıya aittir.

        Devam etmek için onay kutusunu işaretle.
        """)
        approved = gr.Checkbox(label="✅ Okudum, Onaylıyorum")
        begin_btn = gr.Button("🚀 Sohbete Başla")

    # Chat bölümü
    with gr.Group(visible=False) as chat_section:
        chatbot = gr.Chatbot(label="🤖 AlpDroid", show_label=False)
        msg = gr.Textbox(placeholder="Bir mesaj yaz...", scale=4)
        send = gr.Button("Gönder")

        file = gr.File(label="📎 Ek dosya (isteğe bağlı)", file_types=[".txt", ".csv", ".json", ".md"])

        state = gr.State([])

        def user_submit(message, history):
            history = history + [[message, None]]
            return "", history

        def model_response(history, file):
            return chat(history=history)

        send.click(fn=user_submit, inputs=[msg, state], outputs=[msg, state])
        send.click(fn=model_response, inputs=[state, file], outputs=[chatbot])

    # Geçiş
    begin_btn.click(fn=start_chat, inputs=[approved], outputs=[intro, chat_section])

app.launch()