Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,42 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# MiniMax AI modeli
|
| 4 |
chat = gr.load(
|
| 5 |
"models/MiniMaxAI/MiniMax-M1-80k",
|
| 6 |
provider="novita"
|
| 7 |
)
|
| 8 |
|
| 9 |
-
# Giriş ekranı
|
| 10 |
def start_chat(approved):
|
| 11 |
if approved:
|
| 12 |
return gr.update(visible=False), gr.update(visible=True)
|
| 13 |
else:
|
| 14 |
-
raise gr.Error("
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
with gr.Blocks(theme=gr.themes.
|
| 18 |
-
# Giriş
|
| 19 |
with gr.Group(visible=True) as intro:
|
| 20 |
gr.Markdown("""
|
| 21 |
## 🧠 AlpDroid'e Hoş Geldin!
|
| 22 |
|
| 23 |
Bu yapay zekâ tamamen deneysel amaçlıdır.
|
| 24 |
Tıbbi, hukuki, finansal ya da etik kararlar için **kullanılamaz**.
|
| 25 |
-
|
| 26 |
|
| 27 |
Devam etmek için onay kutusunu işaretle.
|
| 28 |
""")
|
| 29 |
approved = gr.Checkbox(label="✅ Okudum, Onaylıyorum")
|
| 30 |
begin_btn = gr.Button("🚀 Sohbete Başla")
|
| 31 |
|
| 32 |
-
# Chat
|
| 33 |
with gr.Group(visible=False) as chat_section:
|
| 34 |
chatbot = gr.Chatbot(label="🤖 AlpDroid", show_label=False)
|
| 35 |
msg = gr.Textbox(placeholder="Bir mesaj yaz...", scale=4)
|
| 36 |
send = gr.Button("Gönder")
|
| 37 |
|
| 38 |
-
# Kullanıcı dosya eklemek isterse diye, altta bir kutu
|
| 39 |
file = gr.File(label="📎 Ek dosya (isteğe bağlı)", file_types=[".txt", ".csv", ".json", ".md"])
|
| 40 |
|
| 41 |
-
# Chat geçmişi yönetimi
|
| 42 |
state = gr.State([])
|
| 43 |
|
| 44 |
def user_submit(message, history):
|
|
@@ -51,7 +49,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="purple", dark_mode=True)) as ap
|
|
| 51 |
send.click(fn=user_submit, inputs=[msg, state], outputs=[msg, state])
|
| 52 |
send.click(fn=model_response, inputs=[state, file], outputs=[chatbot])
|
| 53 |
|
| 54 |
-
#
|
| 55 |
begin_btn.click(fn=start_chat, inputs=[approved], outputs=[intro, chat_section])
|
| 56 |
|
| 57 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# MiniMax AI modeli
|
| 4 |
chat = gr.load(
|
| 5 |
"models/MiniMaxAI/MiniMax-M1-80k",
|
| 6 |
provider="novita"
|
| 7 |
)
|
| 8 |
|
| 9 |
+
# Giriş ekranı kontrol fonksiyonu
|
| 10 |
def start_chat(approved):
|
| 11 |
if approved:
|
| 12 |
return gr.update(visible=False), gr.update(visible=True)
|
| 13 |
else:
|
| 14 |
+
raise gr.Error("Kutucuğu işaretlemeden devam edemezsin Patron!")
|
| 15 |
|
| 16 |
+
# Arayüz başlatılıyor
|
| 17 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as app:
|
| 18 |
+
# Giriş bölümü
|
| 19 |
with gr.Group(visible=True) as intro:
|
| 20 |
gr.Markdown("""
|
| 21 |
## 🧠 AlpDroid'e Hoş Geldin!
|
| 22 |
|
| 23 |
Bu yapay zekâ tamamen deneysel amaçlıdır.
|
| 24 |
Tıbbi, hukuki, finansal ya da etik kararlar için **kullanılamaz**.
|
| 25 |
+
Tüm sorumluluk kullanıcıya aittir.
|
| 26 |
|
| 27 |
Devam etmek için onay kutusunu işaretle.
|
| 28 |
""")
|
| 29 |
approved = gr.Checkbox(label="✅ Okudum, Onaylıyorum")
|
| 30 |
begin_btn = gr.Button("🚀 Sohbete Başla")
|
| 31 |
|
| 32 |
+
# Chat bölümü
|
| 33 |
with gr.Group(visible=False) as chat_section:
|
| 34 |
chatbot = gr.Chatbot(label="🤖 AlpDroid", show_label=False)
|
| 35 |
msg = gr.Textbox(placeholder="Bir mesaj yaz...", scale=4)
|
| 36 |
send = gr.Button("Gönder")
|
| 37 |
|
|
|
|
| 38 |
file = gr.File(label="📎 Ek dosya (isteğe bağlı)", file_types=[".txt", ".csv", ".json", ".md"])
|
| 39 |
|
|
|
|
| 40 |
state = gr.State([])
|
| 41 |
|
| 42 |
def user_submit(message, history):
|
|
|
|
| 49 |
send.click(fn=user_submit, inputs=[msg, state], outputs=[msg, state])
|
| 50 |
send.click(fn=model_response, inputs=[state, file], outputs=[chatbot])
|
| 51 |
|
| 52 |
+
# Geçiş
|
| 53 |
begin_btn.click(fn=start_chat, inputs=[approved], outputs=[intro, chat_section])
|
| 54 |
|
| 55 |
app.launch()
|