freeze_local_states#
- penzai.deprecated.v1.data_effects.local_state.freeze_local_states(handled: WithFunctionalLocalState, states: dict[str, Any]) Any [source]#
Embeds the given states into a handled model, and removes the handler.
This function converts a functionalized stateful model into a single effectful one, making it easier to inspect, patch, or serialize. It is roughly the inverse of
handle_local_states
, andhandle_local_states
can be used to re-install the handler.- Parameters:
handled – A WithFunctionalLocalState wrapping a model, as constructed using
handle_local_states
.states – A state dictionary, either from
handle_local_states
or from calling the handled model to get updated states.
- Returns:
A copy of the original model, without the
WithFunctionalLocalState
wrapper, and with each of the states embedded as aFrozenLocalStateRequest
inside the tree.