AnesKAM commited on
Commit
560cafa
·
verified ·
1 Parent(s): 4927a8d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +106 -56
main.py CHANGED
@@ -1,29 +1,21 @@
1
  import os
2
- import random
3
  import threading
4
  import time
5
- from fastapi import FastAPI, Request
6
- from fastapi.responses import HTMLResponse, JSONResponse
7
- from pydantic import BaseModel
8
- from openai import OpenAI # المكتبة الرسمية
9
 
10
  app = FastAPI()
11
 
12
- # قائمة مفاتيحك (بما أن السبيس خاص)
13
- KEY_LIST = [
14
- "sk-scitely-052764c408c3c08987d77d8f7576bcc9815c81f2874c97f5fb310fd4f40fb534",
15
- "sk-scitely-052764c408c3c08987d77d8f7576bcc9815c81f2874c97f5fb310fd4f40fb534"
16
- ]
17
 
18
- class ChatRequest(BaseModel):
19
- message: str
20
- tool: str = "Chat"
21
-
22
- # ثغرة عدم النوم
23
  def keep_alive():
24
  while True:
25
  try:
26
- import requests
27
  requests.get("http://localhost:7860/")
28
  except:
29
  pass
@@ -31,46 +23,104 @@ def keep_alive():
31
 
32
  threading.Thread(target=keep_alive, daemon=True).start()
33
 
34
- @app.post("/api/chat")
35
- async def chat_endpoint(req: ChatRequest):
36
- try:
37
- if not KEY_LIST:
38
- return JSONResponse({"error": "No API Keys found!"}, status_code=500)
39
-
40
- # اختيار مفتاح عشوائي
41
- selected_key = random.choice(KEY_LIST)
42
-
43
- # تهيئة العميل (Client) باستخدام الإعدادات التي أرسلتها
44
- client = OpenAI(
45
- api_key=selected_key,
46
- base_url="https://api.scitely.com/v1"
47
- )
48
-
49
- # تحديد الموديل
50
- model_id = "qwen3-32b"
51
- if req.tool == "Code Lab":
52
- model_id = "qwen3-coder-plus"
53
- elif req.tool == "PowerPoint":
54
- model_id = "deepseek-v3.2"
55
-
56
- # طلب الرد من Scitely
57
- response = client.chat.completions.create(
58
- model=model_id,
59
- messages=[
60
- {"role": "system", "content": "You are Ginisi Elite by AnesNT."},
61
- {"role": "user", "content": req.message}
62
- ],
63
- temperature=0.7
64
- )
65
-
66
- # إرسال الرد للواجهة
67
- return {"choices": [{"message": {"content": response.choices[0].message.content}}]}
68
-
69
- except Exception as e:
70
- print(f"Error: {str(e)}")
71
- return JSONResponse({"error": str(e)}, status_code=500)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  @app.get("/", response_class=HTMLResponse)
74
  async def get_index():
75
- with open("index.html", "r", encoding="utf-8") as f:
76
- return f.read()
 
 
 
 
1
  import os
 
2
  import threading
3
  import time
4
+ import requests
5
+ from fastapi import FastAPI
6
+ from fastapi.responses import HTMLResponse
7
+ import uvicorn
8
 
9
  app = FastAPI()
10
 
11
+ # --- إعدادات أنس ---
12
+ MY_API_KEY = "sk-scitely-YOUR_KEY_HERE" # ضع مفتاحك هنا
 
 
 
13
 
14
+ # ثغرة منع النوم (Stay Alive)
 
 
 
 
15
  def keep_alive():
16
  while True:
17
  try:
18
+ # محاكاة زيارة للسبيس ليبقى شغالاً 24/7
19
  requests.get("http://localhost:7860/")
20
  except:
21
  pass
 
23
 
24
  threading.Thread(target=keep_alive, daemon=True).start()
25
 
