alperall commited on
Commit
ecebbca
·
verified ·
1 Parent(s): 80efc08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -3
app.py CHANGED
@@ -1,18 +1,50 @@
1
  import gradio as gr
2
  import requests
3
 
 
4
  alp_droid_prompt = requests.get(
5
  "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
6
  ).text
7
 
 
 
 
 
 
 
8
  model = gr.load(
9
  "models/Orion-zhen/Qwen2.5-7B-Instruct-Uncensored",
10
  provider="featherless-ai",
11
  )
12
 
 
13
  def ask_alpdroid(user_input):
14
- prompt = alp_droid_prompt + "\n\n" + user_input
15
- return model(prompt)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
 
 
17
 
18
- .launch()
 
1
  import gradio as gr
2
  import requests
3
 
4
+ # AlpDroid prompt'unu çek
5
  alp_droid_prompt = requests.get(
6
  "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
7
  ).text
8
 
9
+ # Tema ayarları
10
+ light_theme = gr.themes.Citrus(primary_hue="emerald")
11
+ dark_theme = gr.themes.Citrus(primary_hue="gray")
12
+ current_theme = {"mode": "light"}
13
+
14
+ # Modeli gr.load ile al
15
  model = gr.load(
16
  "models/Orion-zhen/Qwen2.5-7B-Instruct-Uncensored",
17
  provider="featherless-ai",
18
  )
19
 
20
+ # Kullanıcı girdisine prompt'u enjekte et
21
  def ask_alpdroid(user_input):
22
+ full_prompt = alp_droid_prompt + "\n\n" + user_input
23
+ return model(full_prompt)
24
+
25
+ # Tema değiştirme (butona tıklanınca sadece mesaj verir, çünkü runtime'da tema değişmiyor)
26
+ def toggle_theme():
27
+ if current_theme["mode"] == "light":
28
+ current_theme["mode"] = "dark"
29
+ return "🌙 Dark mode aktif! Sayfayı yenile (F5)"
30
+ else:
31
+ current_theme["mode"] = "light"
32
+ return "☀️ Light mode aktif! Sayfayı yenile (F5)"
33
+
34
+ # Arayüzü başlat
35
+ with gr.Blocks(theme=light_theme) as demo:
36
+ gr.Markdown("## 🤖 AlpDroid Chat — Qwen2.5-7B + Prompt Enjeksiyonu")
37
+
38
+ theme_btn = gr.Button("🌗 Tema Değiştir")
39
+ theme_msg = gr.Textbox(label="Tema Bilgisi", interactive=False)
40
+
41
+ with gr.Row():
42
+ inp = gr.Textbox(label="Sen yaz", lines=6, placeholder="Mesajını gir...")
43
+ out = gr.Textbox(label="AlpDroid cevaplıyor...", lines=6)
44
+
45
+ send = gr.Button("Gönder")
46
 
47
+ send.click(fn=ask_alpdroid, inputs=inp, outputs=out)
48
+ theme_btn.click(fn=toggle_theme, outputs=theme_msg)
49
 
50
+ demo.launch()