guardrails
Creates, updates, deletes, gets or lists a guardrails resource.
Overview
| Name | guardrails |
| Type | Resource |
| Id | google.ces.guardrails |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
name | string | Identifier. The unique identifier of the guardrail. Format: projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail} |
action | object | Optional. Action to take when the guardrail is triggered. (id: TriggerAction) |
codeCallback | object | Optional. Guardrail that potentially blocks the conversation based on the result of the callback execution. (id: GuardrailCodeCallback) |
contentFilter | object | Optional. Guardrail that bans certain content from being used in the conversation. (id: GuardrailContentFilter) |
createTime | string (google-datetime) | Output only. Timestamp when the guardrail was created. |
description | string | Optional. Description of the guardrail. |
displayName | string | Required. Display name of the guardrail. |
enabled | boolean | Optional. Whether the guardrail is enabled. |
etag | string | Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes. |
llmPolicy | object | Optional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification. (id: GuardrailLlmPolicy) |
llmPromptSecurity | object | Optional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification. (id: GuardrailLlmPromptSecurity) |
modelSafety | object | Optional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings. (id: GuardrailModelSafety) |
updateTime | string (google-datetime) | Output only. Timestamp when the guardrail was last updated. |
| Name | Datatype | Description |
|---|---|---|
name | string | Identifier. The unique identifier of the guardrail. Format: projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail} |
action | object | Optional. Action to take when the guardrail is triggered. (id: TriggerAction) |
codeCallback | object | Optional. Guardrail that potentially blocks the conversation based on the result of the callback execution. (id: GuardrailCodeCallback) |
contentFilter | object | Optional. Guardrail that bans certain content from being used in the conversation. (id: GuardrailContentFilter) |
createTime | string (google-datetime) | Output only. Timestamp when the guardrail was created. |
description | string | Optional. Description of the guardrail. |
displayName | string | Required. Display name of the guardrail. |
enabled | boolean | Optional. Whether the guardrail is enabled. |
etag | string | Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes. |
llmPolicy | object | Optional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification. (id: GuardrailLlmPolicy) |
llmPromptSecurity | object | Optional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification. (id: GuardrailLlmPromptSecurity) |
modelSafety | object | Optional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings. (id: GuardrailModelSafety) |
updateTime | string (google-datetime) | Output only. Timestamp when the guardrail was last updated. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | projectsId, locationsId, appsId, guardrailsId | Gets details of the specified guardrail. | |
list | select | projectsId, locationsId, appsId | pageSize, pageToken, filter, orderBy | Lists guardrails in the given app. |
create | insert | projectsId, locationsId, appsId | guardrailId | Creates a new guardrail in the given app. |
patch | update | projectsId, locationsId, appsId, guardrailsId | updateMask | Updates the specified guardrail. |
delete | delete | projectsId, locationsId, appsId, guardrailsId | force, etag | Deletes the specified guardrail. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
appsId | string | |
guardrailsId | string | |
locationsId | string | |
projectsId | string | |
etag | string | |
filter | string | |
force | boolean | |
guardrailId | string | |
orderBy | string | |
pageSize | integer (int32) | |
pageToken | string | |
updateMask | string (google-fieldmask) |
SELECT examples
- get
- list
Gets details of the specified guardrail.
SELECT
name,
action,
codeCallback,
contentFilter,
createTime,
description,
displayName,
enabled,
etag,
llmPolicy,
llmPromptSecurity,
modelSafety,
updateTime
FROM google.ces.guardrails
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND appsId = '{{ appsId }}' -- required
AND guardrailsId = '{{ guardrailsId }}' -- required
;
Lists guardrails in the given app.
SELECT
name,
action,
codeCallback,
contentFilter,
createTime,
description,
displayName,
enabled,
etag,
llmPolicy,
llmPromptSecurity,
modelSafety,
updateTime
FROM google.ces.guardrails
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND appsId = '{{ appsId }}' -- required
AND pageSize = '{{ pageSize }}'
AND pageToken = '{{ pageToken }}'
AND filter = '{{ filter }}'
AND orderBy = '{{ orderBy }}'
;
INSERT examples
- create
- Manifest
Creates a new guardrail in the given app.
INSERT INTO google.ces.guardrails (
data__description,
data__codeCallback,
data__etag,
data__llmPolicy,
data__enabled,
data__llmPromptSecurity,
data__name,
data__displayName,
data__contentFilter,
data__modelSafety,
data__action,
projectsId,
locationsId,
appsId,
guardrailId
)
SELECT
'{{ description }}',
'{{ codeCallback }}',
'{{ etag }}',
'{{ llmPolicy }}',
{{ enabled }},
'{{ llmPromptSecurity }}',
'{{ name }}',
'{{ displayName }}',
'{{ contentFilter }}',
'{{ modelSafety }}',
'{{ action }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ appsId }}',
'{{ guardrailId }}'
RETURNING
name,
action,
codeCallback,
contentFilter,
createTime,
description,
displayName,
enabled,
etag,
llmPolicy,
llmPromptSecurity,
modelSafety,
updateTime
;
# Description fields are for documentation purposes
- name: guardrails
props:
- name: projectsId
value: "{{ projectsId }}"
description: Required parameter for the guardrails resource.
- name: locationsId
value: "{{ locationsId }}"
description: Required parameter for the guardrails resource.
- name: appsId
value: "{{ appsId }}"
description: Required parameter for the guardrails resource.
- name: description
value: "{{ description }}"
description: |
Optional. Description of the guardrail.
- name: codeCallback
description: |
Optional. Guardrail that potentially blocks the conversation based on the result of the callback execution.
value:
beforeAgentCallback:
pythonCode: "{{ pythonCode }}"
disabled: {{ disabled }}
description: "{{ description }}"
proactiveExecutionEnabled: {{ proactiveExecutionEnabled }}
afterModelCallback:
pythonCode: "{{ pythonCode }}"
disabled: {{ disabled }}
description: "{{ description }}"
proactiveExecutionEnabled: {{ proactiveExecutionEnabled }}
beforeModelCallback:
pythonCode: "{{ pythonCode }}"
disabled: {{ disabled }}
description: "{{ description }}"
proactiveExecutionEnabled: {{ proactiveExecutionEnabled }}
afterAgentCallback:
pythonCode: "{{ pythonCode }}"
disabled: {{ disabled }}
description: "{{ description }}"
proactiveExecutionEnabled: {{ proactiveExecutionEnabled }}
- name: etag
value: "{{ etag }}"
description: |
Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes.
- name: llmPolicy
description: |
Optional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification.
value:
policyScope: "{{ policyScope }}"
maxConversationMessages: {{ maxConversationMessages }}
modelSettings:
model: "{{ model }}"
temperature: {{ temperature }}
failOpen: {{ failOpen }}
allowShortUtterance: {{ allowShortUtterance }}
prompt: "{{ prompt }}"
- name: enabled
value: {{ enabled }}
description: |
Optional. Whether the guardrail is enabled.
- name: llmPromptSecurity
description: |
Optional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification.
value:
defaultSettings:
defaultPromptTemplate: "{{ defaultPromptTemplate }}"
failOpen: {{ failOpen }}
customPolicy:
policyScope: "{{ policyScope }}"
maxConversationMessages: {{ maxConversationMessages }}
modelSettings:
model: "{{ model }}"
temperature: {{ temperature }}
failOpen: {{ failOpen }}
allowShortUtterance: {{ allowShortUtterance }}
prompt: "{{ prompt }}"
- name: name
value: "{{ name }}"
description: |
Identifier. The unique identifier of the guardrail. Format: `projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}`
- name: displayName
value: "{{ displayName }}"
description: |
Required. Display name of the guardrail.
- name: contentFilter
description: |
Optional. Guardrail that bans certain content from being used in the conversation.
value:
matchType: "{{ matchType }}"
disregardDiacritics: {{ disregardDiacritics }}
bannedContentsInAgentResponse:
- "{{ bannedContentsInAgentResponse }}"
bannedContentsInUserInput:
- "{{ bannedContentsInUserInput }}"
bannedContents:
- "{{ bannedContents }}"
- name: modelSafety
description: |
Optional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings.
value:
safetySettings:
- category: "{{ category }}"
threshold: "{{ threshold }}"
- name: action
description: |
Optional. Action to take when the guardrail is triggered.
value:
generativeAnswer:
prompt: "{{ prompt }}"
respondImmediately:
responses:
- disabled: {{ disabled }}
text: "{{ text }}"
transferAgent:
agent: "{{ agent }}"
- name: guardrailId
value: "{{ guardrailId }}"
UPDATE examples
- patch
Updates the specified guardrail.
UPDATE google.ces.guardrails
SET
data__description = '{{ description }}',
data__codeCallback = '{{ codeCallback }}',
data__etag = '{{ etag }}',
data__llmPolicy = '{{ llmPolicy }}',
data__enabled = {{ enabled }},
data__llmPromptSecurity = '{{ llmPromptSecurity }}',
data__name = '{{ name }}',
data__displayName = '{{ displayName }}',
data__contentFilter = '{{ contentFilter }}',
data__modelSafety = '{{ modelSafety }}',
data__action = '{{ action }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND appsId = '{{ appsId }}' --required
AND guardrailsId = '{{ guardrailsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
action,
codeCallback,
contentFilter,
createTime,
description,
displayName,
enabled,
etag,
llmPolicy,
llmPromptSecurity,
modelSafety,
updateTime;
DELETE examples
- delete
Deletes the specified guardrail.
DELETE FROM google.ces.guardrails
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND appsId = '{{ appsId }}' --required
AND guardrailsId = '{{ guardrailsId }}' --required
AND force = '{{ force }}'
AND etag = '{{ etag }}'
;