Additional kwargs are just extra info that openai (or other LLM providers) attach to messages (usually this is for function/tool calls)
You would restore it ideally in your loop above
for row in records:
chat_history.append(
ChatMessage(
role=row[3],
content=row[2],
additional_kwargs=row[??]
)
)
Personally though, I would store an entire JSON of the chat message and restore from that directly
message_json = message.json()
[store in db]
for row in records:
chat_history.append(
ChatMessage.parse_raw(row[<json location>])
)