import gradio as gr import sys import pandas as pd sys.path.insert(0, "ASG.API/") from ASGModels import ASG ASGAI=ASG(isForm=False) choices=[ "Group", "Technique", "Software" ] model_choices = gr.Dropdown( choices=choices, label="اختر النموذج", value="Group", ) import gradio as gr def home_page(): return """

مرحباً بك في Model AI ASG

Wasm-Speeker We provide models that help to aid in the creation of different attack sequences. You can deal with AGS models by choosing the model you want. We provide models that help to aid in the creation of different attack sequences. You can deal with AGS models by choosing the model you want.

Bootstrap Themes

Responsive left-aligned hero with image

Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.

Border hero with cropped image and shadows

Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.

Dark mode hero

Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.

""" def format_cyber_response(user_question: str, raw_answer: str, model="gpt-4") -> str: """ Uses an AI model to rephrase a raw cyber answer into a professionally structured response according to the style and tone of the user question. """ prompt = f""" You are an expert technical writer and cybersecurity analyst. Your task is to take the following user question and raw answer related to MITRE ATT&CK framework or cyberattack scenario generation, and rewrite the answer professionally based on the nature and tone of the question. Instructions: 1. Analyze the question to detect whether it is asking for an explanation, summary, technical analysis, or use-case scenario. 2. Rewrite the raw answer to match the expected response style (educational, technical, formal, or analytical). 3. Use domain-appropriate terminology. 4. Make the output coherent, structured, and professionally written. --- Question: {user_question} Raw Answer: {raw_answer} --- Final Response: """ return prompt from gradio_client import Client def ask_ai(message ): client = Client("wasmdashai/T2T") result = client.predict( text=message, key="AIzaSyC85_3TKmiXtOpwybhSFThZdF1nGKlxU5c", api_name="/predict" ) return result from gradio_client import Client def ask_wasm(txt): client = Client("wasmdashai/LAHJA-AI") result = client.predict( prompt=txt, api_name="/generate_from_prompt" ) return result def t2t(text, namn_model): if namn_model == "Group": out = ASGAI.Group.predictAPI(text) elif namn_model == "Technique": out = ASGAI.Tec.predictAPI(text) else: out = ASGAI.Soft.predictAPI(text) txt=format_cyber_response(text,str(out)) # anwai=ask_ai(txt) return txt def t2seq(text, namn_model): if namn_model == "Group": out = ASGAI.Group.Predict_ALL(text) elif namn_model == "Technique": out = ASGAI.Tec.Predict_ALL(text) else: out = ASGAI.Soft.Predict_ALL(text) txt=format_cyber_response(text,str(out)) # anwai=ask_wasm(txt) return txt def echo(message, history): text=t2seq(message,"Group") return text import uuid def s2s(text): userid=str(uuid.uuid4()) datase=[] def addsenario(inputs): data, pd = inputs seqtactic = '' seqtec = '' for ob in data[0]: seqtactic += ob[0] + "$@" seqtec += ob[1] + "$@" out, _ = ASGAI.Soft.predictAPI(seqtec) out2, _ = ASGAI.Group.predictAPI(seqtec + " " + out) score = f"{out2}@{out}@{data[1][1]}@{round(data[2], 2)}" tutorial = { "seqtactic": seqtactic, "iduser": userid, "seqtec": seqtec, "score": score } datase.append(tutorial) return tutorial ASGAI.cks.onsequens=addsenario text_output=ASGAI.search([text],numstop=50) df = pd.DataFrame(datase) return df # Use Blocks with gr.Blocks() as demo: gr.HTML(""" Model AI ASG """) # العنوان الرئيسي gr.Markdown("# Model AI ASG") # عرض الصورة الترحيبية gr.Image("icon (1).jpg", label="Model AI ASG") gr.HTML(""" """) with gr.Row(): with gr.Tab("Home"): gr.HTML(home_page()) with gr.Tab("Thread Base"): gr.Markdown("### Thread Base") with gr.Row(): with gr.Tab("T2T"): text_input = gr.Textbox(label="Input Text") model_choices = gr.Dropdown(choices=["Group", "Technique", "Soft"], label="Model",value="Group",) text_output = gr.Textbox(label="Output") submit_btn = gr.Button("Submit") submit_btn.click(fn=t2t, inputs=[text_input, model_choices], outputs=text_output) with gr.Tab("T2Seq"): text_input_seq = gr.Textbox(label="Input Text") model_choices_seq = gr.Dropdown(choices=["Group", "Technique", "Soft"], label="Model",value="Group",) text_output_seq = gr.Textbox(label="Output") submit_btn_seq = gr.Button("Submit") submit_btn_seq.click(fn=t2seq, inputs=[text_input_seq, model_choices_seq], outputs=text_output_seq) with gr.Tab("T2Sinaro"): model_choices_seq1 = gr.Dropdown(choices=["Group", "Technique", "Soft"], label="Model",value="Group",) gr.ChatInterface(fn=echo, title="Echo Bot") with gr.Tab("T2Sinaror"): text_input_seqttt = gr.Textbox(label="Input Text") submit_btn_seqtt = gr.Button("Submit") text_out_seqttt = gr.Dataframe(headers=["seqtactic", "iduser", "seqtec", "score"], datatype="str", label="Output") submit_btn_seqtt.click(fn=s2s, inputs=[text_input_seqttt], outputs=text_out_seqttt) with gr.Tab("Stute Base"): gr.Markdown("### Stute Base") demo.launch() # demo.launch()