wasmdashai commited on
Commit
284e677
·
verified ·
1 Parent(s): 4958fda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -1
app.py CHANGED
@@ -76,6 +76,52 @@ def home_page():
76
  </div>
77
  </div>
78
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  def t2t(text, namn_model):
80
  if namn_model == "Group":
81
  out = ASGAI.Group.predictAPI(text)
@@ -83,7 +129,9 @@ def t2t(text, namn_model):
83
  out = ASGAI.Tec.predictAPI(text)
84
  else:
85
  out = ASGAI.Soft.predictAPI(text)
86
- return str(out)
 
 
87
 
88
  def t2seq(text, namn_model):
89
  if namn_model == "Group":
@@ -92,6 +140,9 @@ def t2seq(text, namn_model):
92
  out = ASGAI.Tec.Predict_ALL(text)
93
  else:
94
  out = ASGAI.Soft.Predict_ALL(text)
 
 
 
95
  return str(out)
96
  def echo(message, history):
97
  text=t2seq(message,"Group")
 
76
  </div>
77
  </div>
78
  """
79
+
80
+ def format_cyber_response(user_question: str, raw_answer: str, model="gpt-4") -> str:
81
+ """
82
+ Uses an AI model to rephrase a raw cyber answer into a professionally structured response
83
+ according to the style and tone of the user question.
84
+ """
85
+
86
+ prompt = f"""
87
+ You are an expert technical writer and cybersecurity analyst.
88
+
89
+ Your task is to take the following user question and raw answer related to MITRE ATT&CK framework
90
+ or cyberattack scenario generation, and rewrite the answer professionally based on the nature
91
+ and tone of the question.
92
+
93
+ Instructions:
94
+ 1. Analyze the question to detect whether it is asking for an explanation, summary, technical analysis, or use-case scenario.
95
+ 2. Rewrite the raw answer to match the expected response style (educational, technical, formal, or analytical).
96
+ 3. Use domain-appropriate terminology.
97
+ 4. Make the output coherent, structured, and professionally written.
98
+
99
+ ---
100
+
101
+ Question:
102
+ {user_question}
103
+
104
+ Raw Answer:
105
+ {raw_answer}
106
+
107
+ ---
108
+
109
+ Final Response:
110
+ """
111
+
112
+ return prompt
113
+ from gradio_client import Client
114
+
115
+ def ask_wasm(text):
116
+ txt=format_cyber_response(text)
117
+ client = Client("wasmdashai/LAHJA-AI")
118
+ result = client.predict(
119
+ prompt=txt,
120
+ api_name="/generate_from_prompt"
121
+ )
122
+ return result
123
+
124
+
125
  def t2t(text, namn_model):
126
  if namn_model == "Group":
127
  out = ASGAI.Group.predictAPI(text)
 
129
  out = ASGAI.Tec.predictAPI(text)
130
  else:
131
  out = ASGAI.Soft.predictAPI(text)
132
+
133
+ anwai=ask_wasm(text,str(out))
134
+ return anwai
135
 
136
  def t2seq(text, namn_model):
137
  if namn_model == "Group":
 
140
  out = ASGAI.Tec.Predict_ALL(text)
141
  else:
142
  out = ASGAI.Soft.Predict_ALL(text)
143
+
144
+
145
+
146
  return str(out)
147
  def echo(message, history):
148
  text=t2seq(message,"Group")