26
+ # الواجهة الاحترافية مدمجة (AnesNT UI)
27
+ HTML_CONTENT = f"""
28
+ <!DOCTYPE html>
29
+ <html lang="ar" dir="rtl">
30
+ <head>
31
+ <meta charset="UTF-8">
32
+ <title>Ginisi Elite | Powered by AnesNT</title>
33
+ <script src="https://cdn.tailwindcss.com"></script>
34
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
35
+ <style>
36
+ body {{ background: #050505; color: #fff; font-family: 'Segoe UI', sans-serif; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }}
37
+ .bridge-overlay {{ position: fixed; inset: 0; background: #000; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }}
38
+ iframe {{ width: 100%; max-width: 600px; height: 400px; border-radius: 20px; border: 1px solid #333; background: white; }}
39
+ .chat-area {{ flex: 1; overflow-y: auto; padding: 30px; scroll-behavior: smooth; }}
40
+ .input-box {{ background: #111; border: 1px solid #222; border-radius: 25px; padding: 5px 15px; margin: 20px; display: flex; align-items: center; }}
41
+ .ai-msg {{ background: rgba(59, 130, 246, 0.1); border: 1px solid #1d4ed8; padding: 15px; border-radius: 20px; margin-bottom: 15px; align-self: flex-start; max-width: 80%; }}
42
+ .user-msg {{ background: #1a1a1a; border: 1px solid #333; padding: 15px; border-radius: 20px; margin-bottom: 15px; align-self: flex-end; max-width: 80%; color: #3b82f6; }}
43
+ </style>
44
+ </head>
45
+ <body>
46
+
47
+ <div id="bridge" class="bridge-overlay">
48
+ <h1 class="text-2xl font-bold mb-4 text-blue-500">نظام GINISI ELITE</h1>
49
+ <p class="text-gray-400 mb-6 text-sm text-center">يا بطل، Scitely تطلب التحقق. حل الاختبار في الأسفل ثم اضغط انطلاق.</p>
50
+ <iframe src="https://console.scitely.com"></iframe>
51
+ <button onclick="unlock()" class="mt-8 px-12 py-3 bg-blue-600 rounded-full font-bold shadow-lg hover:bg-blue-700 transition">انطلاق المشروع 🚀</button>
52
+ </div>
53
+
54
+ <header class="p-4 border-b border-gray-900 flex justify-between items-center bg-black">
55
+ <div class="flex items-center gap-3">
56
+ <div class="w-10 h-10 border-2 border-blue-500 rounded-lg flex items-center justify-center font-bold text-blue-500">G</div>
57
+ <span class="font-bold text-xl">Ginisi <span class="text-blue-500">Elite</span></span>
58
+ </div>
59
+ <div class="text-[10px] text-gray-600 font-mono tracking-widest">DOCKER MODE | ANESNT</div>
60
+ </header>
61
+
62
+ <main id="chat-box" class="chat-area flex flex-col">
63
+ <div class="ai-msg">مرحباً يا <b>أنس</b>. أنا Ginisi، مطور من قبل AnesNT. كيف أساعدك في برمجياتك اليوم؟</div>
64
+ </main>
65
+
66
+ <footer class="bg-black/50 backdrop-blur">
67
+ <div class="max-w-4xl mx-auto input-box">
68
+ <input id="user-input" type="text" class="flex-1 bg-transparent border-none outline-none p-3 text-white" placeholder="أدخل أمرك هنا..." onkeypress="if(event.key === 'Enter') sendMsg()">
69
+ <button onclick="sendMsg()" class="w-10 h-10 bg-blue-600 rounded-full flex items-center justify-center hover:bg-blue-700 transition">
70
+ <i class="fas fa-paper-plane text-white text-sm"></i>
71
+ </button>
72
+ </div>
73
+ </footer>
74
+
75
+ <script>
76
+ const API_KEY = "{MY_API_KEY}";
77
+
78
+ function unlock() {{
79
+ document.getElementById('bridge').style.display = 'none';
80
+ }}
81
+
82
+ async function sendMsg() {{
83
+ const input = document.getElementById('user-input');
84
+ const box = document.getElementById('chat-box');
85
+ const msg = input.value.trim();
86
+ if (!msg) return;
87
+
88
+ box.innerHTML += `<div class="user-msg"><b>أنس:</b> \${{msg}}</div>`;
89
+ input.value = "";
90
+ box.scrollTop = box.scrollHeight;
91
+
92
+ try {{
93
+ // الطلب المباشر من المتصفح (Client-side) لتجاوز حظر الدوكر والكلاودفلار
94
+ const response = await fetch('https://api.scitely.com/v1/chat/completions', {{
95
+ method: 'POST',
96
+ headers: {{
97
+ 'Content-Type': 'application/json',
98
+ 'Authorization': 'Bearer ' + API_KEY
99
+ }},
100
+ body: JSON.stringify({{
101
+ model: 'deepseek-v3.2',
102
+ messages: [{{role: 'user', content: msg}}]
103
+ }})
104
+ }});
105
+
106
+ const data = await response.json();
107
+ const reply = data.choices[0].message.content;
108
+
109
+ box.innerHTML += `<div class="ai-msg"><b>Ginisi:</b> \${{reply}}</div>`;
110
+ }} catch (err) {{
111
+ box.innerHTML += `<div class="text-red-500 text-xs text-center">⚠️ فشل الاتصال. تأكد من حل اختبار Cloudflare.</div>`;
112
+ }}
113
+ box.scrollTop = box.scrollHeight;
114
+ }}
115
+ </script>
116
+ </body>
117
+ </html>
118
+ """
119
 
120
  @app.get("/", response_class=HTMLResponse)
121
  async def get_index():
122
+ return HTML_CONTENT
123
+
124
+ if __name__ == "__main__":
125
+ # هذا السطر مهم جداً للدوكر في Hugging Face
126
+ uvicorn.run(app, host="0.0.0.0", port=7860)