code: def create_gallery(
      session: Session, dbmanager: DBManager, tags: List[str] = []
  ) -> Gallery:
      """
      Publish a session to the gallery table in the database. Fetches the session messages first, then saves session and messages object to the gallery database table.
      :param session: The Session object containing session data
      :param dbmanager: The DBManager instance used to interact with the database
      :param tags: A list of tags to associate with the session
      :return: A gallery object containing the session and messages objects
      """
  
      messages = get_messages(
          user_id=session.user_id,
          session_id=session.id,
          dbmanager=dbmanager,
      )
      gallery_item = Gallery(
          session=session, messages=messages, tags=tags
      )
      query = "INSERT INTO gallery (id, session, messages, tags, timestamp) VALUES (?, ?, ?, ?,?)"
      args = (
          gallery_item.id,
          json.dumps(gallery_item.session.dict()),
          json.dumps(
              [message.dict() for message in gallery_item.messages]
          ),
          json.dumps(gallery_item.tags),
          gallery_item.timestamp,
      )
      dbmanager.query(query=query, args=args)
      return gallery_item
  
imports: import json
  import logging
  import sqlite3
  import threading
  import os
  from typing import Any, List, Dict, Optional, Tuple
  from ..datamodel import AgentFlowSpec, AgentWorkFlowConfig, Gallery, Message, Session, Skill
label_desc: Use image node_id 6 for calling a global function with example usage: create_gallery(session, dbmanager, tags) and returns: gallery_item