Skip to content

watsonx

% pip install novastack-guardrails-watsonx

WatsonxGuardrail #

Bases: BaseGuardrail

Provides functionality to interact with IBM watsonx.governance Guardrails.

Info

Beekeeper currently does not support agent_function_call_validation policy provided by IBM Watsonx Governance Guardrails manager.

Attributes:

Name Type Description
api_key str

The API key for IBM watsonx.governance.

policy_id str

The policy ID in watsonx.governance.

inventory_id str

The inventory ID in watsonx.governance.

instance_id str

The instance ID in watsonx.governance.

region Region

The region where watsonx.governance is hosted when using IBM Cloud. Defaults to us-south.

Example
from novastack.guardrails.watsonx.supporting_classes.enums import Region

from novastack.guardrails.watsonx import (
    WatsonxGuardrail,
)

# watsonx.governance (IBM Cloud)
guardrails_manager = WatsonxGuardrail(
    api_key="API_KEY",
    policy_id="POLICY_ID",
    inventory_id="INVENTORY_ID",
    instance_id="INSTANCE_ID",
    region=Region.US_SOUTH,
)

enforce #

enforce(text: str, direction: Direction, prompt: str | None = None, context: list = []) -> GuardrailResponse

Runs policies enforcement to specified guardrail.

Parameters:

Name Type Description Default
text str

The input text that needs to be evaluated or processed according to the guardrail policy.

required
direction Direction

Whether the guardrail is processing the input or generated output.

required
prompt str

The prompt.

None
context list

List of context.

[]
Example
from novastack.core.guardrails.enums import Direction

guardrails_manager.enforce(
    text="Hi, How can I help you?",
    direction=Direction.OUTPUT,
    prompt="You are a helpful assistant.",
)

Enums#

Region #

Bases: str, Enum

Supported IBM watsonx.governance regions.

Defines the available regions where watsonx.governance SaaS services are deployed.

Attributes:

Name Type Description
US_SOUTH str

"us-south".

EU_DE str

"eu-de".

AU_SYD str

"au-syd".

Direction #

Bases: str, Enum

Supported IBM watsonx.governance directions (input/output).

Attributes:

Name Type Description
INPUT str

"input".

OUTPUT str

"output".