aiverify-moonshot 0.4.10__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aiverify_moonshot-0.4.10.dist-info → aiverify_moonshot-0.5.0.dist-info}/METADATA +24 -26
- {aiverify_moonshot-0.4.10.dist-info → aiverify_moonshot-0.5.0.dist-info}/RECORD +37 -36
- {aiverify_moonshot-0.4.10.dist-info → aiverify_moonshot-0.5.0.dist-info}/WHEEL +1 -1
- moonshot/integrations/cli/benchmark/cookbook.py +8 -11
- moonshot/integrations/cli/benchmark/recipe.py +1 -5
- moonshot/integrations/cli/cli_errors.py +3 -0
- moonshot/integrations/cli/common/connectors.py +22 -10
- moonshot/integrations/web_api/app.py +1 -1
- moonshot/integrations/web_api/schemas/endpoint_create_dto.py +1 -0
- moonshot/integrations/web_api/services/endpoint_service.py +1 -0
- moonshot/src/api/api_bookmark.py +16 -5
- moonshot/src/api/api_connector.py +3 -3
- moonshot/src/api/api_connector_endpoint.py +6 -3
- moonshot/src/api/api_context_strategy.py +2 -2
- moonshot/src/api/api_cookbook.py +6 -6
- moonshot/src/api/api_dataset.py +5 -5
- moonshot/src/api/api_environment_variables.py +3 -0
- moonshot/src/api/api_metrics.py +1 -1
- moonshot/src/api/api_prompt_template.py +9 -0
- moonshot/src/api/api_recipe.py +3 -3
- moonshot/src/api/api_red_teaming.py +4 -8
- moonshot/src/api/api_result.py +10 -6
- moonshot/src/api/api_run.py +3 -3
- moonshot/src/api/api_runner.py +7 -6
- moonshot/src/api/api_session.py +11 -7
- moonshot/src/bookmark/bookmark.py +12 -5
- moonshot/src/connectors/connector.py +127 -62
- moonshot/src/connectors/connector_prompt_arguments.py +15 -5
- moonshot/src/connectors/connector_response.py +15 -0
- moonshot/src/connectors_endpoints/connector_endpoint.py +32 -20
- moonshot/src/connectors_endpoints/connector_endpoint_arguments.py +4 -1
- moonshot/src/messages_constants.py +85 -3
- moonshot/src/redteaming/attack/attack_module.py +34 -7
- moonshot/src/runs/run_arguments.py +43 -20
- {aiverify_moonshot-0.4.10.dist-info → aiverify_moonshot-0.5.0.dist-info}/licenses/AUTHORS.md +0 -0
- {aiverify_moonshot-0.4.10.dist-info → aiverify_moonshot-0.5.0.dist-info}/licenses/LICENSE.md +0 -0
- {aiverify_moonshot-0.4.10.dist-info → aiverify_moonshot-0.5.0.dist-info}/licenses/NOTICES.md +0 -0
moonshot/src/api/api_cookbook.py
CHANGED
|
@@ -14,7 +14,7 @@ def api_create_cookbook(name: str, description: str, recipes: list[str]) -> str:
|
|
|
14
14
|
|
|
15
15
|
This function takes the name, description, and recipes for a new cookbook as input. It then creates a new
|
|
16
16
|
CookbookArguments object with these details and an empty id. The id is left empty because it will be generated
|
|
17
|
-
from the name during the creation process. The function then calls the Cookbook's
|
|
17
|
+
from the name during the creation process. The function then calls the Cookbook's create method to
|
|
18
18
|
create the new cookbook.
|
|
19
19
|
|
|
20
20
|
Args:
|
|
@@ -43,7 +43,7 @@ def api_read_cookbook(cb_id: str) -> dict:
|
|
|
43
43
|
"""
|
|
44
44
|
Retrieves a cookbook based on the provided cookbook ID.
|
|
45
45
|
|
|
46
|
-
This function reads a cookbook using the `
|
|
46
|
+
This function reads a cookbook using the `read` method
|
|
47
47
|
of the `Cookbook` class, and converts the returned `Cookbook` object to a dictionary using its `to_dict` method.
|
|
48
48
|
|
|
49
49
|
Args:
|
|
@@ -60,7 +60,7 @@ def api_read_cookbooks(cb_ids: conlist(str, min_length=1)) -> list[dict]:
|
|
|
60
60
|
"""
|
|
61
61
|
Retrieves a list of cookbooks based on the provided list of cookbook IDs.
|
|
62
62
|
|
|
63
|
-
This function iterates over the list of provided cookbook IDs, reads each cookbook using the `
|
|
63
|
+
This function iterates over the list of provided cookbook IDs, reads each cookbook using the `read` method
|
|
64
64
|
of the `Cookbook` class, and converts the returned `Cookbook` objects to dictionaries using their `to_dict` method.
|
|
65
65
|
It then returns a list of these dictionary representations.
|
|
66
66
|
|
|
@@ -90,7 +90,7 @@ def api_update_cookbook(cb_id: str, **kwargs) -> bool:
|
|
|
90
90
|
bool: True if the cookbook was successfully updated.
|
|
91
91
|
|
|
92
92
|
Raises:
|
|
93
|
-
|
|
93
|
+
RuntimeError: If the cookbook with the given ID does not exist.
|
|
94
94
|
"""
|
|
95
95
|
# Check if the cookbook exists
|
|
96
96
|
try:
|
|
@@ -134,7 +134,7 @@ def api_get_all_cookbook() -> list[dict]:
|
|
|
134
134
|
"""
|
|
135
135
|
Retrieves all available cookbooks.
|
|
136
136
|
|
|
137
|
-
This function calls the `
|
|
137
|
+
This function calls the `get_available_items` method of the `Cookbook` class, which returns a tuple
|
|
138
138
|
containing a list of cookbook IDs and a list of `CookbookArguments` objects. The function then returns a list
|
|
139
139
|
of dictionaries, each representing a cookbook.
|
|
140
140
|
|
|
@@ -149,7 +149,7 @@ def api_get_all_cookbook_name() -> list[str]:
|
|
|
149
149
|
"""
|
|
150
150
|
Retrieves the names of all available cookbooks.
|
|
151
151
|
|
|
152
|
-
This function calls the `
|
|
152
|
+
This function calls the `get_available_items` method of the `Cookbook` class, which returns a tuple
|
|
153
153
|
containing a list of cookbook IDs and a list of `CookbookArguments` objects. The function then returns the
|
|
154
154
|
list of cookbook IDs, which are the names of the cookbooks.
|
|
155
155
|
|
moonshot/src/api/api_dataset.py
CHANGED
|
@@ -16,7 +16,7 @@ def api_delete_dataset(ds_id: str) -> bool:
|
|
|
16
16
|
ds_id (str): The unique identifier for the dataset to be deleted.
|
|
17
17
|
|
|
18
18
|
Returns:
|
|
19
|
-
bool: True if the dataset was successfully deleted.
|
|
19
|
+
bool: True if the dataset was successfully deleted, False otherwise.
|
|
20
20
|
|
|
21
21
|
Raises:
|
|
22
22
|
Exception: If the deletion process encounters an error.
|
|
@@ -27,10 +27,10 @@ def api_delete_dataset(ds_id: str) -> bool:
|
|
|
27
27
|
def api_get_all_datasets() -> list[dict]:
|
|
28
28
|
"""
|
|
29
29
|
This function retrieves all available datasets and returns them as a list of dictionaries. Each dictionary
|
|
30
|
-
represents a
|
|
30
|
+
represents a dataset and contains its information.
|
|
31
31
|
|
|
32
32
|
Returns:
|
|
33
|
-
list[dict]: A list of dictionaries, each representing a
|
|
33
|
+
list[dict]: A list of dictionaries, each representing a dataset.
|
|
34
34
|
"""
|
|
35
35
|
_, datasets = Dataset.get_available_items()
|
|
36
36
|
return [dataset.to_dict() for dataset in datasets]
|
|
@@ -38,10 +38,10 @@ def api_get_all_datasets() -> list[dict]:
|
|
|
38
38
|
|
|
39
39
|
def api_get_all_datasets_name() -> list[str]:
|
|
40
40
|
"""
|
|
41
|
-
This function retrieves all available
|
|
41
|
+
This function retrieves all available dataset names and returns them as a list.
|
|
42
42
|
|
|
43
43
|
Returns:
|
|
44
|
-
list[str]: A list of
|
|
44
|
+
list[str]: A list of dataset names.
|
|
45
45
|
"""
|
|
46
46
|
datasets_name, _ = Dataset.get_available_items()
|
|
47
47
|
return datasets_name
|
|
@@ -8,6 +8,9 @@ def api_set_environment_variables(env_vars: dict) -> None:
|
|
|
8
8
|
"""
|
|
9
9
|
Sets the environment variables for the current session.
|
|
10
10
|
|
|
11
|
+
This function takes a dictionary of environment variables and sets them for the current session
|
|
12
|
+
by loading them into the EnvironmentVars configuration.
|
|
13
|
+
|
|
11
14
|
Args:
|
|
12
15
|
env_vars (dict): A dictionary containing the environment variables to set.
|
|
13
16
|
|
moonshot/src/api/api_metrics.py
CHANGED
|
@@ -15,7 +15,7 @@ def api_delete_metric(met_id: str) -> bool:
|
|
|
15
15
|
met_id (str): The unique identifier for the metric to be deleted.
|
|
16
16
|
|
|
17
17
|
Returns:
|
|
18
|
-
bool: True if the metric was successfully deleted.
|
|
18
|
+
bool: True if the metric was successfully deleted, False otherwise.
|
|
19
19
|
|
|
20
20
|
Raises:
|
|
21
21
|
Exception: If the deletion process encounters an error.
|
|
@@ -10,6 +10,9 @@ def api_get_all_prompt_template_detail() -> list[dict]:
|
|
|
10
10
|
"""
|
|
11
11
|
Retrieves all available prompt template details and returns them as a list of dictionaries.
|
|
12
12
|
|
|
13
|
+
This function calls the `get_all_prompt_template_details` method from the `PromptTemplate` class
|
|
14
|
+
to fetch the details of all prompt templates. It then returns these details as a list of dictionaries.
|
|
15
|
+
|
|
13
16
|
Returns:
|
|
14
17
|
list[dict]: A list of dictionaries, each representing the details of a prompt template.
|
|
15
18
|
"""
|
|
@@ -20,6 +23,9 @@ def api_get_all_prompt_template_name() -> list[str]:
|
|
|
20
23
|
"""
|
|
21
24
|
Retrieves all available prompt template names and returns them as a list.
|
|
22
25
|
|
|
26
|
+
This function calls the `get_all_prompt_template_names` method from the `PromptTemplate` class
|
|
27
|
+
to fetch the names of all prompt templates. It then returns these names as a list of strings.
|
|
28
|
+
|
|
23
29
|
Returns:
|
|
24
30
|
list[str]: A list of prompt template names.
|
|
25
31
|
"""
|
|
@@ -31,6 +37,9 @@ def api_delete_prompt_template(pt_id: str) -> bool:
|
|
|
31
37
|
"""
|
|
32
38
|
Deletes a prompt template by its identifier.
|
|
33
39
|
|
|
40
|
+
This function calls the `delete` method from the `PromptTemplate` class to delete a prompt template
|
|
41
|
+
identified by its unique ID. It returns True if the deletion was successful, otherwise it raises an exception.
|
|
42
|
+
|
|
34
43
|
Args:
|
|
35
44
|
pt_id (str): The unique identifier of the prompt template to be deleted.
|
|
36
45
|
|
moonshot/src/api/api_recipe.py
CHANGED
|
@@ -79,7 +79,7 @@ def api_read_recipes(rec_ids: conlist(str, min_length=1)) -> list[dict]:
|
|
|
79
79
|
and returns a list of dictionaries containing each recipe's information.
|
|
80
80
|
|
|
81
81
|
Args:
|
|
82
|
-
rec_ids (
|
|
82
|
+
rec_ids (conlist(str, min_length=1)): The IDs of the recipes.
|
|
83
83
|
|
|
84
84
|
Returns:
|
|
85
85
|
list[dict]: A list of dictionaries, each containing a recipe's information.
|
|
@@ -155,7 +155,7 @@ def api_get_all_recipe() -> list[dict]:
|
|
|
155
155
|
"""
|
|
156
156
|
Retrieves all available recipes.
|
|
157
157
|
|
|
158
|
-
This function calls the
|
|
158
|
+
This function calls the get_available_items method to retrieve all available recipes. It then converts each
|
|
159
159
|
recipe into a dictionary using the to_dict method and returns a list of these dictionaries.
|
|
160
160
|
|
|
161
161
|
Returns:
|
|
@@ -169,7 +169,7 @@ def api_get_all_recipe_name() -> list[str]:
|
|
|
169
169
|
"""
|
|
170
170
|
Retrieves all available recipe names.
|
|
171
171
|
|
|
172
|
-
This function calls the
|
|
172
|
+
This function calls the get_available_items method to retrieve all available recipes. It then extracts the names
|
|
173
173
|
of each recipe and returns a list of these names.
|
|
174
174
|
|
|
175
175
|
Returns:
|
|
@@ -11,9 +11,7 @@ def api_get_all_attack_modules() -> list[str]:
|
|
|
11
11
|
Retrieves all available attack module IDs.
|
|
12
12
|
|
|
13
13
|
This function calls the `get_available_items` method from the `AttackModule` class to retrieve all available
|
|
14
|
-
attack modules.
|
|
15
|
-
|
|
16
|
-
It then extracts the IDs of each attack module and returns a list of these IDs.
|
|
14
|
+
attack modules. It then extracts the IDs of each attack module and returns a list of these IDs.
|
|
17
15
|
|
|
18
16
|
Returns:
|
|
19
17
|
list[str]: A list of strings, each representing an attack module ID.
|
|
@@ -27,10 +25,8 @@ def api_get_all_attack_module_metadata() -> list[dict]:
|
|
|
27
25
|
Retrieves metadata for all available attack modules.
|
|
28
26
|
|
|
29
27
|
This function calls the `get_available_items` method from the `AttackModule` class to retrieve all available
|
|
30
|
-
attack modules metadata
|
|
31
|
-
|
|
32
|
-
It then extracts the metadata for each attack module and returns a list of dictionaries, each containing the
|
|
33
|
-
metadata of an attack module.
|
|
28
|
+
attack modules. It then extracts the metadata for each attack module and returns a list of dictionaries,
|
|
29
|
+
each containing the metadata of an attack module.
|
|
34
30
|
|
|
35
31
|
Returns:
|
|
36
32
|
list[dict]: A list of dictionaries, each representing the metadata of an attack module.
|
|
@@ -44,7 +40,7 @@ def api_delete_attack_module(am_id: str) -> bool:
|
|
|
44
40
|
"""
|
|
45
41
|
Deletes an attack module by its identifier.
|
|
46
42
|
|
|
47
|
-
This function takes an attack module ID as input and calls the delete method from the AttackModule class
|
|
43
|
+
This function takes an attack module ID as input and calls the `delete` method from the `AttackModule` class
|
|
48
44
|
to remove the specified attack module from storage.
|
|
49
45
|
|
|
50
46
|
Args:
|
moonshot/src/api/api_result.py
CHANGED
|
@@ -11,7 +11,7 @@ def api_read_result(res_id: str) -> dict:
|
|
|
11
11
|
"""
|
|
12
12
|
Reads a result and returns its information.
|
|
13
13
|
|
|
14
|
-
This function takes a result ID as input, reads the corresponding
|
|
14
|
+
This function takes a result ID as input, reads the corresponding result from the storage manager,
|
|
15
15
|
and returns a dictionary containing the result's information.
|
|
16
16
|
|
|
17
17
|
Args:
|
|
@@ -28,7 +28,7 @@ def api_read_results(res_ids: conlist(str, min_length=1)) -> list[dict]:
|
|
|
28
28
|
"""
|
|
29
29
|
Reads multiple results and returns their information.
|
|
30
30
|
|
|
31
|
-
This function takes a list of result IDs as input, reads the corresponding
|
|
31
|
+
This function takes a list of result IDs as input, reads the corresponding results from the storage manager,
|
|
32
32
|
and returns a list of dictionaries, each containing a result's information.
|
|
33
33
|
|
|
34
34
|
Args:
|
|
@@ -37,7 +37,6 @@ def api_read_results(res_ids: conlist(str, min_length=1)) -> list[dict]:
|
|
|
37
37
|
Returns:
|
|
38
38
|
list[dict]: A list of dictionaries, each containing a result's information.
|
|
39
39
|
"""
|
|
40
|
-
|
|
41
40
|
return [Result.read(res_id) for res_id in res_ids]
|
|
42
41
|
|
|
43
42
|
|
|
@@ -63,11 +62,13 @@ def api_delete_result(res_id: str) -> bool:
|
|
|
63
62
|
|
|
64
63
|
def api_get_all_result() -> list[dict]:
|
|
65
64
|
"""
|
|
66
|
-
This function retrieves all available results and returns them as a list of dictionaries.
|
|
67
|
-
|
|
65
|
+
This function retrieves all available results and returns them as a list of dictionaries.
|
|
66
|
+
|
|
67
|
+
This function calls the get_available_items method from the Result class to retrieve all available results.
|
|
68
|
+
It then returns a list of dictionaries, each containing the details of a result.
|
|
68
69
|
|
|
69
70
|
Returns:
|
|
70
|
-
list[dict]: A list of dictionaries, each representing a result.
|
|
71
|
+
list[dict]: A list of dictionaries, each representing a result's details.
|
|
71
72
|
"""
|
|
72
73
|
_, results = Result.get_available_items()
|
|
73
74
|
return [result for result in results]
|
|
@@ -77,6 +78,9 @@ def api_get_all_result_name() -> list[str]:
|
|
|
77
78
|
"""
|
|
78
79
|
This function retrieves all available result names and returns them as a list.
|
|
79
80
|
|
|
81
|
+
This function calls the get_available_items method from the Result class to retrieve all available results.
|
|
82
|
+
It then extracts the names of each result and returns a list of these names.
|
|
83
|
+
|
|
80
84
|
Returns:
|
|
81
85
|
list[str]: A list of result names.
|
|
82
86
|
"""
|
moonshot/src/api/api_run.py
CHANGED
|
@@ -14,7 +14,7 @@ def api_get_all_run(runner_id: str = "") -> list[dict]:
|
|
|
14
14
|
|
|
15
15
|
Args:
|
|
16
16
|
runner_id (str, optional): The ID of the runner to retrieve runs for. If empty, runs for all runners
|
|
17
|
-
|
|
17
|
+
are retrieved.
|
|
18
18
|
|
|
19
19
|
Returns:
|
|
20
20
|
list[dict]: A list of dictionaries, each representing a run's data.
|
|
@@ -34,8 +34,8 @@ def _api_get_available_runs(
|
|
|
34
34
|
RunArguments instances representing the runs.
|
|
35
35
|
|
|
36
36
|
Args:
|
|
37
|
-
runner_id (str): The ID of the runner for which to retrieve run information. If empty, information
|
|
38
|
-
|
|
37
|
+
runner_id (str, optional): The ID of the runner for which to retrieve run information. If empty, information
|
|
38
|
+
for all runners is retrieved.
|
|
39
39
|
|
|
40
40
|
Returns:
|
|
41
41
|
tuple[list[str], list[RunArguments]]: A tuple containing a list of runner IDs and a list of RunArguments
|
moonshot/src/api/api_runner.py
CHANGED
|
@@ -20,7 +20,7 @@ def api_create_runner(
|
|
|
20
20
|
Creates a new runner.
|
|
21
21
|
|
|
22
22
|
This function takes the name, endpoints, and an optional progress callback function to create a new Runner instance.
|
|
23
|
-
The
|
|
23
|
+
The ID of the runner is generated from the name of the runner using the slugify function,
|
|
24
24
|
so it does not need to be provided.
|
|
25
25
|
|
|
26
26
|
Args:
|
|
@@ -59,7 +59,8 @@ def api_load_runner(
|
|
|
59
59
|
|
|
60
60
|
Args:
|
|
61
61
|
runner_id (str): The ID of the runner to be loaded.
|
|
62
|
-
progress_callback_func (Callable | None):
|
|
62
|
+
progress_callback_func (Callable | None, optional): An optional progress callback function for the runner.
|
|
63
|
+
Defaults to None.
|
|
63
64
|
|
|
64
65
|
Returns:
|
|
65
66
|
Runner: An initialized Runner object.
|
|
@@ -108,8 +109,8 @@ def api_get_all_runner() -> list[dict]:
|
|
|
108
109
|
"""
|
|
109
110
|
Retrieves all available runners.
|
|
110
111
|
|
|
111
|
-
This function calls the get_available_items method to retrieve all available runners.
|
|
112
|
-
runner into a dictionary using the to_dict method and returns a list of these dictionaries.
|
|
112
|
+
This function calls the get_available_items method from the Runner class to retrieve all available runners.
|
|
113
|
+
It then converts each runner into a dictionary using the to_dict method and returns a list of these dictionaries.
|
|
113
114
|
|
|
114
115
|
Returns:
|
|
115
116
|
list[dict]: A list of dictionaries, each representing a runner.
|
|
@@ -122,8 +123,8 @@ def api_get_all_runner_name() -> list[str]:
|
|
|
122
123
|
"""
|
|
123
124
|
Retrieves all available runner names.
|
|
124
125
|
|
|
125
|
-
This function calls the get_available_items method to retrieve all available runners.
|
|
126
|
-
each runner and returns a list of these names.
|
|
126
|
+
This function calls the get_available_items method from the Runner class to retrieve all available runners.
|
|
127
|
+
It then extracts the names of each runner and returns a list of these names.
|
|
127
128
|
|
|
128
129
|
Returns:
|
|
129
130
|
list[str]: A list of runner names.
|
moonshot/src/api/api_session.py
CHANGED
|
@@ -43,11 +43,14 @@ def api_create_session(
|
|
|
43
43
|
Args:
|
|
44
44
|
runner_id (str): The unique identifier of the runner for which the session is to be created.
|
|
45
45
|
database_instance (Any): The database instance to be used for the session.
|
|
46
|
-
endpoints (list): A list of endpoints for the session.
|
|
46
|
+
endpoints (list[str]): A list of endpoints for the session.
|
|
47
47
|
runner_args (dict): A dictionary of arguments for the runner.
|
|
48
48
|
|
|
49
49
|
Returns:
|
|
50
|
-
Session
|
|
50
|
+
Session: A new Session object.
|
|
51
|
+
|
|
52
|
+
Raises:
|
|
53
|
+
RuntimeError: If the runner_id is empty or if the database_instance is not provided.
|
|
51
54
|
"""
|
|
52
55
|
if isinstance(database_instance, DBInterface):
|
|
53
56
|
if runner_id:
|
|
@@ -86,16 +89,16 @@ def api_get_all_session_names() -> list[str]:
|
|
|
86
89
|
return session_names
|
|
87
90
|
|
|
88
91
|
|
|
89
|
-
def api_get_available_session_info() -> tuple[list, list]:
|
|
92
|
+
def api_get_available_session_info() -> tuple[list[str], list[dict]]:
|
|
90
93
|
"""
|
|
91
|
-
Retrieves the IDs and
|
|
94
|
+
Retrieves the IDs and metadata of runners with active sessions.
|
|
92
95
|
|
|
93
|
-
This function retrieves the IDs and
|
|
96
|
+
This function retrieves the IDs and metadata of runners with active sessions by querying all runners
|
|
94
97
|
and checking if each runner has an active session. It returns a tuple containing a list of runner IDs and a list
|
|
95
98
|
of corresponding session metadata for runners with active sessions.
|
|
96
99
|
|
|
97
100
|
Returns:
|
|
98
|
-
tuple[list[str], list[
|
|
101
|
+
tuple[list[str], list[dict]]: A tuple containing a list of runner IDs and a list of corresponding session
|
|
99
102
|
metadata for runners with active sessions.
|
|
100
103
|
"""
|
|
101
104
|
runners_info = api_get_all_runner()
|
|
@@ -122,7 +125,8 @@ def api_get_all_session_metadata() -> list[dict]:
|
|
|
122
125
|
This function retrieves the metadata for all active sessions by calling the `api_get_available_session_info` method.
|
|
123
126
|
|
|
124
127
|
Returns:
|
|
125
|
-
list: A list containing the metadata for all active sessions, sorted by created datetime in
|
|
128
|
+
list[dict]: A list containing the metadata for all active sessions, sorted by created datetime in
|
|
129
|
+
descending order.
|
|
126
130
|
"""
|
|
127
131
|
_, session_metadata_list = api_get_available_session_info()
|
|
128
132
|
return sorted(
|
|
@@ -11,9 +11,9 @@ from moonshot.src.messages_constants import (
|
|
|
11
11
|
BOOKMARK_ADD_BOOKMARK_VALIDATION_ERROR,
|
|
12
12
|
BOOKMARK_DELETE_ALL_BOOKMARK_ERROR,
|
|
13
13
|
BOOKMARK_DELETE_ALL_BOOKMARK_SUCCESS,
|
|
14
|
-
BOOKMARK_DELETE_BOOKMARK_FAIL,
|
|
15
14
|
BOOKMARK_DELETE_BOOKMARK_ERROR,
|
|
16
15
|
BOOKMARK_DELETE_BOOKMARK_ERROR_1,
|
|
16
|
+
BOOKMARK_DELETE_BOOKMARK_FAIL,
|
|
17
17
|
BOOKMARK_DELETE_BOOKMARK_SUCCESS,
|
|
18
18
|
BOOKMARK_EXPORT_BOOKMARK_ERROR,
|
|
19
19
|
BOOKMARK_EXPORT_BOOKMARK_VALIDATION_ERROR,
|
|
@@ -186,7 +186,9 @@ class Bookmark:
|
|
|
186
186
|
if (
|
|
187
187
|
bookmark_info is not None
|
|
188
188
|
and isinstance(bookmark_info, tuple)
|
|
189
|
-
and all(
|
|
189
|
+
and all(
|
|
190
|
+
isinstance(item, str) for item in bookmark_info[1:]
|
|
191
|
+
) # Check if the rest are strings besides id
|
|
190
192
|
):
|
|
191
193
|
return BookmarkArguments.from_tuple_to_dict(bookmark_info)
|
|
192
194
|
else:
|
|
@@ -210,9 +212,11 @@ class Bookmark:
|
|
|
210
212
|
"""
|
|
211
213
|
if isinstance(bookmark_name, str) and bookmark_name:
|
|
212
214
|
try:
|
|
213
|
-
|
|
214
215
|
bookmark_info = Storage.read_database_record(
|
|
215
|
-
|
|
216
|
+
self.db_instance,
|
|
217
|
+
(bookmark_name,),
|
|
218
|
+
Bookmark.sql_select_bookmark_record,
|
|
219
|
+
)
|
|
216
220
|
if bookmark_info is not None:
|
|
217
221
|
sql_delete_bookmark_record = textwrap.dedent(
|
|
218
222
|
f"""
|
|
@@ -222,7 +226,10 @@ class Bookmark:
|
|
|
222
226
|
Storage.delete_database_record_in_table(
|
|
223
227
|
self.db_instance, sql_delete_bookmark_record
|
|
224
228
|
)
|
|
225
|
-
return {
|
|
229
|
+
return {
|
|
230
|
+
"success": True,
|
|
231
|
+
"message": BOOKMARK_DELETE_BOOKMARK_SUCCESS,
|
|
232
|
+
}
|
|
226
233
|
else:
|
|
227
234
|
return {"success": False, "message": BOOKMARK_DELETE_BOOKMARK_FAIL}
|
|
228
235
|
except Exception as e:
|