Skip to navigation

nemoguardrails.server.experimental.providers.openai.chat_completions.response_projection

View as MarkdownOpen in Claude

Field policies for guarded buffered OpenAI Chat Completions responses.

Module Contents

Classes

NameDescription
ChatCompletionsAssistantMessageProjectionAccept assistant text while preventing replacement of annotated content.
ChatCompletionsChoiceProjectionExpose the guarded message while preserving opaque choice metadata.
ChatCompletionsGuardedResponseProjectionRequire one guarded choice and retain reviewed provider-owned response fields.

API

class nemoguardrails.server.experimental.providers.openai.chat_completions.response_projection.ChatCompletionsAssistantMessageProjection()

Bases: PolicyModel, GuardedContentModel

Accept assistant text while preventing replacement of annotated content.

annotations
Annotated[list[Any] | None, constrained(reason=(core_capability.citation_content), max_length=0)] = None
audio
Annotated[None, disabled(core_capability.audio_content)] = None
content
Annotated[str | None, guarded(assistant, replaceable=True, blocked_by=annotations, replacement_reason=(provider_integrity.annotated_text))]
function_call
Annotated[None, disabled(core_capability.tool_content)] = None
policy
ObjectPolicy
reasoning_content
Annotated[None, disabled(core_capability.reasoning_content, extension=True)] = None
refusal
Annotated[None, disabled(core_capability.refusal_content)] = None
role
Annotated[Literal['assistant'], constrained()]
tool_calls
Annotated[list[Any] | None, constrained(reason=(core_capability.tool_content), max_length=0)] = None
class nemoguardrails.server.experimental.providers.openai.chat_completions.response_projection.ChatCompletionsChoiceProjection()

Bases: PolicyModel, GuardedContentModel

Expose the guarded message while preserving opaque choice metadata.

finish_reason
Annotated[Any, opaque()] = None
index
Annotated[Any, opaque()] = None
logprobs
Annotated[None, disabled(provider_integrity.token_logprobs)] = None
message
Annotated[ChatCompletionsAssistantMessageProjection, guarded()]
policy
ObjectPolicy = ObjectPolicy(unknown_fields='configurable')
class nemoguardrails.server.experimental.providers.openai.chat_completions.response_projection.ChatCompletionsGuardedResponseProjection()

Bases: PolicyModel, GuardedPayloadModel

Require one guarded choice and retain reviewed provider-owned response fields.

The response is closed to OpenAI’s fields: a member outside them could carry generated text that output rails never inspect.

choices
Annotated[list[ChatCompletionsChoiceProjection], guarded(min_length=1, max_length=1)]
policy
ObjectPolicy