Repository: LAION-AI/Open-Assistant
File: inference/server/export.py (Python)

Code before:
        type=parse_date,
        help="Only export chats created on or after this date. Format: YYYY-MM-DD",
    )
    parser.add_argument(
        "--to-date",
        type=parse_date,
        help="Only export chats created on or before this date. Format: YYYY-MM-DD",
    )
    parser.add_argument(
        "--user-id",
        type=str,
        help="Only export chats created by this user.",
    )
    parser.add_argument(
        "--chat-id",
        type=str,
        help="Only export this chat.",
    )
    parser.add_argument(
        "--nonzero-assistant-score",
        action=argparse.BooleanOptionalAction,
        help="Only export chats with at least one assistant message with score != 0.",
    ),
    parser.add_argument(
        "--reported",
        action=argparse.BooleanOptionalAction,
        help="Only export chats with at least one reported message.",
    )
    return parser.parse_args()


def create_filters(args: argparse.Namespace) -> list[Any]:
    filters = []

    if args.from_date:
        filters.append(DbChat.created_at >= args.from_date)
    if args.to_date:
        filters.append(DbChat.created_at <= args.to_date)
    if args.user_id:
        filters.append(DbChat.user_id == args.user_id)
    if args.chat_id:
        filters.append(DbChat.id == args.chat_id)
    if args.nonzero_assistant_score:
        filters.append(DbChat.messages.any((DbMessage.role == "assistant") & (DbMessage.score != 0)))
    if args.reported:
        filters.append(DbChat.messages.any(DbMessage.reports.any()))

    return filters


def main():

Review comment (suggestion):
Could we use `action="store_true"` for these filters? Would just keep it consistent with other boolean args for this and other scripts

Code after:
        type=parse_date,
        help="Only export chats created on or after this date. Format: YYYY-MM-DD",
    )
    parser.add_argument(
        "--to-date",
        type=parse_date,
        help="Only export chats created on or before this date. Format: YYYY-MM-DD",
    )
    parser.add_argument(
        "--user-id",
        type=str,
        help="Only export chats created by this user.",
    )
    parser.add_argument(
        "--chat-id",
        type=str,
        help="Only export this chat.",
    )
    parser.add_argument(
        "--scored",
        action="store_true",
        help="Only export chats with at least one assistant message with score != 0.",
    ),
    parser.add_argument(
        "--reported",
        action="store_true",
        help="Only export chats with at least one reported message.",
    )
    return parser.parse_args()


def create_filters(args: argparse.Namespace) -> list[Any]:
    filters = []

    if args.from_date:
        filters.append(DbChat.created_at >= args.from_date)
    if args.to_date:
        filters.append(DbChat.created_at <= args.to_date)
    if args.user_id:
        filters.append(DbChat.user_id == args.user_id)
    if args.chat_id:
        filters.append(DbChat.id == args.chat_id)
    if args.scored:
        filters.append(DbChat.messages.any((DbMessage.role == "assistant") & (DbMessage.score != 0)))
    if args.reported:
        filters.append(DbChat.messages.any(DbMessage.reports.any()))

    return filters


def main():