Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
def chat_with_ai(prompt):
|
| 6 |
+
# استخدام محرك Hugging Face القوي والمجاني مباشرة
|
| 7 |
+
# هذا الموديل متخصص جداً في المعادلات والأكواد
|
| 8 |
+
API_URL = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 9 |
+
# يمكنك وضع توكن خاص بك هنا لزيادة السرعة، أو استخدامه هكذا
|
| 10 |
+
headers = {"Authorization": "Bearer hf_xxxxxxxxxxxxxxxxxxxx"} # اختيار اختياري
|
| 11 |
+
|
| 12 |
+
payload = {"inputs": prompt, "parameters": {"max_new_tokens": 1000}}
|
| 13 |
+
response = requests.post(API_URL, json=payload)
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
return response.json()[0]['generated_text']
|
| 17 |
+
except:
|
| 18 |
+
return "النظام قيد التحضير، يرجى المحاولة بعد لحظات..."
|
| 19 |
+
|
| 20 |
+
gr.ChatInterface(
|
| 21 |
+
chat_with_ai,
|
| 22 |
+
title="Saad AI - Zain Iraq Edition",
|
| 23 |
+
description="نظام سعد الخاص للمعادلات والأكواد"
|
| 24 |
+
).launch()
|