-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT Adding labels for individual prompts (#624)
- Loading branch information
Showing
12 changed files
with
81 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
# Licensed under the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
|
||
def combine_dict(existing_dict: dict[str, str] = None, new_dict: dict[str, str] = None) -> dict[str, str]: | ||
""" | ||
Combines two dictionaries containing string keys and values into one | ||
Args: | ||
existing_dict: Dictionary with existing values | ||
new_dict: Dictionary with new values to be added to the existing dictionary. | ||
Note if there's a key clash, the value in new_dict will be used. | ||
Returns: combined dictionary | ||
""" | ||
result = existing_dict or {} | ||
result.update(new_dict or {}) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
from pyrit.common.utils import combine_dict | ||
|
||
|
||
def test_combine_non_empty_dict(): | ||
dict1 = {"a": "b"} | ||
dict2 = {"c": "d"} | ||
assert combine_dict(dict1, dict2) == {"a": "b", "c": "d"} | ||
|
||
|
||
def test_combine_empty_dict(): | ||
dict1 = {} | ||
dict2 = {} | ||
assert combine_dict(dict1, dict2) == {} | ||
|
||
|
||
def test_combine_first_empty_dict(): | ||
dict1 = {"a": "b"} | ||
dict2 = {} | ||
assert combine_dict(dict1, dict2) == {"a": "b"} | ||
|
||
|
||
def test_combine_second_empty_dict(): | ||
dict1 = {} | ||
dict2 = {"c": "d"} | ||
assert combine_dict(dict1, dict2) == {"c": "d"} | ||
|
||
|
||
def test_combine_dict_same_keys(): | ||
dict1 = {"c": "b"} | ||
dict2 = {"c": "d"} | ||
assert combine_dict(dict1, dict2) == {"c": "d"} |