r"""A toolkit for assessing the risk associated with functions. Args: verbose (Optional[bool]): Whether to print verbose output. (default: :obj:`False`)
| 18 | |
| 19 | |
| 20 | class FunctionRiskToolkit(BaseToolkit): |
| 21 | r"""A toolkit for assessing the risk associated with functions. |
| 22 | |
| 23 | Args: |
| 24 | verbose (Optional[bool]): Whether to print verbose output. |
| 25 | (default: :obj:`False`) |
| 26 | """ |
| 27 | |
| 28 | def __init__(self, verbose: Optional[bool] = False): |
| 29 | self.verbose = verbose |
| 30 | |
| 31 | def function_risk(self, score: int, reason: str): |
| 32 | r"""Provides an assessment of the potential risk associated |
| 33 | with a function. |
| 34 | |
| 35 | Args: |
| 36 | score (int): The risk level associated with the function, |
| 37 | ranging from 1 to 3: |
| 38 | - 1: No harm |
| 39 | (e.g., simple math operations, content searches) |
| 40 | - 2: Minimal harm (e.g., accessing user files) |
| 41 | - 3: Risk present |
| 42 | (e.g., deleting files, modifying the file system) |
| 43 | reason (str): A brief explanation of the reasoning behind |
| 44 | the assigned score, describing the specific aspects that |
| 45 | contribute to the assessed risk. |
| 46 | """ |
| 47 | if self.verbose: |
| 48 | print(f"Function risk assessment: {reason} (score: {score})") |
| 49 | |
| 50 | def get_tools(self) -> List[FunctionTool]: |
| 51 | r"""Returns a list of FunctionTool objects representing the |
| 52 | functions in the toolkit. |
| 53 | |
| 54 | Returns: |
| 55 | List[FunctionTool]: A list of FunctionTool objects |
| 56 | representing the functions in the toolkit. |
| 57 | """ |
| 58 | return [FunctionTool(self.function_risk)] |