Skip to content

Latest commit

 

History

History
221 lines (145 loc) · 13.8 KB

File metadata and controls

221 lines (145 loc) · 13.8 KB

GuardrailRules

Overview

Available Operations

  • list - List guardrail rules
  • create - Create guardrail rule
  • delete - Delete guardrail rule
  • retrieve - Get guardrail rule
  • update - Update guardrail rule

list

Returns a paginated list of guardrail rules for the current project.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.guardrail_rules.list(limit=10)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
limit Optional[int] N/A
starting_after Optional[str] A cursor for use in pagination.
ending_before Optional[str] A cursor for use in pagination.
project_id Optional[str] Optional filter by project ID.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GuardrailRuleListResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

create

Creates a new guardrail rule with expression, guardrails configuration, and timeout settings.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.guardrail_rules.create(display_name="Rosemarie_Wisoky")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
display_name str ✔️ N/A
description Optional[str] N/A
enabled Optional[bool] N/A
expression Optional[models.ExpressionInput] N/A
guardrails List[models.GuardrailRef] N/A
project_id Optional[str] Optional project ID. If null/omitted, the entity is global (workspace-wide).
timeout Optional[int] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GuardrailRuleCreateResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

delete

Deletes an existing guardrail rule by ID.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.guardrail_rules.delete(guardrail_rule_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
guardrail_rule_id str ✔️ The ID of the guardrail rule
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

retrieve

Retrieves the details of an existing guardrail rule by ID.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.guardrail_rules.retrieve(guardrail_rule_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
guardrail_rule_id str ✔️ The ID of the guardrail rule
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GuardrailRuleGetResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

update

Partially updates an existing guardrail rule. Only provided fields are updated.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.guardrail_rules.update(guardrail_rule_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
guardrail_rule_id str ✔️ The ID of the guardrail rule
description Optional[str] N/A
display_name Optional[str] N/A
enabled Optional[bool] N/A
expression Optional[models.ExpressionInput] N/A
guardrails List[models.GuardrailRef] N/A
timeout Optional[int] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GuardrailRuleUpdateResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*