Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,26 +7,25 @@ app = Flask(__name__)
|
|
| 7 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 8 |
API_URL = "https://router.huggingface.co/v1/chat/completions"
|
| 9 |
|
| 10 |
-
#
|
| 11 |
MODELLER = [
|
| 12 |
"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "deepcogito/cogito-671b-v2.1-FP8",
|
| 13 |
-
"deepseek-ai/DeepSeek-
|
| 14 |
-
"
|
| 15 |
-
"openai/gpt-oss-120b", "
|
| 16 |
-
"
|
| 17 |
-
"
|
| 18 |
-
"
|
| 19 |
-
"
|
| 20 |
-
"
|
| 21 |
-
"
|
| 22 |
-
"
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
-
"
|
| 26 |
-
"
|
| 27 |
-
"
|
| 28 |
-
"
|
| 29 |
-
"mistralai/Mistral-7B-Instruct-v0.2", "microsoft/Phi-3-mini-4k-instruct"
|
| 30 |
]
|
| 31 |
|
| 32 |
model_sayaci = 0
|
|
@@ -39,44 +38,39 @@ def handle_request():
|
|
| 39 |
|
| 40 |
try:
|
| 41 |
data = request.get_json()
|
| 42 |
-
istatistikler = data.get("istatistikler", "
|
| 43 |
|
| 44 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
| 45 |
payload = {
|
| 46 |
"model": secilen_model,
|
| 47 |
"messages": [
|
| 48 |
-
{"role": "system", "content": "Sen
|
| 49 |
-
{"role": "user", "content":
|
| 50 |
],
|
| 51 |
-
"max_tokens":
|
| 52 |
"temperature": 0.0
|
| 53 |
}
|
| 54 |
|
| 55 |
-
response = requests.post(API_URL, headers=headers, json=payload, timeout=
|
| 56 |
-
|
| 57 |
-
# Limit sorguları
|
| 58 |
-
kalan = response.headers.get("x-ratelimit-remaining-requests", "Gizli")
|
| 59 |
-
toplam = response.headers.get("x-ratelimit-limit-requests", "Gizli")
|
| 60 |
|
| 61 |
if response.status_code == 200:
|
| 62 |
-
|
|
|
|
| 63 |
|
| 64 |
-
# Gevezelik temizliği
|
| 65 |
-
if "</think>" in cevap:
|
| 66 |
-
|
| 67 |
-
cevap = re.sub(r'(?i)(okay|let|here|rating|score|analysis).*', '', cevap).strip()
|
| 68 |
|
| 69 |
return jsonify({
|
| 70 |
"model": secilen_model,
|
| 71 |
"puanlar": cevap.replace(".", ","),
|
| 72 |
-
"
|
| 73 |
-
"toplam_limit": toplam
|
| 74 |
})
|
| 75 |
-
|
| 76 |
-
|
| 77 |
|
| 78 |
except Exception as e:
|
| 79 |
-
return jsonify({"error": str(e)
|
| 80 |
|
| 81 |
if __name__ == "__main__":
|
| 82 |
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 7 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 8 |
API_URL = "https://router.huggingface.co/v1/chat/completions"
|
| 9 |
|
| 10 |
+
# HATASIZ VE REYTİNG ODAKLI 50 MODEL
|
| 11 |
MODELLER = [
|
| 12 |
"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "deepcogito/cogito-671b-v2.1-FP8",
|
| 13 |
+
"deepseek-ai/DeepSeek-V3.2-Exp", "Qwen/Qwen3.5-397B-A17B", "Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8",
|
| 14 |
+
"meta-llama/Llama-3.3-70B-Instruct", "deepseek-ai/DeepSeek-R1", "google/gemma-3-27b-it",
|
| 15 |
+
"openai/gpt-oss-120b", "Qwen/QwQ-32B", "meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
| 16 |
+
"baidu/ERNIE-4.5-300B-A47B-Base-PT", "moonshotai/Kimi-K2.5", "deepseek-ai/DeepSeek-V3",
|
| 17 |
+
"mistralai/Mistral-Small-2409", "Qwen/Qwen2.5-72B-Instruct", "meta-llama/Llama-3.1-70B-Instruct",
|
| 18 |
+
"CohereLabs/c4ai-command-a-03-2025", "meta-llama/Llama-3.2-3B-Instruct", "google/gemma-3n-E4B-it",
|
| 19 |
+
"Qwen/Qwen3-235B-A22B-Thinking-2507", "CohereLabs/aya-expanse-32b", "meta-llama/Meta-Llama-3-70B-Instruct",
|
| 20 |
+
"allenai/Olmo-3.1-32B-Instruct", "Qwen/Qwen2.5-Coder-32B-Instruct", "mistralai/Mistral-7B-Instruct-v0.2",
|
| 21 |
+
"meta-llama/Llama-3.1-8B-Instruct", "nvidia/NVIDIA-Nemotron-Nano-9B-v2", "Qwen/Qwen3-8B",
|
| 22 |
+
"allenai/Olmo-3.1-32B-Think", "CohereLabs/c4ai-command-r-08-2024", "meta-llama/Llama-3.2-1B-Instruct",
|
| 23 |
+
"Qwen/Qwen3-32B", "google/gemma-2-9b-it", "mistralai/Mistral-Nemo-Instruct-2407",
|
| 24 |
+
"microsoft/Phi-3.5-mini-instruct", "meta-llama/Llama-Guard-3-8B", "Qwen/Qwen2.5-7B-Instruct",
|
| 25 |
+
"allenai/Olmo-3-7B-Instruct", "CohereLabs/c4ai-command-r7b-12-2024", "Qwen/Qwen3-14B",
|
| 26 |
+
"google/gemma-2-2b-it", "meta-llama/Llama-3-8B-Instruct", "Qwen/Qwen2.5-Coder-7B-Instruct",
|
| 27 |
+
"mistralai/Pixtral-12B-2409", "Qwen/Qwen3-Next-80B-A3B-Instruct", "google/gemma-3-4b-it",
|
| 28 |
+
"meta-llama/Llama-3.1-405B-Instruct-FP8", "deepseek-ai/DeepSeek-V2.5", "Qwen/Qwen2.5-1.5B-Instruct"
|
|
|
|
| 29 |
]
|
| 30 |
|
| 31 |
model_sayaci = 0
|
|
|
|
| 38 |
|
| 39 |
try:
|
| 40 |
data = request.get_json()
|
| 41 |
+
istatistikler = data.get("istatistikler", "")
|
| 42 |
|
| 43 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
| 44 |
payload = {
|
| 45 |
"model": secilen_model,
|
| 46 |
"messages": [
|
| 47 |
+
{"role": "system", "content": "Sen SADECE istatistiklere göre 4,0-10,0 arası puan veren bir robotsun. Yorum yasak. Sadece 'İsim: Puan' yaz."},
|
| 48 |
+
{"role": "user", "content": istatistikler}
|
| 49 |
],
|
| 50 |
+
"max_tokens": 100,
|
| 51 |
"temperature": 0.0
|
| 52 |
}
|
| 53 |
|
| 54 |
+
response = requests.post(API_URL, headers=headers, json=payload, timeout=30)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
if response.status_code == 200:
|
| 57 |
+
json_data = response.json()
|
| 58 |
+
cevap = json_data['choices'][0]['message']['content']
|
| 59 |
|
| 60 |
+
# Gevezelik temizliği
|
| 61 |
+
if "</think>" in cevap: cevap = cevap.split("</think>")[-1]
|
| 62 |
+
cevap = re.sub(r'(?i)(okay|let|here|rating|score|analysis|sure).*', '', cevap).strip()
|
|
|
|
| 63 |
|
| 64 |
return jsonify({
|
| 65 |
"model": secilen_model,
|
| 66 |
"puanlar": cevap.replace(".", ","),
|
| 67 |
+
"index": model_sayaci # Godot'ya kaçıncıda olduğunu söyler
|
|
|
|
| 68 |
})
|
| 69 |
+
|
| 70 |
+
return jsonify({"error": "Hata", "hatali_model": secilen_model}), response.status_code
|
| 71 |
|
| 72 |
except Exception as e:
|
| 73 |
+
return jsonify({"error": str(e)}), 500
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
| 76 |
app.run(host="0.0.0.0", port=7860)
|