code: def rewrite():
      if request.method == "POST":
          json_data = json.loads(request.data)
          user_id = json_data.get("user_id")
          question_captured = json_data.get("question")
          original_response = json_data.get("original_response")
          rewrite_captured = json_data.get("rewrite")
          date_format = "%m%d%Y-%H%M%S"
          date = datetime.now(tz=pytz.utc)
          date = date.astimezone(timezone("US/Pacific"))
          print(
              "["
              + date.strftime(date_format)
              + "] A user has submitted a rewrite."
          )
          print("Submitted by: " + user_id + "\n")
          print("# " + question_captured.strip() + "\n")
          print("## Original response\n")
          print(original_response.strip() + "\n")
          print("## Rewrite\n")
          print(rewrite_captured + "\n")
          filename = (
              rewrites_dir
              + "/"
              + question_captured.strip()
              .replace(" ", "-")
              .replace("?", "")
              .replace("'", "")
              .lower()
              + "-"
              + date.strftime(date_format)
              + ".md"
          )
          with open(filename, "w", encoding="utf-8") as file:
              file.write("Submitted by: " + user_id + "\n\n")
              file.write("# " + question_captured.strip() + "\n\n")
              file.write("## Original response\n\n")
              file.write(original_response.strip() + "\n\n")
              file.write("## Rewrite\n\n")
              file.write(rewrite_captured + "\n")
              file.close()
          return "OK"
      else:
          return redirect(url_for("chatui.index"))
  
imports: from flask import Blueprint, render_template, request, redirect, url_for, json
  import markdown
  import markdown.extensions.fenced_code
  from bs4 import BeautifulSoup
  import urllib
  import os
  from datetime import datetime
  from pytz import timezone
  import pytz
  import uuid
  from scripts import read_config
  from chroma import Format
  from docs_agent import DocsAgent
label_desc: Use image node_id 3 for calling a global function with example usage: rewrite() and returns: str, redirect