Core¶
- class aisploit.core.BaseCallbackHandler¶
Bases:
object
Base class for callback handlers.
- on_redteam_attempt_end(attempt: int, response: Response, score: Score, *, run_id: str)¶
Called when a red team attempt ends.
- Args:
attempt (int): The attempt number. response (Response): The response from the attempt. score (Score): The score of the attempt. run_id (str): The ID of the current run.
- on_redteam_attempt_start(attempt: int, prompt: PromptValue, *, run_id: str)¶
Called when a red team attempt starts.
- Args:
attempt (int): The attempt number. prompt (BasePromptValue): The prompt value. run_id (str): The ID of the current run.
- on_scanner_plugin_end(name: str, *, run_id: str)¶
Called when a scanner plugin ends.
- Args:
name (str): The name of the scanner plugin. run_id (str): The ID of the current run.
- on_scanner_plugin_start(name: str, *, run_id: str)¶
Called when a scanner plugin starts.
- Args:
name (str): The name of the scanner plugin. run_id (str): The ID of the current run.
- on_sender_send_prompt_end()¶
- on_sender_send_prompt_start()¶
- class aisploit.core.BaseChatModel¶
Bases:
Runnable
[PromptValue
|str
|Sequence
[BaseMessage
|List
[str
] |Tuple
[str
,str
] |str
|Dict
[str
,Any
]],BaseMessage
]- abstract supports_functions() bool ¶
Check if the model supports additional functions beyond basic chat.
- Returns:
bool: True if the model supports additional functions, False otherwise.
- class aisploit.core.BaseChatModelConverter(chat_model: aisploit.core.model.BaseChatModel)¶
Bases:
BaseConverter
,ABC
- chat_model: BaseChatModel¶
- class aisploit.core.BaseClassifier¶
Bases:
ABC
,Generic
[T
,Input
]An abstract base class for classifiers.
- abstract score(input: Input, references: List[Input] | None = None, metadata: Dict[str, Any] | None = None) Score[T] ¶
Score the input and return a Score object.
- Args:
input (Input): The input to be scored. references (List[Input], optional): List of reference inputs. Defaults to None. metadata (Dict[str, Any], optional): Additional metadata for scoring. Defaults to {}.
- Returns:
Score[T]: A Score object representing the score of the input.
- tags: List[str]¶
- class aisploit.core.BaseConverter¶
Bases:
ABC
Abstract base class for converters.
- convert(prompt: str | PromptValue) PromptValue ¶
Converts the prompt value.
- Args:
prompt (BasePromptValue): The prompt value to be converted.
- Returns:
BasePromptValue: The converted prompt value.
- class aisploit.core.BaseDataset¶
Bases:
ABC
Generic dataset class.
- aisploit.core.BaseEmbeddings¶
alias of
Embeddings
- class aisploit.core.BaseGenerator¶
Bases:
Generic
[T
],ABC
- abstract generate() Generator[T, Any, None] ¶
- class aisploit.core.BaseImageTarget(size: Literal['512x512', '1024x1024'] = '512x512', show_image: bool = False)¶
Bases:
ABC
- show_image: bool¶
- size: Literal['512x512', '1024x1024']¶
- class aisploit.core.BaseJob(*, disable_progressbar: bool = <factory>, verbose: bool = False)¶
Bases:
object
- disable_progressbar: bool¶
- verbose: bool¶
- class aisploit.core.BaseLLM¶
Bases:
Runnable
[PromptValue
|str
|Sequence
[BaseMessage
|List
[str
] |Tuple
[str
,str
] |str
|Dict
[str
,Any
]],str
]
- aisploit.core.BasePromptValue¶
alias of
PromptValue
- class aisploit.core.BaseReport(*, run_id: str)¶
Bases:
Generic
[T
],ABC
A generic base class for reports.
- property created_at: datetime¶
- class aisploit.core.BaseTarget¶
Bases:
ABC
An abstract base class for targets.
- class aisploit.core.BaseTextClassifier¶
Bases:
BaseClassifier
[T
,str
],Generic
[T
]An abstract base class for text classifiers.
- aisploit.core.BaseVectorStore¶
alias of
VectorStore
- class aisploit.core.CallbackManager(*, run_id: str, callbacks: Sequence[BaseCallbackHandler] | None)¶
Bases:
object
Manages callback handlers.
- on_redteam_attempt_end(attempt: int, response: Response, score: Score)¶
Notify callback handlers when a red team attempt ends.
- Args:
attempt (int): The attempt number. response (Response): The response from the attempt. score (Score): The score of the attempt.
- on_redteam_attempt_start(attempt: int, prompt: PromptValue)¶
Notify callback handlers when a red team attempt starts.
- Args:
attempt (int): The attempt number. prompt (BasePromptValue): The prompt value.
- on_scanner_plugin_end(name: str)¶
Notify callback handlers when a scanner plugin ends.
- Args:
name (str): The name of the scanner plugin.
- on_scanner_plugin_start(name: str)¶
Notify callback handlers when a scanner plugin starts.
- Args:
name (str): The name of the scanner plugin.
- on_sender_send_prompt_end()¶
- on_sender_send_prompt_start()¶
- exception aisploit.core.ContentFilteredException¶
Bases:
Exception
- class aisploit.core.DataclassDataset¶
Bases:
BaseDataset
,Generic
[T
]Dataset class based on dataclasses.
- class aisploit.core.Prompt(value: str | langchain_core.prompt_values.PromptValue, metadata: Dict[str, Any] = <factory>)¶
Bases:
object
- metadata: Dict[str, Any]¶
- value: str | PromptValue¶
- class aisploit.core.Response(content: str, metadata: ~typing.Dict[str, ~typing.Any] = <factory>)¶
Bases:
object
A class representing a response from the target.
- content: str¶
- metadata: Dict[str, Any]¶
- class aisploit.core.Score(flagged: bool, value: T, description: str = '', explanation: str = '')¶
Bases:
Generic
[T
]A class representing a score.
- Attributes:
flagged (bool): Whether the score is flagged. value (T): The value of the score. description (str): Optional description of the score. explanation (str): Optional explanation of the score.
- description: str¶
- explanation: str¶
- flagged: bool¶
- value: T¶
- class aisploit.core.StringPromptValue(*, text: str, type: Literal['StringPromptValue'] = 'StringPromptValue')¶
Bases:
PromptValue
String prompt value.
- classmethod get_lc_namespace() List[str] ¶
Get the namespace of the langchain object.
- text: str¶
Prompt text.
- to_messages() List[BaseMessage] ¶
Return prompt as messages.
- to_string() str ¶
Return prompt as string.
- type: Literal['StringPromptValue']¶
- class aisploit.core.TabularDataset¶
Bases:
BaseDataset
Dataset class for tabular data.
- class aisploit.core.YamlDeserializable¶
Bases:
object
Base class for objects that can be deserialized from YAML.
- classmethod from_yaml_file(file: Path) T ¶
Load an object from a YAML file.
- Args:
cls (Type[T]): The class to instantiate. file (Path): The path to the YAML file.
- Returns:
T: An instance of the class deserialized from the YAML file.
- Raises:
FileNotFoundError: If the specified file does not exist. ValueError: If there’s an error in parsing the YAML data.