code: def serialize(data, format: str = 'json', pretty: bool = False):
      
      def encode(obj):
          if isinstance(obj, stellata.model.Model):
              return obj.to_dict()
          elif isinstance(obj, datetime.datetime):
              return int(obj.timestamp())
          elif isinstance(obj, datetime.date):
              return obj.isoformat()
          elif isinstance(obj, decimal.Decimal):
              return float(obj)
          elif hasattr(obj, 'serialize'):
              return obj.serialize()
  
          return obj
  
      if format == 'msgpack':
          return msgpack.packb(data, default=encode)
  
      if format == 'json':
          if pretty:
              return json.dumps(data, default=encode, indent=4)
          return json.dumps(data, default=encode)
  
      return data
docs: Serialize a stellata object to a string format.