How do you store key-value pair data with NO ORDER?

TinyDB is the easiest data base.

To preserve the list order of a chat history locally, pick a tag for when the chat started, like 2025-12-21-14:40 (My local time for when this board thread started in date time sort order).

Start the value under that tag as an empty list.

As each message arrives as a three key dictionary,

  • retrieve the chat history for the current chat start datetime as a list into a local variable named history (empty list if not found)
  • add the message dictionary object to the list history
  • save the updated chat history list back into its TinyDB tag.

Read the articles on How to Work With Lists.