base
Abstract base class for type adapters used by message serializers.
- class pipecat.bus.adapters.base.TypeAdapter[source]
Bases:
ABCSerialize and deserialize instances of a specific type for network transport.
Each adapter handles one or more types, converting them to/from a JSON-compatible dict. Register adapters on a
JSONMessageSerializerto handle non-JSON-native field values (e.g.LLMContext,ToolsSchema).Adapters receive
serialize_valueanddeserialize_valuecallbacks from the serializer so they can recursively serialize nested fields without importing the serializer itself.- abstractmethod serialize(obj: Any, serialize_value: Callable[[Any], Any]) dict[str, Any][source]
Convert an object to a JSON-compatible dict.
- Parameters:
obj – The object to serialize.
serialize_value – Callback to recursively serialize nested values.
- Returns:
A dict representation of the object.
- abstractmethod deserialize(data: dict[str, Any], deserialize_value: Callable[[Any], Any], target_type: type | None = None) Any[source]
Reconstruct an object from a dict.
- Parameters:
data – The dict representation produced by
serialize().deserialize_value – Callback to recursively deserialize nested values.
target_type – The resolved target class. Defaults to None.
- Returns:
The reconstructed object.