Skip to navigation

nemoguardrails.server.experimental.providers.openai.chat_completions.stream_projection

View as MarkdownOpen in Claude

Declare guarded text, closed content boundaries, and opaque stream metadata.

These handwritten models own per-event field policy. The classifier binds them to event roles; handwritten hooks enforce ordering and terminal-state behavior.

Module Contents

Classes

NameDescription
ChatCompletionsStreamChoiceProjectionRequire integer choice zero and reject unreviewed choice-level content.
ChatCompletionsStreamDeltaProjectionAccept assistant text or metadata-only deltas within a closed boundary.
ChatCompletionsStreamErrorDetailsProjectionValidate the native error message without treating it as guarded text.
ChatCompletionsStreamErrorProjectionAccept only an error envelope, never an error mixed with generated content.
ChatCompletionsStreamPayloadProjectionAllow one text choice or an empty usage chunk, preserving root metadata.

API

class nemoguardrails.server.experimental.providers.openai.chat_completions.stream_projection.ChatCompletionsStreamChoiceProjection()

Bases: PolicyModel, GuardedContentModel

Require integer choice zero and reject unreviewed choice-level content.

delta
Annotated[ChatCompletionsStreamDeltaProjection, guarded()]
finish_reason
Annotated[Any, opaque()] = None
index
Annotated[int, constrained(strict=True, ge=0, le=0)]
logprobs
Annotated[None, disabled('provider_integrity.token_logprobs')] = None
class nemoguardrails.server.experimental.providers.openai.chat_completions.stream_projection.ChatCompletionsStreamDeltaProjection()

Bases: PolicyModel, GuardedContentModel

Accept assistant text or metadata-only deltas within a closed boundary.

audio
Annotated[None, disabled('core_capability.audio_content')] = None
content
Annotated[str | None, guarded('assistant')] = None
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'] | None, constrained()] = None
tool_calls
Annotated[list[Any] | None, constrained(reason='core_capability.tool_content', max_length=0)] = None
class nemoguardrails.server.experimental.providers.openai.chat_completions.stream_projection.ChatCompletionsStreamErrorDetailsProjection()

Bases: PolicyModel, GuardedContentModel

Validate the native error message without treating it as guarded text.

code
Annotated[Any, opaque()] = None
message
Annotated[str, constrained()]
misalignment
Annotated[Any, opaque()] = None
param
Annotated[Any, opaque()] = None
policy
ObjectPolicy
type
Annotated[Any, opaque()] = None
class nemoguardrails.server.experimental.providers.openai.chat_completions.stream_projection.ChatCompletionsStreamErrorProjection()

Bases: PolicyModel, GuardedProjectionModel

Accept only an error envelope, never an error mixed with generated content.

error
Annotated[ChatCompletionsStreamErrorDetailsProjection, constrained()]
policy
ObjectPolicy = ObjectPolicy(source='ErrorResponse')
class nemoguardrails.server.experimental.providers.openai.chat_completions.stream_projection.ChatCompletionsStreamPayloadProjection()

Bases: PolicyModel, GuardedProjectionModel

Allow one text choice or an empty usage chunk, preserving root metadata.

choices
Annotated[list[ChatCompletionsStreamChoiceProjection], guarded(max_length=1)]
object
Annotated[Literal['chat.completion.chunk'], constrained()]
policy
ObjectPolicy