File size: 1,951 Bytes
9cf6111 70323ec 44df078 70323ec fc0c78d 4f5b2da 70323ec 4f5b2da 70323ec fc0c78d 56c42d2 70323ec 56c42d2 70323ec 56c42d2 70323ec 56c42d2 70323ec fc0c78d 70323ec fc0c78d 70323ec fc0c78d 70323ec fc0c78d 70323ec fc0c78d 70323ec fc0c78d 70323ec 44df078 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 56 57 |
import gradio as gr
# MiniMax AI modeli yükleniyor
chat = gr.load(
"models/MiniMaxAI/MiniMax-M1-80k",
provider="novita"
)
# Giriş ekranı kontrolü
def start_chat(approved):
if approved:
return gr.update(visible=False), gr.update(visible=True)
else:
raise gr.Error("Başlamak için kutucuğu işaretlemelisin Patron!")
# Gradio uygulaması
with gr.Blocks(theme=gr.themes.Base(primary_hue="purple", dark_mode=True)) as app:
# Giriş sayfası
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**.
Kullanım tümüyle senin sorumluluğundadır Patron.
Devam etmek için onay kutusunu işaretle.
""")
approved = gr.Checkbox(label="✅ Okudum, Onaylıyorum")
begin_btn = gr.Button("🚀 Sohbete Başla")
# Chat ekranı
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")
# Kullanıcı dosya eklemek isterse diye, altta bir kutu
file = gr.File(label="📎 Ek dosya (isteğe bağlı)", file_types=[".txt", ".csv", ".json", ".md"])
# Chat geçmişi yönetimi
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])
# Girişten sohbete geçiş
begin_btn.click(fn=start_chat, inputs=[approved], outputs=[intro, chat_section])
app.launch() |