File size: 1,107 Bytes
dac1b2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
from huggingface_hub import InferenceClient

# ده المحرك اللي بيفكر وبيبرمج
client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")

def generate_code(idea):
    # بنقول للذكاء الاصطناعي يبرمج فكرتك فوراً
    prompt = f"Write a complete, ready-to-use code for: {idea}. Only output the code."
    response = ""
    for message in client.chat_completion([{"role": "user", "content": prompt}], max_tokens=3000, stream=True):
        response += message.choices[0].delta.content
    return response

# شكل الموقع بتاعك
with gr.Blocks() as demo:
    gr.Markdown("# 🚀 مبرمج كرم الذكي")
    gr.Markdown("اكتب فكرتك وسأقوم ببرمجتها لك في ثوانٍ!")
    idea = gr.Textbox(label="ماذا تريد أن أصنع لك؟", placeholder="مثلاً: لعبة ثعبان بلغة Python")
    btn = gr.Button("ابدأ البرمجة الآن")
    result = gr.Code(label="الكود الناتج")
    
    btn.click(fn=generate_code, inputs=idea, outputs=result)

demo.launch()