|
import gradio as gr |
|
|
|
|
|
chat = gr.load( |
|
"models/MiniMaxAI/MiniMax-M1-80k", |
|
provider="novita" |
|
) |
|
|
|
|
|
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!") |
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as app: |
|
|
|
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") |
|
|
|
|
|
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]) |
|
|
|
|
|
begin_btn.click(fn=start_chat, inputs=[approved], outputs=[intro, chat_section]) |
|
|
|
app.launch() |