Ensarioglu commited on
Commit
9f6e9c1
·
verified ·
1 Parent(s): 0b2e460

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -37
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
- # SENİN LİSTENDEN SEÇİLEN, 402 VERMEYEN EN GÜÇLÜ 50 MODEL
11
  MODELLER = [
12
  "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "deepcogito/cogito-671b-v2.1-FP8",
13
- "deepseek-ai/DeepSeek-R1", "Qwen/Qwen3.5-397B-A17B", "Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8",
14
- "deepseek-ai/DeepSeek-V3.2-Exp", "zai-org/GLM-5", "baidu/ERNIE-4.5-300B-A47B-Base-PT",
15
- "openai/gpt-oss-120b", "google/gemma-3-27b-it", "meta-llama/Llama-3.3-70B-Instruct",
16
- "Qwen/Qwen3-235B-A22B-Thinking-2507", "CohereLabs/c4ai-command-a-03-2025", "moonshotai/Kimi-K2.5",
17
- "meta-llama/Llama-4-Scout-17B-16E-Instruct", "deepseek-ai/DeepSeek-V3", "Qwen/QwQ-32B",
18
- "google/gemma-3n-E4B-it", "ServiceNow-AI/Apriel-1.6-15b-Thinker", "EssentialAI/rnj-1-instruct",
19
- "alpindale/WizardLM-2-8x22B", "mistralai/Mistral-Small-2409", "meta-llama/Llama-3.1-70B-Instruct",
20
- "Qwen/Qwen2.5-72B-Instruct", "zai-org/GLM-4.7-Flash", "CohereLabs/aya-expanse-32b",
21
- "Sao10K/L3-70B-Euryale-v2.1", "allenai/Olmo-3.1-32B-Think", "deepcogito/cogito-671b-v2.1",
22
- "Qwen/Qwen3-Next-80B-A3B-Thinking", "meta-llama/Meta-Llama-3-70B-Instruct",
23
- "tokyotech-llm/Llama-3.3-Swallow-70B-Instruct-v0.4", "utter-project/EuroLLM-22B-Instruct-2512",
24
- "zai-org/GLM-4.6V", "Qwen/Qwen3-VL-235B-A22B-Thinking", "moonshotai/Kimi-K2-Thinking",
25
- "deepseek-ai/DeepSeek-V3.1-Terminus", "allenai/Olmo-3.1-32B-Instruct", "aisingapore/Qwen-SEA-LION-v4-32B-IT",
26
- "NousResearch/Hermes-2-Pro-Llama-3-8B", "Qwen/Qwen2.5-Coder-32B-Instruct", "baidu/ERNIE-4.5-VL-424B-A47B-Base-PT",
27
- "Sao10K/L3-8B-Stheno-v3.2", "nvidia/NVIDIA-Nemotron-Nano-9B-v2", "arcee-ai/Trinity-Mini",
28
- "swiss-ai/Apertus-70B-Instruct-2509", "Qwen/Qwen3-8B", "meta-llama/Llama-3.1-8B-Instruct",
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", "Veri yok")
43
 
44
  headers = {"Authorization": f"Bearer {HF_TOKEN}"}
45
  payload = {
46
  "model": secilen_model,
47
  "messages": [
48
- {"role": "system", "content": "Sen bir robotsun. Görevin: İstatistiklere bakıp 4.0 ile 10.0 arasında puan vermek. SADECE 'İsim: Puan' formatında yaz. Yorum yapma, açıklama yapma, cümle kurma."},
49
- {"role": "user", "content": f"Reyting ver (4.0-10.0):\n{istatistikler}"}
50
  ],
51
- "max_tokens": 150,
52
  "temperature": 0.0
53
  }
54
 
55
- response = requests.post(API_URL, headers=headers, json=payload, timeout=50)
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
- cevap = response.json()['choices'][0]['message']['content']
 
63
 
64
- # Gevezelik temizliği (Think ve İngilizce girişler)
65
- if "</think>" in cevap:
66
- cevap = cevap.split("</think>")[-1]
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
- "kalan_hak": kalan,
73
- "toplam_limit": toplam
74
  })
75
- else:
76
- return jsonify({"error": f"Hata: {response.status_code}", "hatali_model": secilen_model}), response.status_code
77
 
78
  except Exception as e:
79
- return jsonify({"error": str(e), "hatali_model": secilen_model}), 500
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)