GuardrailsApi
Method |
HTTP request |
Description |
|---|---|---|
GET /guardrails/effective |
Get effective guardrails settings. |
|
GET /guardrails/violations/dashboard |
Get guardrail violations dashboard data. |
|
GET /guardrails/violations/summary |
Get guardrail violation summary KPIs. |
|
GET /guardrails/violations |
List guardrail violations. |
get_effective_guardrails
GuardrailsSettings get_effective_guardrails(chat_session_id=chat_session_id, collection_id=collection_id)
Get effective guardrails settings.
Returns the effective guardrails settings based on the hierarchy (chat session > collection > global admin > defaults).
Example
Bearer Authentication (bearerAuth):
import h2ogpte.rest_sync
from h2ogpte.rest_sync.models.guardrails_settings import GuardrailsSettings
from h2ogpte.rest_sync.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest_sync.Configuration(
host = "https://h2ogpte.genai.h2o.ai/api/v1"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest_sync.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with h2ogpte.rest_sync.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = h2ogpte.rest_sync.GuardrailsApi(api_client)
chat_session_id = 'chat_session_id_example' # str | Optional chat session ID to check for chat-level settings (optional)
collection_id = 'collection_id_example' # str | Optional collection ID to check for collection-level settings (optional)
try:
# Get effective guardrails settings.
api_response = api_instance.get_effective_guardrails(chat_session_id=chat_session_id, collection_id=collection_id)
print("The response of GuardrailsApi->get_effective_guardrails:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling GuardrailsApi->get_effective_guardrails: %s\n" % e)
Parameters
Name |
Type |
Description |
Notes |
|---|---|---|---|
chat_session_id |
str |
Optional chat session ID to check for chat-level settings |
[optional] |
collection_id |
str |
Optional collection ID to check for collection-level settings |
[optional] |
Return type
HTTP request headers
Content-Type: Not defined
Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
|---|---|---|
200 |
Successful operation |
- |
400 |
Bad request |
- |
401 |
Unauthorized - Invalid or missing API key |
- |
get_guardrail_violations_dashboard
GuardrailViolationsDashboard get_guardrail_violations_dashboard(interval=interval, collection_id_filter=collection_id_filter, user_id_filter=user_id_filter)
Get guardrail violations dashboard data.
Returns daily trend, breakdown by violation type, by collection, and by user. Admin only.
Example
Bearer Authentication (bearerAuth):
import h2ogpte.rest_sync
from h2ogpte.rest_sync.models.guardrail_violations_dashboard import GuardrailViolationsDashboard
from h2ogpte.rest_sync.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest_sync.Configuration(
host = "https://h2ogpte.genai.h2o.ai/api/v1"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest_sync.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with h2ogpte.rest_sync.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = h2ogpte.rest_sync.GuardrailsApi(api_client)
interval = '7 days' # str | Time interval to aggregate over (e.g. \"7 days\", \"30 days\", \"90 days\"). (optional) (default to '7 days')
collection_id_filter = '' # str | Filter by collection ID. (optional) (default to '')
user_id_filter = '' # str | Filter by user ID. (optional) (default to '')
try:
# Get guardrail violations dashboard data.
api_response = api_instance.get_guardrail_violations_dashboard(interval=interval, collection_id_filter=collection_id_filter, user_id_filter=user_id_filter)
print("The response of GuardrailsApi->get_guardrail_violations_dashboard:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling GuardrailsApi->get_guardrail_violations_dashboard: %s\n" % e)
Parameters
Name |
Type |
Description |
Notes |
|---|---|---|---|
interval |
str |
Time interval to aggregate over (e.g. "7 days", "30 days", "90 days"). |
[optional] [default to ‘7 days’] |
collection_id_filter |
str |
Filter by collection ID. |
[optional] [default to ‘’] |
user_id_filter |
str |
Filter by user ID. |
[optional] [default to ‘’] |
Return type
HTTP request headers
Content-Type: Not defined
Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
|---|---|---|
200 |
Successful operation |
- |
400 |
Bad request |
- |
401 |
Unauthorized - Invalid or missing API key |
- |
403 |
Forbidden |
- |
get_guardrail_violations_summary
GuardrailViolationsSummary get_guardrail_violations_summary(interval=interval)
Get guardrail violation summary KPIs.
Returns total violation counts, time-window breakdowns, violation rate, and per-type breakdown. Admin only.
Example
Bearer Authentication (bearerAuth):
import h2ogpte.rest_sync
from h2ogpte.rest_sync.models.guardrail_violations_summary import GuardrailViolationsSummary
from h2ogpte.rest_sync.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest_sync.Configuration(
host = "https://h2ogpte.genai.h2o.ai/api/v1"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest_sync.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with h2ogpte.rest_sync.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = h2ogpte.rest_sync.GuardrailsApi(api_client)
interval = '7 days' # str | Time interval to aggregate over (e.g. \"7 days\", \"30 days\", \"90 days\"). (optional) (default to '7 days')
try:
# Get guardrail violation summary KPIs.
api_response = api_instance.get_guardrail_violations_summary(interval=interval)
print("The response of GuardrailsApi->get_guardrail_violations_summary:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling GuardrailsApi->get_guardrail_violations_summary: %s\n" % e)
Parameters
Name |
Type |
Description |
Notes |
|---|---|---|---|
interval |
str |
Time interval to aggregate over (e.g. "7 days", "30 days", "90 days"). |
[optional] [default to ‘7 days’] |
Return type
HTTP request headers
Content-Type: Not defined
Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
|---|---|---|
200 |
Successful operation |
- |
400 |
Bad request |
- |
401 |
Unauthorized - Invalid or missing API key |
- |
403 |
Forbidden |
- |
list_guardrail_violations
GuardrailViolationsList list_guardrail_violations(offset=offset, limit=limit, interval=interval, type_filter=type_filter, collection_id_filter=collection_id_filter, user_id_filter=user_id_filter)
List guardrail violations.
Returns a paginated list of guardrail violations with user and collection context. Admin only.
Example
Bearer Authentication (bearerAuth):
import h2ogpte.rest_sync
from h2ogpte.rest_sync.models.guardrail_violations_list import GuardrailViolationsList
from h2ogpte.rest_sync.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest_sync.Configuration(
host = "https://h2ogpte.genai.h2o.ai/api/v1"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest_sync.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with h2ogpte.rest_sync.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = h2ogpte.rest_sync.GuardrailsApi(api_client)
offset = 0 # int | (optional) (default to 0)
limit = 50 # int | (optional) (default to 50)
interval = '7 days' # str | Time interval to filter by (e.g. \"7 days\", \"30 days\", \"90 days\"). (optional) (default to '7 days')
type_filter = '' # str | Filter by violation type (e.g. \"guardrails_safety\", \"presidio_pii\"). (optional) (default to '')
collection_id_filter = '' # str | Filter by collection ID. (optional) (default to '')
user_id_filter = '' # str | Filter by user ID. (optional) (default to '')
try:
# List guardrail violations.
api_response = api_instance.list_guardrail_violations(offset=offset, limit=limit, interval=interval, type_filter=type_filter, collection_id_filter=collection_id_filter, user_id_filter=user_id_filter)
print("The response of GuardrailsApi->list_guardrail_violations:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling GuardrailsApi->list_guardrail_violations: %s\n" % e)
Parameters
Name |
Type |
Description |
Notes |
|---|---|---|---|
offset |
int |
[optional] [default to 0] |
|
limit |
int |
[optional] [default to 50] |
|
interval |
str |
Time interval to filter by (e.g. "7 days", "30 days", "90 days"). |
[optional] [default to ‘7 days’] |
type_filter |
str |
Filter by violation type (e.g. "guardrails_safety", "presidio_pii"). |
[optional] [default to ‘’] |
collection_id_filter |
str |
Filter by collection ID. |
[optional] [default to ‘’] |
user_id_filter |
str |
Filter by user ID. |
[optional] [default to ‘’] |
Return type
HTTP request headers
Content-Type: Not defined
Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
|---|---|---|
200 |
Successful operation |
- |
400 |
Bad request |
- |
401 |
Unauthorized - Invalid or missing API key |
- |
403 |
Forbidden |
- |