Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from openai import OpenAI | |
| import os | |
| client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) | |
| logo_file = "logo AIP.jpg" | |
| custom_css = """ | |
| @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap'); | |
| * { | |
| font-family: 'Cairo', sans-serif !important; | |
| } | |
| body, .gradio-container { | |
| direction: rtl; | |
| } | |
| textarea, input { | |
| text-align: right; | |
| direction: rtl; | |
| } | |
| /* عكس الأعمدة */ | |
| .reverse-row { | |
| display: flex; | |
| flex-direction: row-reverse; | |
| gap: 20px; | |
| } | |
| /* تنسيق الإخراج */ | |
| .output-box { | |
| background-color: #0f172a; | |
| color: #e5e7eb; | |
| border-radius: 10px; | |
| padding: 15px; | |
| font-size: 15px; | |
| } | |
| """ | |
| def idea_to_ai_software_platform(user_idea): | |
| try: | |
| prompt = f""" | |
| أنت نظام ذكاء اصطناعي متخصص في: | |
| Software Architecture + DevOps + AI Engineering. | |
| المطلوب: | |
| تحويل الفكرة التالية إلى منصة برمجية متكاملة قابلة للتنفيذ. | |
| اكتب بالعربية، بأسلوب احترافي وسهل. | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 📌 الفكرة: | |
| {user_idea} | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 1️⃣ تحليل المشكلة | |
| - ما المشكلة الحقيقية؟ | |
| - لماذا الحل مهم؟ | |
| - من المستخدم النهائي؟ | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 2️⃣ تحويل الفكرة إلى متطلبات (Requirements) | |
| - المتطلبات الوظيفية | |
| - المتطلبات غير الوظيفية | |
| - User Flow مختصر | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 3️⃣ خارطة النظام (System Architecture) | |
| - مكونات النظام | |
| - كيف تتواصل مع بعضها | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 4️⃣ Tech Stack المقترح (مع سبب الاختيار) | |
| 🔹 Frontend | |
| 🔹 Backend | |
| 🔹 Database | |
| 🔹 AI / APIs | |
| 🔹 DevOps & Deployment | |
| 🔹 Security | |
| 🔹 Monitoring | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 5️⃣ مثال كود مبدئي (Prototype) | |
| - كود بسيط يوضح الفكرة الأساسية | |
| - بلغة مناسبة | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 6️⃣ Test Cases | |
| - Unit Tests | |
| - Integration Tests (نقاط) | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 7️⃣ هيكل المشروع (Project Structure) | |
| - مجلدات | |
| - ملفات أساسية | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 8️⃣ التوثيق (Documentation) | |
| - شرح المشروع | |
| - كيفية التشغيل | |
| - API Overview | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 9️⃣ تقدير الوقت والتكلفة | |
| - مدة التنفيذ | |
| - مستوى التعقيد | |
| - تقدير تقريبي للتكلفة | |
| ━━━━━━━━━━━━━━━━━━━━ | |
| 🔟 توصيات أدوات حقيقية | |
| - أدوات تطوير | |
| - أدوات AI | |
| - أدوات إدارة مشروع | |
| """ | |
| response = client.chat.completions.create( | |
| model="gpt-4o-mini", | |
| messages=[ | |
| {"role": "system", "content": "أنت خبير تطوير برمجيات ومنصات AI."}, | |
| {"role": "user", "content": prompt} | |
| ], | |
| temperature=0.35, | |
| max_tokens=1800 | |
| ) | |
| return response.choices[0].message.content | |
| except Exception as e: | |
| return f"❌ خطأ:\n{str(e)}" | |
| with gr.Blocks( | |
| title="AI Software Builder", | |
| css=custom_css | |
| ) as interface: | |
| gr.Image(logo_file, height=150, show_label=False) | |
| gr.Markdown(""" | |
| ## | |
| من فكرة مكتوبة إلى مشروع برمجي متكامل بالذكاء الاصطناعي | |
| """) | |
| with gr.Row(elem_classes=["reverse-row"]): | |
| with gr.Column(scale=1): | |
| idea_input = gr.Textbox( | |
| lines=7, | |
| label="📝 اكتب المشكلة أو الفكرة", | |
| placeholder="مثال: أريد نظام ذكي يحلل شكاوى العملاء تلقائيًا ويصنفها" | |
| ) | |
| submit_btn = gr.Button("⚡ أنشئ الحل البرمجي المتكامل", variant="primary") | |
| with gr.Column(scale=1): | |
| output = gr.Textbox( | |
| lines=30, | |
| label="📦 المخرجات", | |
| elem_classes=["output-box"], | |
| interactive=False | |
| ) | |
| submit_btn.click( | |
| fn=idea_to_ai_software_platform, | |
| inputs=idea_input, | |
| outputs=output | |
| ) | |
| gr.HTML(""" | |
| <div style="text-align:center; margin-top:25px; color:#38bdf8;"> | |
| © 2026 Eng. Reem Algethami | AI Software Builder Platform | |
| </div> | |
| """) | |
| if __name__ == "__main__": | |
| interface.launch(theme=gr.themes.Soft()) | |