Class Guardrail.LlmPolicy.Builder (0.1.0)

public static final class Guardrail.LlmPolicy.Builder extends GeneratedMessage.Builder<Guardrail.LlmPolicy.Builder> implements Guardrail.LlmPolicyOrBuilder

Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification.

Protobuf type google.cloud.ces.v1.Guardrail.LlmPolicy

Static Methods

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

Methods

build()

public Guardrail.LlmPolicy build()
Returns
Type Description
Guardrail.LlmPolicy

buildPartial()

public Guardrail.LlmPolicy buildPartial()
Returns
Type Description
Guardrail.LlmPolicy

clear()

public Guardrail.LlmPolicy.Builder clear()
Returns
Type Description
Guardrail.LlmPolicy.Builder
Overrides

clearAllowShortUtterance()

public Guardrail.LlmPolicy.Builder clearAllowShortUtterance()

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.

bool allow_short_utterance = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

clearFailOpen()

public Guardrail.LlmPolicy.Builder clearFailOpen()

Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail.

bool fail_open = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

clearMaxConversationMessages()

public Guardrail.LlmPolicy.Builder clearMaxConversationMessages()

Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used.

int32 max_conversation_messages = 1 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

clearModelSettings()

public Guardrail.LlmPolicy.Builder clearModelSettings()

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Guardrail.LlmPolicy.Builder

clearPolicyScope()

public Guardrail.LlmPolicy.Builder clearPolicyScope()

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.

.google.cloud.ces.v1.Guardrail.LlmPolicy.PolicyScope policy_scope = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

clearPrompt()

public Guardrail.LlmPolicy.Builder clearPrompt()

Required. Policy prompt.

string prompt = 3 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

getAllowShortUtterance()

public boolean 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.

bool allow_short_utterance = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

The allowShortUtterance.

getDefaultInstanceForType()

public Guardrail.LlmPolicy getDefaultInstanceForType()
Returns
Type Description
Guardrail.LlmPolicy

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
Overrides

getFailOpen()

public boolean getFailOpen()

Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail.

bool fail_open = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

The failOpen.

getMaxConversationMessages()

public int 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.

int32 max_conversation_messages = 1 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
int

The maxConversationMessages.

getModelSettings()

public ModelSettings getModelSettings()

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
ModelSettings

The modelSettings.

getModelSettingsBuilder()

public ModelSettings.Builder getModelSettingsBuilder()

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
ModelSettings.Builder

getModelSettingsOrBuilder()

public ModelSettingsOrBuilder getModelSettingsOrBuilder()

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
ModelSettingsOrBuilder

getPolicyScope()

public Guardrail.LlmPolicy.PolicyScope 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.

.google.cloud.ces.v1.Guardrail.LlmPolicy.PolicyScope policy_scope = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Guardrail.LlmPolicy.PolicyScope

The policyScope.

getPolicyScopeValue()

public int getPolicyScopeValue()

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.

.google.cloud.ces.v1.Guardrail.LlmPolicy.PolicyScope policy_scope = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
int

The enum numeric value on the wire for policyScope.

getPrompt()

public String getPrompt()

Required. Policy prompt.

string prompt = 3 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
String

The prompt.

getPromptBytes()

public ByteString getPromptBytes()

Required. Policy prompt.

string prompt = 3 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
ByteString

The bytes for prompt.

hasModelSettings()

public boolean hasModelSettings()

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the modelSettings field is set.

internalGetFieldAccessorTable()

protected GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeFrom(Guardrail.LlmPolicy other)

public Guardrail.LlmPolicy.Builder mergeFrom(Guardrail.LlmPolicy other)
Parameter
Name Description
other Guardrail.LlmPolicy
Returns
Type Description
Guardrail.LlmPolicy.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public Guardrail.LlmPolicy.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Guardrail.LlmPolicy.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public Guardrail.LlmPolicy.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
Guardrail.LlmPolicy.Builder
Overrides

mergeModelSettings(ModelSettings value)

public Guardrail.LlmPolicy.Builder mergeModelSettings(ModelSettings value)

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value ModelSettings
Returns
Type Description
Guardrail.LlmPolicy.Builder

setAllowShortUtterance(boolean value)

public Guardrail.LlmPolicy.Builder setAllowShortUtterance(boolean value)

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.

bool allow_short_utterance = 6 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value boolean

The allowShortUtterance to set.

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

setFailOpen(boolean value)

public Guardrail.LlmPolicy.Builder setFailOpen(boolean value)

Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail.

bool fail_open = 5 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value boolean

The failOpen to set.

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

setMaxConversationMessages(int value)

public Guardrail.LlmPolicy.Builder setMaxConversationMessages(int value)

Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used.

int32 max_conversation_messages = 1 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value int

The maxConversationMessages to set.

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

setModelSettings(ModelSettings value)

public Guardrail.LlmPolicy.Builder setModelSettings(ModelSettings value)

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value ModelSettings
Returns
Type Description
Guardrail.LlmPolicy.Builder

setModelSettings(ModelSettings.Builder builderForValue)

public Guardrail.LlmPolicy.Builder setModelSettings(ModelSettings.Builder builderForValue)

Optional. Model settings.

.google.cloud.ces.v1.ModelSettings model_settings = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
builderForValue ModelSettings.Builder
Returns
Type Description
Guardrail.LlmPolicy.Builder

setPolicyScope(Guardrail.LlmPolicy.PolicyScope value)

public Guardrail.LlmPolicy.Builder setPolicyScope(Guardrail.LlmPolicy.PolicyScope value)

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.

.google.cloud.ces.v1.Guardrail.LlmPolicy.PolicyScope policy_scope = 4 [(.google.api.field_behavior) = REQUIRED];

Parameter
Name Description
value Guardrail.LlmPolicy.PolicyScope

The policyScope to set.

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

setPolicyScopeValue(int value)

public Guardrail.LlmPolicy.Builder setPolicyScopeValue(int value)

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.

.google.cloud.ces.v1.Guardrail.LlmPolicy.PolicyScope policy_scope = 4 [(.google.api.field_behavior) = REQUIRED];

Parameter
Name Description
value int

The enum numeric value on the wire for policyScope to set.

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

setPrompt(String value)

public Guardrail.LlmPolicy.Builder setPrompt(String value)

Required. Policy prompt.

string prompt = 3 [(.google.api.field_behavior) = REQUIRED];

Parameter
Name Description
value String

The prompt to set.

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.

setPromptBytes(ByteString value)

public Guardrail.LlmPolicy.Builder setPromptBytes(ByteString value)

Required. Policy prompt.

string prompt = 3 [(.google.api.field_behavior) = REQUIRED];

Parameter
Name Description
value ByteString

The bytes for prompt to set.

Returns
Type Description
Guardrail.LlmPolicy.Builder

This builder for chaining.