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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -39
app.py CHANGED
@@ -1,50 +1,33 @@
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()
 
 
1
  import requests
2
 
3
+ # AlpDroid prompt'u çek
4
  alp_droid_prompt = requests.get(
5
  "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
6
  ).text
7
 
8
+ # Kullanıcıdan giriş al
9
+ user_input = input("Sen: ")
 
 
10
 
11
+ # API bilgileri
12
+ API_KEY = "fw_3ZHAHBUKKgDkDYqkM3MTGaf6"
13
+ MODEL = "accounts/fireworks/models/qwen2-7b-instruct" # veya kimi/kimi-1.5, mixtral, vs.
 
 
14
 
15
+ headers = {
16
+ "Authorization": f"Bearer {API_KEY}",
17
+ "Content-Type": "application/json"
18
+ }
19
 
20
+ data = {
21
+ "model": MODEL,
22
+ "messages": [
23
+ {"role": "system", "content": alp_droid_prompt},
24
+ {"role": "user", "content": user_input}
25
+ ],
26
+ "temperature": 0.7,
27
+ "max_tokens": 1024,
28
+ "stream": False
29
+ }
30
 
31
+ response = requests.post("https://api.fireworks.ai/inference/v1/chat/completions", json=data, headers=headers)
 
 
 
 
 
32
 
33
+ print("\nAlpDroid:", response.json()["choices"][0]["message"]["content"])