code: def run_client(
      client, prompt, args, kwargs, do_md_to_text=True, verbose=False
  ):
      if is_gradio_version4:
          kwargs["answer_with_sources"] = True
          kwargs["show_accordions"] = True
          kwargs["append_sources_to_answer"] = True
          kwargs["append_sources_to_chat"] = False
          kwargs["show_link_in_sources"] = True
          res_dict, client = run_client_gen(
              client, kwargs, do_md_to_text=do_md_to_text
          )
          res_dict["response"] += str(res_dict["sources_str"])
          return res_dict, client
          # FIXME: https://github.com/gradio-app/gradio/issues/6592
  
      assert kwargs["chat"], "Chat mode only"
      res = client.predict(*tuple(args), api_name="/instruction")
      args[-1] += [res[-1]]
  
      res_dict = kwargs
      res_dict["prompt"] = prompt
      if not kwargs["stream_output"]:
          res = client.predict(
              *tuple(args), api_name="/instruction_bot"
          )
          res_dict["response"] = res[0][-1][1]
          print(
              md_to_text(
                  res_dict["response"], do_md_to_text=do_md_to_text
              )
          )
          return res_dict, client
      else:
          job = client.submit(*tuple(args), api_name="/instruction_bot")
          res1 = ""
          while not job.done():
              outputs_list = job.communicator.job.outputs
              if outputs_list:
                  res = job.communicator.job.outputs[-1]
                  res1 = res[0][-1][-1]
                  res1 = md_to_text(res1, do_md_to_text=do_md_to_text)
                  print(res1)
              time.sleep(0.1)
          full_outputs = job.outputs()
          if verbose:
              print("job.outputs: %s" % str(full_outputs))
          # ensure get ending to avoid race
          # -1 means last response if streaming
          # 0 means get text_output, ignore exception_text
          # 0 means get list within text_output that looks like [[prompt], [answer]]
          # 1 means get bot answer, so will have last bot answer
          res_dict["response"] = md_to_text(
              full_outputs[-1][0][0][1], do_md_to_text=do_md_to_text
          )
          return res_dict, client
  
imports: import ast
  import time
  import os
  import markdown
  import pytest
  from bs4 import BeautifulSoup
  from src.utils import is_gradio_version4
  from tests.utils import get_inf_server
label_desc: Use image node_id 15 for calling a global function with example usage: run_client(client, prompt, args, kwargs, do_md_to_text, verbose) and returns: res_dict,  client, res_dict,  client, res_dict,  client