Bookmark API
api_delete_all_bookmark()
Removes all bookmarks from the database.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary indicating the result of the delete operation. |
api_delete_bookmark(bookmark_name)
Removes a bookmark from the database using its name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bookmark_name
|
str
|
The name of the bookmark to be removed. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the details of the deleted bookmark. |
Source code in moonshot/src/api/api_bookmark.py
api_export_bookmarks(export_file_name='bookmarks')
Exports bookmarks to a specified file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
export_file_name
|
str
|
The name of the file to export the bookmarks to. |
'bookmarks'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The filepath of where the file is written. |
Source code in moonshot/src/api/api_bookmark.py
api_get_all_bookmarks()
Retrieves a list of all bookmarks from the database.
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: A list of bookmarks, each represented as a dictionary. |
api_get_bookmark(bookmark_name)
Retrieves the details of a specific bookmark by its name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bookmark_name
|
str
|
The name of the bookmark to retrieve. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The bookmark details corresponding to the provided name. |
Source code in moonshot/src/api/api_bookmark.py
api_insert_bookmark(name, prompt, prepared_prompt, response, context_strategy='', prompt_template='', attack_module='', metric='')
Inserts a new bookmark into the database.
This function constructs a BookmarkArguments object with the provided details and invokes the add_bookmark method of a Bookmark instance to persist the new bookmark.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The unique name of the bookmark. |
required |
prompt
|
str
|
The associated prompt text for the bookmark. |
required |
prepared_prompt
|
str
|
The prepared prompt text for the bookmark. |
required |
response
|
str
|
The corresponding response text for the bookmark. |
required |
context_strategy
|
str
|
The strategy used for context management in the bookmark. Defaults to "". |
''
|
prompt_template
|
str
|
The template used for generating the prompt. Defaults to "". |
''
|
attack_module
|
str
|
The attack module linked with the bookmark. Defaults to "". |
''
|
metric
|
str
|
The metric associated with the bookmark. Defaults to "". |
''
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the details of the newly inserted bookmark. |