Che237 commited on
Commit
f73c256
·
verified ·
1 Parent(s): 67058ae

Update the CyberForge ML service

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -1093,10 +1093,25 @@ class TransformerModelLoader:
1093
  "such as reputation, hashes or CVEs, say it is unverified instead of guessing."
1094
  )
1095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1096
  def security_chat(self, query: str, max_tokens: int = 512, time_budget_s: Optional[float] = None, interactive: bool = False) -> Dict:
1097
  """Cybersecurity Q&A, answered by the open-source model running inside
1098
- this Space (free, no API key). `interactive` when a person is waiting."""
1099
- return local_llm.chat(self.SYSTEM_PROMPT, query, max_tokens=max_tokens, time_budget_s=time_budget_s, interactive=interactive)
 
 
1100
 
1101
  def status(self) -> Dict:
1102
  return {
 
1093
  "such as reputation, hashes or CVEs, say it is unverified instead of guessing."
1094
  )
1095
 
1096
+ # For a person talking to the assistant (interactive requests): a
1097
+ # conversation first. The analyst prompt above stays for background
1098
+ # explanations of scans, alerts and reports.
1099
+ ASSISTANT_PROMPT = (
1100
+ "You are the CyberForge assistant, a friendly, helpful chat assistant built into "
1101
+ "the CyberForge security app. Talk naturally, like a normal chat assistant: reply "
1102
+ "to greetings and small talk briefly and warmly, and offer to help. Answer security "
1103
+ "questions clearly and concisely, in plain sentences, using a short list only for "
1104
+ "steps. When the message includes the user's CyberForge memory, use it only if it "
1105
+ "helps answer. Never claim to have scanned, detected or checked anything that is "
1106
+ "not in the message; if something has not been checked, say so."
1107
+ )
1108
+
1109
  def security_chat(self, query: str, max_tokens: int = 512, time_budget_s: Optional[float] = None, interactive: bool = False) -> Dict:
1110
  """Cybersecurity Q&A, answered by the open-source model running inside
1111
+ this Space (free, no API key). `interactive` when a person is waiting:
1112
+ then it is a conversation (ASSISTANT_PROMPT), not an analyst's report."""
1113
+ system = self.ASSISTANT_PROMPT if interactive else self.SYSTEM_PROMPT
1114
+ return local_llm.chat(system, query, max_tokens=max_tokens, time_budget_s=time_budget_s, interactive=interactive)
1115
 
1116
  def status(self) -> Dict:
1117
  return {