Skip to navigation

nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions

View as MarkdownOpen in Claude

Bind LiteLLM Chat extensions to the single-text OpenAI pipeline.

Reviewed finish metadata is opaque; extension containers remain closed to unreviewed content. See README.md for source/version evidence and field policy.

The OpenAI request binding and stream lifecycle hooks are reused. Python declarations are authoritative; the exported contract describes these effective bindings and is never loaded to construct them. No LiteLLM dependency is needed at runtime.

Module Contents

Classes

NameDescription
LiteLLMAssistantMessageProjectionAdd a closed message extension without changing the guarded text target.
LiteLLMChoiceFieldsPreserve LiteLLM’s original finish reason without inspecting metadata.
LiteLLMChoiceProjectionRebind the message type and constrain the provider-specific choice object.
LiteLLMGuardedResponseDerive coverage and text extraction from the complete dialect model graph.
LiteLLMMessageFieldsAllow the recorded null refusal without accepting uninspected content.
LiteLLMResponseProjectionRetain the single-text response boundary with the reviewed nested types.

Data

LITELLM_CHAT_COMPLETIONS_ENDPOINT

API

class nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions.LiteLLMAssistantMessageProjection()

Bases: ChatCompletionsAssistantMessageProjection

Add a closed message extension without changing the guarded text target.

images
Annotated[list[Any] | None, constrained(reason=(core_capability.multimodal_content), max_length=0)] = None
policy
ObjectPolicy
provider_specific_fields
Annotated[LiteLLMMessageFields | None, constrained()] = None
reasoning_items
Annotated[list[LiteLLMReasoningItemProjection] | None, constrained()] = None
thinking_blocks
Annotated[list[Any] | None, constrained(reason=(core_capability.reasoning_content), max_length=0)] = None
class nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions.LiteLLMChoiceFields()

Bases: PolicyModel

Preserve LiteLLM’s original finish reason without inspecting metadata.

policy
ObjectPolicy = ObjectPolicy(opaque=('native_finish_reason',))
class nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions.LiteLLMChoiceProjection()

Bases: ChatCompletionsChoiceProjection

Rebind the message type and constrain the provider-specific choice object.

message
Annotated[LiteLLMAssistantMessageProjection, guarded()]
policy
ObjectPolicy
provider_specific_fields
Annotated[LiteLLMChoiceFields | None, constrained()] = None
class nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions.LiteLLMGuardedResponse()

Bases: LiteLLMResponseProjection

Derive coverage and text extraction from the complete dialect model graph.

guarded_text_location
= text_location(LiteLLMResponseProjection)
projection_contract
class nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions.LiteLLMMessageFields()

Bases: PolicyModel

Allow the recorded null refusal without accepting uninspected content.

refusal
Annotated[None, disabled(core_capability.refusal_content)] = None
thinking_blocks
Annotated[list[Any] | None, constrained(reason=(core_capability.reasoning_content), max_length=0)] = None
class nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions.LiteLLMResponseProjection()

Bases: ChatCompletionsGuardedResponseProjection

Retain the single-text response boundary with the reviewed nested types.

access_programs
Annotated[Any, opaque()] = None
billing
Annotated[Any, opaque()] = None
choices
Annotated[list[LiteLLMChoiceProjection], guarded(min_length=1, max_length=1)]
frequency_penalty
Annotated[Any, opaque()] = None
image
Annotated[ResponseImageProjection | None, constrained()] = None
input_transformations
InputTransformations = None
presence_penalty
Annotated[Any, opaque()] = None
tool_usage
Annotated[Any, opaque()] = None
nemoguardrails.server.experimental.providers.openai.dialects.litellm.chat_completions.LITELLM_CHAT_COMPLETIONS_ENDPOINT = replace(CHAT_COMPLETIONS_ENDPOINT, contract_name='litellm_chat_completions', ope...