nemoguardrails.library.jailbreak_detection.server

View as Markdown

Module Contents

Classes

NameDescription
JailbreakHeuristicRequestprompt (str): User utterance to the model
JailbreakModelRequestSince the embedding model corresponds exactly to the classifier, we only need to provide the embedding model in the request.

Functions

Data

app

cli_app

device

API

class nemoguardrails.library.jailbreak_detection.server.JailbreakHeuristicRequest()

Bases: BaseModel

prompt (str): User utterance to the model lp_threshold (float): Threshold value for length-perplexity heuristic. Default: 89.79 ps_ppl_threshold (float): Threshold value for prefix/suffix perplexity heuristic. Default: 1845.65

lp_threshold
Optional[float] = 89.79
prompt
str
ps_ppl_threshold
Optional[float] = 1845.65
class nemoguardrails.library.jailbreak_detection.server.JailbreakModelRequest()

Bases: BaseModel

Since the embedding model corresponds exactly to the classifier, we only need to provide the embedding model in the request.

prompt (str): User utterance to the model

prompt
str
nemoguardrails.library.jailbreak_detection.server.hello_world()
nemoguardrails.library.jailbreak_detection.server.lp_heuristic_check(
request: nemoguardrails.library.jailbreak_detection.server.JailbreakHeuristicRequest
)
nemoguardrails.library.jailbreak_detection.server.ps_ppl_heuristic_check(
request: nemoguardrails.library.jailbreak_detection.server.JailbreakHeuristicRequest
)
nemoguardrails.library.jailbreak_detection.server.run_all_heuristics(
request: nemoguardrails.library.jailbreak_detection.server.JailbreakHeuristicRequest
)
nemoguardrails.library.jailbreak_detection.server.run_model_check(
request: nemoguardrails.library.jailbreak_detection.server.JailbreakModelRequest
)
nemoguardrails.library.jailbreak_detection.server.start(
port: int = typer.Option(default=1337, ...,
host: str = typer.Option(default='0.0.0...
)
nemoguardrails.library.jailbreak_detection.server.app = FastAPI()
nemoguardrails.library.jailbreak_detection.server.cli_app = typer.Typer()
nemoguardrails.library.jailbreak_detection.server.device = os.environ.get('JAILBREAK_CHECK_DEVICE', 'cpu')