Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,48 @@
|
|
|
|
|
| 1 |
import requests
|
| 2 |
|
| 3 |
-
# AlpDroid prompt'
|
| 4 |
alp_droid_prompt = requests.get(
|
| 5 |
"https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
|
| 6 |
).text
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
user_input = input("Sen: ")
|
| 10 |
-
|
| 11 |
-
# API bilgileri
|
| 12 |
API_KEY = "fw_3ZHAHBUKKgDkDYqkM3MTGaf6"
|
| 13 |
-
MODEL = "accounts/fireworks/models/qwen2-7b-instruct"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
],
|
| 26 |
-
"temperature": 0.7,
|
| 27 |
-
"max_tokens": 1024,
|
| 28 |
-
"stream": False
|
| 29 |
-
}
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
# AlpDroid prompt'unu GitHub'dan çek
|
| 5 |
alp_droid_prompt = requests.get(
|
| 6 |
"https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
|
| 7 |
).text
|
| 8 |
|
| 9 |
+
# API ayarları
|
|
|
|
|
|
|
|
|
|
| 10 |
API_KEY = "fw_3ZHAHBUKKgDkDYqkM3MTGaf6"
|
| 11 |
+
MODEL = "accounts/fireworks/models/qwen2-7b-instruct"
|
| 12 |
+
|
| 13 |
+
# Fireworks AI üzerinden AlpDroid çağrısı
|
| 14 |
+
def ask_alpdroid(user_input):
|
| 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 |
+
}
|
| 29 |
|
| 30 |
+
response = requests.post(
|
| 31 |
+
"https://api.fireworks.ai/inference/v1/chat/completions",
|
| 32 |
+
json=data,
|
| 33 |
+
headers=headers
|
| 34 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
# JSON'dan yanıtı çek
|
| 37 |
+
try:
|
| 38 |
+
return response.json()["choices"][0]["message"]["content"]
|
| 39 |
+
except Exception as e:
|
| 40 |
+
return f"Hata: {e}\n\nDetay: {response.text}"
|
| 41 |
|
| 42 |
+
# Gradio arayüzü (minimal)
|
| 43 |
+
gr.Interface(
|
| 44 |
+
fn=ask_alpdroid,
|
| 45 |
+
inputs=gr.Textbox(label="Senin mesajın", placeholder="AlpDroid'e ne sormak istersin?", lines=6),
|
| 46 |
+
outputs=gr.Textbox(label="AlpDroid cevabı", lines=8),
|
| 47 |
+
title="🧠 AlpDroid x Qwen2.5 (Prompt Enjekte)"
|
| 48 |
+
).launch()
|