LLMGuardRuntime

class LLMGuardRuntime(BaseRuntime):

A runtime that evaluates the risk level of functions using a language model.

Parameters:

  • prompt (str): The prompt to use for the language model. (default: :obj:GUARDPROMPT)
  • model (BaseModelBackend): The language model to use. (default: :obj: None)
  • verbose (bool): Whether to print verbose output. (default: :obj: False)

init

def __init__(
    self,
    prompt: str = GUARDPROMPT,
    model: Optional[BaseModelBackend] = None,
    verbose: bool = False
):

add

def add(
    self,
    funcs: Union[FunctionTool, List[FunctionTool]],
    threshold: int = 2
):

Add a function or list of functions to the runtime.

Parameters:

  • funcs (FunctionTool or List[FunctionTool]): The function or list of functions to add.
  • threshold (int): The risk threshold for functions. (default: :obj:2)

Returns:

LLMGuardRuntime: The current runtime.

reset

def reset(self):

Resets the runtime to its initial state.