Spaces:
Runtime error
Runtime error
Download app.py from smart-code-maker/my-ultimate-coder: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/smart-code-maker/my-ultimate-coder/resolve/main/app.py
- Command line
-
hf download hf://spaces/smart-code-maker/my-ultimate-coder/app.py
-
curl -L -o app.py https://huggingface.co/spaces/smart-code-maker/my-ultimate-coder/resolve/main/app.py
1.11 kB
| 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() |