Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
# ده المحرك اللي بيفكر وبيبرمج
|
| 5 |
+
client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 6 |
+
|
| 7 |
+
def generate_code(idea):
|
| 8 |
+
# بنقول للذكاء الاصطناعي يبرمج فكرتك فوراً
|
| 9 |
+
prompt = f"Write a complete, ready-to-use code for: {idea}. Only output the code."
|
| 10 |
+
response = ""
|
| 11 |
+
for message in client.chat_completion([{"role": "user", "content": prompt}], max_tokens=3000, stream=True):
|
| 12 |
+
response += message.choices[0].delta.content
|
| 13 |
+
return response
|
| 14 |
+
|
| 15 |
+
# شكل الموقع بتاعك
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
gr.Markdown("# 🚀 مبرمج كرم الذكي")
|
| 18 |
+
gr.Markdown("اكتب فكرتك وسأقوم ببرمجتها لك في ثوانٍ!")
|
| 19 |
+
idea = gr.Textbox(label="ماذا تريد أن أصنع لك؟", placeholder="مثلاً: لعبة ثعبان بلغة Python")
|
| 20 |
+
btn = gr.Button("ابدأ البرمجة الآن")
|
| 21 |
+
result = gr.Code(label="الكود الناتج")
|
| 22 |
+
|
| 23 |
+
btn.click(fn=generate_code, inputs=idea, outputs=result)
|
| 24 |
+
|
| 25 |
+
demo.launch()
|