File size: 1,036 Bytes
905d2fe 3b255c5 905d2fe 3b255c5 905d2fe 3b255c5 905d2fe 3b255c5 905d2fe 3b255c5 905d2fe 3b255c5 |
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 26 27 28 29 30 31 |
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()
|