Create app.py
Browse files
app.py
CHANGED
|
@@ -2,44 +2,31 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
|
| 5 |
-
#
|
| 6 |
MODELS = [
|
| 7 |
-
# 🔵 ديب سيك الكامل
|
| 8 |
{"name": "DeepSeek V3", "url": "https://free.churchless.tech/v1/chat/completions", "model": "deepseek-chat-v3"},
|
| 9 |
{"name": "DeepSeek R1", "url": "https://api.pawan.krd/v1/chat/completions", "model": "deepseek-r1"},
|
| 10 |
{"name": "DeepSeek Coder", "url": "https://free.gpt.ge/v1/chat/completions", "model": "deepseek-coder"},
|
| 11 |
-
{"name": "DeepSeek Logic", "url": "https://free.churchless.tech/v1/chat/completions", "model": "deepseek-llm-67b-chat"},
|
| 12 |
-
|
| 13 |
-
# 🟢 جيميني المفتوح
|
| 14 |
{"name": "Gemini 1.5 Flash", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "google/gemini-flash-1.5"},
|
| 15 |
{"name": "Gemini 1.5 Pro", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "google/gemini-pro-1.5"},
|
| 16 |
-
|
| 17 |
-
# 🟣 كلاود بكل إصداراته
|
| 18 |
{"name": "Claude 3 Haiku", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "anthropic/claude-3-haiku"},
|
| 19 |
{"name": "Claude 3 Sonnet", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "anthropic/claude-3-sonnet"},
|
| 20 |
-
|
| 21 |
-
# 🟡 باقي الأقوى
|
| 22 |
{"name": "Llama 3.3 70B", "url": "https://api.pawan.krd/v1/chat/completions", "model": "llama-3.3-70b"},
|
| 23 |
{"name": "Mistral 8x22B", "url": "https://free.churchless.tech/v1/chat/completions", "model": "mistralai/Mistral-8x22B-Instruct-v0.1"},
|
| 24 |
{"name": "Qwen 2 72B", "url": "https://free.gpt.ge/v1/chat/completions", "model": "qwen-2-72b-instruct"}
|
| 25 |
]
|
| 26 |
|
| 27 |
-
SYSTEM_PROMPT = """أنت عبقري، مساعد ذكي عربي شامل. أجب
|
| 28 |
|
| 29 |
def chat_response(message, history):
|
| 30 |
headers = {"Content-Type": "application/json"}
|
| 31 |
-
|
| 32 |
payload = {
|
| 33 |
"model": "",
|
| 34 |
-
"messages": [
|
| 35 |
-
{"role": "system", "content": SYSTEM_PROMPT},
|
| 36 |
-
{"role": "user", "content": message}
|
| 37 |
-
],
|
| 38 |
"temperature": 0.75,
|
| 39 |
"max_tokens": 1200
|
| 40 |
}
|
| 41 |
|
| 42 |
-
# نجرب كل نموذج حتى نحصل على إجابة
|
| 43 |
for model in MODELS:
|
| 44 |
try:
|
| 45 |
payload["model"] = model["model"]
|
|
@@ -49,17 +36,15 @@ def chat_response(message, history):
|
|
| 49 |
return f"🤖 {model['name']}:\n\n{data['choices'][0]['message']['content'].strip()}"
|
| 50 |
except:
|
| 51 |
continue
|
|
|
|
| 52 |
|
| 53 |
-
return "⚠️ جميع المصادر مشغولة حالياً، الرجاء المحاولة بعد دقيقة."
|
| 54 |
-
|
| 55 |
-
# الواجهة العربية
|
| 56 |
demo = gr.ChatInterface(
|
| 57 |
fn=chat_response,
|
| 58 |
-
title="🤖 عبقري - النظام الشامل
|
| 59 |
-
description="ديب سيك
|
| 60 |
theme=gr.themes.Soft(primary_hue="indigo"),
|
| 61 |
chatbot=gr.Chatbot(height=620, rtl=True),
|
| 62 |
-
textbox=gr.Textbox(placeholder="اكتب سؤالك هنا
|
| 63 |
submit_btn="إرسال", clear_btn="مسح", retry_btn="إعادة المحاولة"
|
| 64 |
)
|
| 65 |
|
|
|
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
|
| 5 |
+
# ✅ كل النماذج الكاملة والمجانية
|
| 6 |
MODELS = [
|
|
|
|
| 7 |
{"name": "DeepSeek V3", "url": "https://free.churchless.tech/v1/chat/completions", "model": "deepseek-chat-v3"},
|
| 8 |
{"name": "DeepSeek R1", "url": "https://api.pawan.krd/v1/chat/completions", "model": "deepseek-r1"},
|
| 9 |
{"name": "DeepSeek Coder", "url": "https://free.gpt.ge/v1/chat/completions", "model": "deepseek-coder"},
|
|
|
|
|
|
|
|
|
|
| 10 |
{"name": "Gemini 1.5 Flash", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "google/gemini-flash-1.5"},
|
| 11 |
{"name": "Gemini 1.5 Pro", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "google/gemini-pro-1.5"},
|
|
|
|
|
|
|
| 12 |
{"name": "Claude 3 Haiku", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "anthropic/claude-3-haiku"},
|
| 13 |
{"name": "Claude 3 Sonnet", "url": "https://openrouter.ai/api/v1/chat/completions", "model": "anthropic/claude-3-sonnet"},
|
|
|
|
|
|
|
| 14 |
{"name": "Llama 3.3 70B", "url": "https://api.pawan.krd/v1/chat/completions", "model": "llama-3.3-70b"},
|
| 15 |
{"name": "Mistral 8x22B", "url": "https://free.churchless.tech/v1/chat/completions", "model": "mistralai/Mistral-8x22B-Instruct-v0.1"},
|
| 16 |
{"name": "Qwen 2 72B", "url": "https://free.gpt.ge/v1/chat/completions", "model": "qwen-2-72b-instruct"}
|
| 17 |
]
|
| 18 |
|
| 19 |
+
SYSTEM_PROMPT = """أنت عبقري، مساعد ذكي عربي شامل. أجب بوضوح، دقة، منطق، وبأسلوب سلس ومفهوم."""
|
| 20 |
|
| 21 |
def chat_response(message, history):
|
| 22 |
headers = {"Content-Type": "application/json"}
|
|
|
|
| 23 |
payload = {
|
| 24 |
"model": "",
|
| 25 |
+
"messages": [{"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": message}],
|
|
|
|
|
|
|
|
|
|
| 26 |
"temperature": 0.75,
|
| 27 |
"max_tokens": 1200
|
| 28 |
}
|
| 29 |
|
|
|
|
| 30 |
for model in MODELS:
|
| 31 |
try:
|
| 32 |
payload["model"] = model["model"]
|
|
|
|
| 36 |
return f"🤖 {model['name']}:\n\n{data['choices'][0]['message']['content'].strip()}"
|
| 37 |
except:
|
| 38 |
continue
|
| 39 |
+
return "⚠️ جميع المصادر مشغولة، جرب بعد دقيقة."
|
| 40 |
|
|
|
|
|
|
|
|
|
|
| 41 |
demo = gr.ChatInterface(
|
| 42 |
fn=chat_response,
|
| 43 |
+
title="🤖 عبقري - النظام الشامل",
|
| 44 |
+
description="ديب سيك • جيميني • كلاود • لاما • ميكسترال • كيوين",
|
| 45 |
theme=gr.themes.Soft(primary_hue="indigo"),
|
| 46 |
chatbot=gr.Chatbot(height=620, rtl=True),
|
| 47 |
+
textbox=gr.Textbox(placeholder="اكتب سؤالك هنا...", rtl=True),
|
| 48 |
submit_btn="إرسال", clear_btn="مسح", retry_btn="إعادة المحاولة"
|
| 49 |
)
|
| 50 |
|