class _OpenAIJSONPlainPayloadConverter(EncodingPayloadConverter): (source)
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:
- All Pydantic models and their nested structures
- Standard JSON-serializable types
- Python standard library types like: - dataclasses - datetime objects - sets - UUIDs
- 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 |
Convert a Temporal payload back to a Python value. |
Method | to |
Convert a value to a Temporal payload. |
Property | encoding |
Get the encoding identifier for this converter. |
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.Payload | The Temporal payload to convert. |
typetype | None | Optional type hint for validation. |
Returns | |
Any | The deserialized and validated value. |
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:Any | The value to convert to a payload. |
Returns | |
temporalio.api.common.v1.Payload | None | A Temporal payload containing the serialized value, or None if the value cannot be converted. |