import os import gradio as gr from rag_system import RAGSystem # تأكد أن الملف اسمه rag_system.py وموجود في نفس المجلد # --- تحميل النظام --- rag = RAGSystem( vector_db_path="vector_db", # تأكد أن قاعدة البيانات مضغوطة ومرفوعة ضمن files model_name="meta-llama/Llama-3-8b-chat-hf", embedding_model_name="sentence-transformers/all-mpnet-base-v2" ) rag.load_vectorstore() rag.load_llm() rag.get_prompt_template() # --- دالة الاستجابة --- def ask_question_interface(question): return rag.ask_question(question) # --- واجهة Gradio --- demo = gr.Interface( fn=ask_question_interface, inputs=gr.Textbox(label="Ask a question about the ECC Guide"), outputs=gr.Textbox(label="Answer"), title="ECC Cybersecurity Assistant", description="Ask questions based on the Essential Cybersecurity Controls (ECC) Implementation Guide issued by the NCA (Saudi Arabia).", ) if __name__ == "__main__": demo.launch()