class documentation

class _OpenAIJSONPlainPayloadConverter(EncodingPayloadConverter): (source)

View In Hierarchy

Payload converter for OpenAI agent types that supports Pydantic models and standard Python types.

This converter extends the standard JSON payload converter to handle OpenAI agent-specific types, particularly Pydantic models. It supports:

  1. All Pydantic models and their nested structures
  2. Standard JSON-serializable types
  3. Python standard library types like: - dataclasses - datetime objects - sets - UUIDs
  4. Custom types composed of any of the above

The converter uses Pydantic's serialization capabilities to ensure proper handling of complex types while maintaining compatibility with Temporal's payload system.

See https://docs.pydantic.dev/latest/api/standard_library_types/ for details on supported types.

Method from_payload Convert a Temporal payload back to a Python value.
Method to_payload Convert a value to a Temporal payload.
Property encoding Get the encoding identifier for this converter.
def from_payload(self, payload: temporalio.api.common.v1.Payload, type_hint: type | None = None) -> Any: (source)

Convert a Temporal payload back to a Python value.

This method deserializes the JSON payload and validates it against the provided type hint using Pydantic's validation system.

Note

The type hint is used for validation but the actual type returned may be a Pydantic model instance.

Parameters
payload:temporalio.api.common.v1.PayloadThe Temporal payload to convert.
type_hint:type | NoneOptional type hint for validation.
Returns
AnyThe deserialized and validated value.
def to_payload(self, value: Any) -> temporalio.api.common.v1.Payload | None: (source)

Convert a value to a Temporal payload.

This method wraps the value in a Pydantic RootModel to handle arbitrary types and serializes it to JSON.

Parameters
value:AnyThe value to convert to a payload.
Returns
temporalio.api.common.v1.Payload | NoneA Temporal payload containing the serialized value, or None if the value cannot be converted.

Get the encoding identifier for this converter.

Returns
The string "json/plain" indicating this is a plain JSON converter.