from flask import Flask, request, jsonify import requests import os import re app = Flask(__name__) # Hugging Face Ayarları HF_TOKEN = os.getenv("HF_TOKEN") API_URL = "https://router.huggingface.co/v1/chat/completions" # ÇALIŞAN ELİT 50 MODEL MODELLER = [ "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "deepcogito/cogito-671b-v2.1-FP8", "deepseek-ai/DeepSeek-V3.2-Exp", "Qwen/Qwen3.5-397B-A17B", "Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8", "meta-llama/Llama-3.3-70B-Instruct", "deepseek-ai/DeepSeek-R1", "google/gemma-3-27b-it", "openai/gpt-oss-120b", "Qwen/QwQ-32B", "meta-llama/Llama-4-Scout-17B-16E-Instruct", "baidu/ERNIE-4.5-300B-A47B-Base-PT", "moonshotai/Kimi-K2.5", "deepseek-ai/DeepSeek-V3", "mistralai/Mistral-Small-2409", "Qwen/Qwen2.5-72B-Instruct", "meta-llama/Llama-3.1-70B-Instruct", "CohereLabs/c4ai-command-a-03-2025", "meta-llama/Llama-3.2-3B-Instruct", "google/gemma-3n-E4B-it", "Qwen/Qwen3-235B-A22B-Thinking-2507", "CohereLabs/aya-expanse-32b", "meta-llama/Meta-Llama-3-70B-Instruct", "allenai/Olmo-3.1-32B-Instruct", "Qwen/Qwen2.5-Coder-32B-Instruct", "mistralai/Mistral-7B-Instruct-v0.2", "meta-llama/Llama-3.1-8B-Instruct", "nvidia/NVIDIA-Nemotron-Nano-9B-v2", "Qwen/Qwen3-8B", "allenai/Olmo-3.1-32B-Think", "CohereLabs/c4ai-command-r-08-2024", "meta-llama/Llama-3.2-1B-Instruct", "Qwen/Qwen3-32B", "google/gemma-2-9b-it", "mistralai/Mistral-Nemo-Instruct-2407", "microsoft/Phi-3.5-mini-instruct", "meta-llama/Llama-Guard-3-8B", "Qwen/Qwen2.5-7B-Instruct", "allenai/Olmo-3-7B-Instruct", "CohereLabs/c4ai-command-r7b-12-2024", "Qwen/Qwen3-14B", "google/gemma-2-2b-it", "meta-llama/Llama-3-8B-Instruct", "Qwen/Qwen2.5-Coder-7B-Instruct", "mistralai/Pixtral-12B-2409", "Qwen/Qwen3-Next-80B-A3B-Instruct", "google/gemma-3-4b-it", "meta-llama/Llama-3.1-405B-Instruct-FP8", "deepseek-ai/DeepSeek-V2.5", "Qwen/Qwen2.5-1.5B-Instruct" ] model_sayaci = 0 @app.route("/", methods=["POST"]) def handle_request(): global model_sayaci secilen_model = MODELLER[model_sayaci % len(MODELLER)] model_sayaci += 1 try: data = request.get_json() istatistikler = data.get("istatistikler", "") headers = {"Authorization": f"Bearer {HF_TOKEN}"} payload = { "model": secilen_model, "messages": [ {"role": "system", "content": "SADECE 'İsim: Puan' formatında cevap ver. 4.0-10.0 arası."}, {"role": "user", "content": istatistikler} ], "max_tokens": 80, "temperature": 0.0 } response = requests.post(API_URL, headers=headers, json=payload, timeout=25) if response.status_code == 200: cevap = response.json()['choices'][0]['message']['content'] if "" in cevap: cevap = cevap.split("")[-1] cevap = re.sub(r'(?i)(okay|let|here|rating|score|analysis|sure|certainly).*', '', cevap).strip() return jsonify({ "model": secilen_model, "puanlar": cevap.replace(".", ","), "sayac": model_sayaci }) return jsonify({"error": f"Model Hatası: {response.status_code}"}), response.status_code except Exception as e: return jsonify({"error": str(e)}), 500 if __name__ == "__main__": # HF için PORT 7860 şarttır! app.run(host="0.0.0.0", port=7860)