Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,50 +1,33 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
-
# AlpDroid prompt'
|
| 5 |
alp_droid_prompt = requests.get(
|
| 6 |
"https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
|
| 7 |
).text
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
dark_theme = gr.themes.Citrus(primary_hue="gray")
|
| 12 |
-
current_theme = {"mode": "light"}
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
provider="featherless-ai",
|
| 18 |
-
)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 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 |
-
|
| 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"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|