|
11 | 11 | }, |
12 | 12 | { |
13 | 13 | "cell_type": "code", |
14 | | - "execution_count": 1, |
| 14 | + "execution_count": null, |
15 | 15 | "metadata": { |
16 | 16 | "id": "JuO12HZQQEnx" |
17 | 17 | }, |
|
35 | 35 | "output_type": "stream", |
36 | 36 | "text": [ |
37 | 37 | "Name: llamator\n", |
38 | | - "Version: 1.1.1\n", |
| 38 | + "Version: 2.2.0\n", |
39 | 39 | "Summary: Framework for testing vulnerabilities of large language models (LLM).\n", |
40 | 40 | "Home-page: \n", |
41 | 41 | "Author: \n", |
|
239 | 239 | "\n", |
240 | 240 | " # Generating a Prompt by an Attack Model\n", |
241 | 241 | " for attack_prompt_index in range(self.num_attempts):\n", |
242 | | - " chat = ChatSession(self.attack_config.attack_client.get_target_client())\n", |
243 | | - " attack_prompt = chat.say(\n", |
244 | | - " ORDINARY_PROMPT_TEMPLATE.format(description=self.client_config.get_model_description())\n", |
245 | | - " )\n", |
246 | | - " attack_prompts.append(attack_prompt)\n", |
247 | 242 | " yield StatusUpdate(\n", |
248 | 243 | " self.client_config,\n", |
249 | 244 | " self.test_name,\n", |
|
252 | 247 | " attack_prompt_index,\n", |
253 | 248 | " self.num_attempts,\n", |
254 | 249 | " )\n", |
| 250 | + " chat = ChatSession(self.attack_config.attack_client.get_target_client())\n", |
| 251 | + " attack_prompt = chat.say(\n", |
| 252 | + " ORDINARY_PROMPT_TEMPLATE.format(description=self.client_config.get_model_description())\n", |
| 253 | + " )\n", |
| 254 | + " if not attack_prompt:\n", |
| 255 | + " logger.warning(\"Error while attacking against target LLM (didn't receive response) ...\")\n", |
| 256 | + " self.status.report_error(str(attack_prompt_index))\n", |
| 257 | + " else:\n", |
| 258 | + " attack_prompts.append(attack_prompt)\n", |
255 | 259 | "\n", |
256 | 260 | " # Executing attack prompts and checking the output of the attacked model\n", |
257 | 261 | " yield StatusUpdate(\n", |
|
291 | 295 | " self.status.report_breach(attack_prompt, response)\n", |
292 | 296 | " else:\n", |
293 | 297 | " self.status.report_resilient(attack_prompt, response)\n", |
| 298 | + " # Adding a response and status to a report\n", |
| 299 | + " responses.append(response)\n", |
| 300 | + " statuses.append(current_status)\n", |
294 | 301 | " yield StatusUpdate(\n", |
295 | 302 | " self.client_config,\n", |
296 | 303 | " self.test_name,\n", |
|
299 | 306 | " attack_prompt_index,\n", |
300 | 307 | " self.num_attempts,\n", |
301 | 308 | " )\n", |
302 | | - " # Adding a response and status to a report\n", |
303 | | - " responses.append(response)\n", |
304 | | - " statuses.append(current_status)\n", |
305 | 309 | "\n", |
306 | 310 | " # Adding data to the report\n", |
307 | 311 | " self._prepare_attack_data(attack_prompts, responses, statuses)\n", |
|
332 | 336 | "data": { |
333 | 337 | "text/plain": [ |
334 | 338 | "{'role': 'assistant',\n", |
335 | | - " 'content': 'Hello! How are you today? How can I assist you?'}" |
| 339 | + " 'content': \"Hello! Nice to meet you. How are you today? Is there something you would like to talk about or ask me? I'm here to help. 😊\"}" |
336 | 340 | ] |
337 | 341 | }, |
338 | 342 | "execution_count": 9, |
|
373 | 377 | "\n", |
374 | 378 | "### Available Attacks\n", |
375 | 379 | "\n", |
376 | | - "Check out the [documentation](https://romiconez.github.io/llamator/attacks_description.html) for an overview of available attacks." |
| 380 | + "Check out the [documentation](https://romiconez.github.io/llamator/attack_descriptions.html) for an overview of available attacks." |
377 | 381 | ] |
378 | 382 | }, |
379 | 383 | { |
|
399 | 403 | "name": "stderr", |
400 | 404 | "output_type": "stream", |
401 | 405 | "text": [ |
402 | | - "Test progress ........................................: 0%| | 0/1 [00:00<?, ?it/s]: 0%| | 0/1 [00:00<?, ?it/s]: 100%|██████████| 1/1 [00:36<00:00, 36.06s/it]: 100%|██████████| 1/1 [00:36<00:00, 36.06s/it]\n" |
| 406 | + "Test progress ........................................: 0%| | 0/1 [00:00<?, ?it/s]: 0%| | 0/1 [00:00<?, ?it/s]: 100%|██████████| 1/1 [01:14<00:00, 74.54s/it]: 100%|██████████| 1/1 [01:14<00:00, 74.55s/it]\n" |
403 | 407 | ] |
404 | 408 | }, |
405 | 409 | { |
|
420 | 424 | "repeat_10_times:\n", |
421 | 425 | " Tests LLM for 10 times response vulnerability\n", |
422 | 426 | "\n", |
423 | | - "Excel report created: ./artifacts\\LLAMATOR_run_2025-01-12_17-02-05\\attacks_report.xlsx\n" |
| 427 | + "DISCLAIMER: Report may contain HARMFUL and OFFENSIVE language, reader discretion is recommended.\n", |
| 428 | + "Excel report created: ./artifacts\\LLAMATOR_run_2025-02-17_11-30-47\\attacks_report.xlsx\n" |
424 | 429 | ] |
425 | 430 | }, |
426 | 431 | { |
427 | 432 | "name": "stderr", |
428 | 433 | "output_type": "stream", |
429 | 434 | "text": [ |
430 | | - "2025-01-12 17:02:46,865 [WARNING] [word_report_generator.py:352]: Test with in_code_name 'repeat_10_times' not found in JSON. Skipping file repeat_10_times.csv.\n" |
| 435 | + "2025-02-17 11:32:05,188 [WARNING] [word_report_generator.py:352]: Test with in_code_name 'repeat_10_times' not found in JSON. Skipping file repeat_10_times.csv.\n" |
431 | 436 | ] |
432 | 437 | }, |
433 | 438 | { |
434 | 439 | "name": "stdout", |
435 | 440 | "output_type": "stream", |
436 | 441 | "text": [ |
437 | | - "Word report created: ./artifacts\\LLAMATOR_run_2025-01-12_17-02-05\\attacks_report.docx\n", |
| 442 | + "Word report created: ./artifacts\\LLAMATOR_run_2025-02-17_11-30-47\\attacks_report.docx\n", |
438 | 443 | "Thank you for using LLAMATOR!\n" |
439 | 444 | ] |
440 | 445 | } |
|
0 commit comments