# app.py import gradio as gr from agent_api import sendPromptToAgent import os # دالة لمعالجة الإدخال من Gradio def handle_prompt(prompt): if not prompt.strip(): return "❌ الرجاء إدخال نص." try: result = sendPromptToAgent(prompt) return result['output'] except Exception as e: return f"❌ حدث خطأ: {e}" # تصميم واجهة Gradio iface = gr.Interface( fn=handle_prompt, inputs=gr.Textbox(lines=3, placeholder="اكتب سؤالك هنا...", label="📨 إدخال النص"), outputs=gr.Textbox(label="💡 الرد من الوكيل"), title="📰 وكيل الأخبار", description="أدخل سؤالك ليقوم الوكيل بالإجابة عليه باستخدام LangChain.", theme="soft" ) # تشغيل التطبيق if __name__ == "__main__": iface.launch(server_name="0.0.0.0", server_port=7860)