Skip to main content

guardrails

Creates, updates, deletes, gets or lists a guardrails resource.

Overview

Nameguardrails
TypeResource
Idgoogle.ces.guardrails

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringIdentifier. The unique identifier of the guardrail. Format: projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}
actionobjectOptional. Action to take when the guardrail is triggered. (id: TriggerAction)
codeCallbackobjectOptional. Guardrail that potentially blocks the conversation based on the result of the callback execution. (id: GuardrailCodeCallback)
contentFilterobjectOptional. Guardrail that bans certain content from being used in the conversation. (id: GuardrailContentFilter)
createTimestring (google-datetime)Output only. Timestamp when the guardrail was created.
descriptionstringOptional. Description of the guardrail.
displayNamestringRequired. Display name of the guardrail.
enabledbooleanOptional. Whether the guardrail is enabled.
etagstringEtag 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.
llmPolicyobjectOptional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification. (id: GuardrailLlmPolicy)
llmPromptSecurityobjectOptional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification. (id: GuardrailLlmPromptSecurity)
modelSafetyobjectOptional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings. (id: GuardrailModelSafety)
updateTimestring (google-datetime)Output only. Timestamp when the guardrail was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, appsId, guardrailsIdGets details of the specified guardrail.
listselectprojectsId, locationsId, appsIdpageSize, pageToken, filter, orderByLists guardrails in the given app.
createinsertprojectsId, locationsId, appsIdguardrailIdCreates a new guardrail in the given app.
patchupdateprojectsId, locationsId, appsId, guardrailsIdupdateMaskUpdates the specified guardrail.
deletedeleteprojectsId, locationsId, appsId, guardrailsIdforce, etagDeletes 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.

NameDatatypeDescription
appsIdstring
guardrailsIdstring
locationsIdstring
projectsIdstring
etagstring
filterstring
forceboolean
guardrailIdstring
orderBystring
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples

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
;

INSERT examples

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
;

UPDATE examples

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

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 }}'
;