class datarobotx.llm.GuardrailConfig(deployment_id, datarobot_key, prediction_server_endpoint, blocked_msg='This content has been blocked because it did not meet acceptable use guidelines.', guardrail_prompt=None, input_parser=<function GuardrailConfig.<lambda>>, output_parser=<function GuardrailConfig.<lambda>>, timeout_secs=5.0, bypass_on_timeout=False)#

Guardrail configuration.

  • deployment_id (str) – DR MLOps deployment id for the guardrail

  • datarobot_key (str) – MLOps DR key to be used when making predictions with the guardrail

  • prediction_server_endpoint (str) – Prediction server endpoint (including API + version suffix) for making predictions with the guardrail

  • blocked_msg (str, optional) – Message that should be returned as output if the guardrail flags an input

  • guardrail_prompt (PromptTemplate or str, optional) – Prompt template to be used to control how input(s) are combined and formatted as a string before being passed to the guardrail; if omitted the inputs will be presented as a newline-separated string of key: value pairs

  • input_parser (Callable, optional) – Hook to customize how a formatted guardrail prompt string should be passed to the guardrail as JSON; callable should accept a string and return a dictionary that is serializable to JSON; if omitted, the formatted prompt will be passed as a dictionary value associated with they key ‘input’

  • output_parser (Callable, optional) – Hook to customize how to determine whether the input was flagged by the guardrail model based on the guardrail model’s output; callable should accept a dictionary (deserialized JSON) and return a bool indicating whether the guardrail flagged this input; if omitted, the value associated with the key ‘flagged’ in the returned dictionary will be cast as a bool

  • timeout_secs (float, optional, default=5.0) – Maximum time to wait in seconds for guardrail to return

  • bypass_on_timeout (bool, optional, default=False) – Whether to bypass the guardrail or block content if the guardrail times out