Conversation.from_dict()

Reconstruct a conversation from a dictionary produced by to_dict().

Usage

Source

Conversation.from_dict(data)

Parameters

data: dict[str, Any]
A dictionary with the structure produced by to_dict().

Returns

Conversation
A fully restored conversation with all messages and metadata.

Examples

from talk_box.conversation import Conversation

convo = Conversation()
convo.add_user_message("Saved message")
restored = Conversation.from_dict(convo.to_dict())
restored.get_message_count()
1