alperall's picture
Update app.py
5259f50 verified
raw
history blame
1.8 kB
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()