Store ChatCompletionMessage responses in a database

Hello everybody,

I would like to know if somebody can help me in storing a
ChatCompletionMessage objects ( which are returned from the API in a database table. I would like to save the entire conversation with the AI (including tools call messages produced by the AI) so that I can pick it up later and continue from where I left off.

An example of message which I am struggling to store is:

ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_P0kScvjWGNFzMqzaDjpRsyw', function=Function(arguments='{"message":"My input message"}', name='my_tool_name'), type='function')])

Should I create a specific class to serialize and deserialize this type of messages?

I am not using assistants (which I guess autonomously handle this problems with threads) and I would like not to use them, if possible.