Reference documentation and code samples for the Google Cloud Ces V1 Client class LlmPolicy.
Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification.
Generated from protobuf message google.cloud.ces.v1.Guardrail.LlmPolicy
Namespace
Google \ Cloud \ Ces \ V1 \ GuardrailMethods
__construct
Constructor.
| Parameters | |
|---|---|
| Name | Description |
data |
array
Optional. Data for populating the Message object. |
↳ max_conversation_messages |
int
Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used. |
↳ model_settings |
Google\Cloud\Ces\V1\ModelSettings
Optional. Model settings. |
↳ prompt |
string
Required. Policy prompt. |
↳ policy_scope |
int
Required. Defines when to apply the policy check during the conversation. If set to |
↳ fail_open |
bool
Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail. |
↳ allow_short_utterance |
bool
Optional. By default, the LLM policy check is bypassed for short utterances. Enabling this setting applies the policy check to all utterances, including those that would normally be skipped. |
getMaxConversationMessages
Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used.
| Returns | |
|---|---|
| Type | Description |
int |
|
setMaxConversationMessages
Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used.
| Parameter | |
|---|---|
| Name | Description |
var |
int
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getModelSettings
Optional. Model settings.
| Returns | |
|---|---|
| Type | Description |
Google\Cloud\Ces\V1\ModelSettings|null |
|
hasModelSettings
clearModelSettings
setModelSettings
Optional. Model settings.
| Parameter | |
|---|---|
| Name | Description |
var |
Google\Cloud\Ces\V1\ModelSettings
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getPrompt
Required. Policy prompt.
| Returns | |
|---|---|
| Type | Description |
string |
|
setPrompt
Required. Policy prompt.
| Parameter | |
|---|---|
| Name | Description |
var |
string
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getPolicyScope
Required. Defines when to apply the policy check during the conversation.
If set to POLICY_SCOPE_UNSPECIFIED, the policy will be applied to the
user input. When applying the policy to the agent response, additional
latency will be introduced before the agent can respond.
| Returns | |
|---|---|
| Type | Description |
int |
Enum of type PolicyScope. |
setPolicyScope
Required. Defines when to apply the policy check during the conversation.
If set to POLICY_SCOPE_UNSPECIFIED, the policy will be applied to the
user input. When applying the policy to the agent response, additional
latency will be introduced before the agent can respond.
| Parameter | |
|---|---|
| Name | Description |
var |
int
Enum of type PolicyScope. |
| Returns | |
|---|---|
| Type | Description |
$this |
|
getFailOpen
Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail.
| Returns | |
|---|---|
| Type | Description |
bool |
|
setFailOpen
Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail.
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getAllowShortUtterance
Optional. By default, the LLM policy check is bypassed for short utterances. Enabling this setting applies the policy check to all utterances, including those that would normally be skipped.
| Returns | |
|---|---|
| Type | Description |
bool |
|
setAllowShortUtterance
Optional. By default, the LLM policy check is bypassed for short utterances. Enabling this setting applies the policy check to all utterances, including those that would normally be skipped.
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|