dungeon29 commited on
Commit
086a5af
·
verified ·
1 Parent(s): 51c4c0d

Update llm_client.py

Browse files
Files changed (1) hide show
  1. llm_client.py +12 -10
llm_client.py CHANGED
@@ -96,12 +96,12 @@ class HybridLLM(LLM):
96
  "prompt": prompt,
97
  "n_predict": 512,
98
  "temperature": 0.3,
99
- "stop": stop or []
100
  }
101
  response = requests.post(
102
  f"{self.local_server_url}/completion",
103
  json=payload,
104
- timeout=120
105
  )
106
  if response.status_code == 200:
107
  return response.json()["content"]
@@ -215,20 +215,22 @@ class LLMClient:
215
  return "❌ Vector Store not initialized."
216
 
217
  # Custom Prompt Template
 
218
  template = """<|im_start|>system
219
- You are a cybersecurity expert. Task: Determine whether the input is 'PHISHING' or 'BENIGN' (Safe).
220
- Respond in the following format:
 
221
  LABEL: [PHISHING or BENIGN]
222
- EXPLANATION: [A brief Vietnamese explanation]
223
 
224
- Context:
225
- {context}
226
  <|im_end|>
227
  <|im_start|>user
228
- Input:
229
- {question}
230
 
231
- Short Analysis:
 
232
  <|im_end|>
233
  <|im_start|>assistant
234
  """
 
96
  "prompt": prompt,
97
  "n_predict": 512,
98
  "temperature": 0.3,
99
+ "stop": (stop or []) + ["<|im_end|>", "Input:", "Context:"]
100
  }
101
  response = requests.post(
102
  f"{self.local_server_url}/completion",
103
  json=payload,
104
+ timeout=300
105
  )
106
  if response.status_code == 200:
107
  return response.json()["content"]
 
215
  return "❌ Vector Store not initialized."
216
 
217
  # Custom Prompt Template
218
+ # Custom Prompt Template - Stricter Format
219
  template = """<|im_start|>system
220
+ You are a strict cybersecurity assistant.
221
+ Your ONLY task is to analyze the input and provide a verdict.
222
+ Output MUST follow this EXACT format:
223
  LABEL: [PHISHING or BENIGN]
224
+ EXPLANATION: [3-4 sentences in Vietnamese explaining the verdict]
225
 
226
+ Do NOT provide any other text, headers, or markdown.
 
227
  <|im_end|>
228
  <|im_start|>user
229
+ Context from knowledge base:
230
+ {context}
231
 
232
+ Input to analyze:
233
+ {question}
234
  <|im_end|>
235
  <|im_start|>assistant
236
  """