code: def get_response(
      instruction,
      gen_kwargs,
      verbose=False,
      chunk_response=True,
      stream_output=False,
  ):
      import ast
  
      kwargs = dict(instruction=instruction)
      if os.getenv("GRADIO_H2OGPT_H2OGPT_KEY"):
          kwargs.update(
              dict(h2ogpt_key=os.getenv("GRADIO_H2OGPT_H2OGPT_KEY"))
          )
      # max_tokens=16 for text completion by default
      gen_kwargs["max_new_tokens"] = gen_kwargs.pop(
          "max_new_tokens", gen_kwargs.pop("max_tokens", 256)
      )
      gen_kwargs["visible_models"] = gen_kwargs.pop(
          "visible_models", gen_kwargs.pop("model", 0)
      )
      # be more like OpenAI, only temperature, not do_sample, to control
      gen_kwargs["temperature"] = gen_kwargs.pop(
          "temperature", 0.0
      )  # unlike OpenAI, default to not random
      # https://platform.openai.com/docs/api-reference/chat/create
      if gen_kwargs["temperature"] > 0.0:
          # let temperature control sampling
          gen_kwargs["do_sample"] = True
      elif gen_kwargs["top_p"] != 1.0:
          # let top_p control sampling
          gen_kwargs["do_sample"] = True
          if (
              gen_kwargs.get("top_k") == 1
              and gen_kwargs.get("temperature") == 0.0
          ):
              logger.warning(
                  "Sampling with top_k=1 has no effect if top_k=1 and temperature=0"
              )
      else:
          # no sampling, make consistent
          gen_kwargs["top_p"] = 1.0
          gen_kwargs["top_k"] = 1
  
      kwargs.update(**gen_kwargs)
  
      # concurrent gradio client
      client = get_client()
  
      if stream_output:
          job = client.submit(
              str(dict(kwargs)), api_name="/submit_nochat_api"
          )
          job_outputs_num = 0
          last_response = ""
          while not job.done():
              outputs_list = job.communicator.job.outputs
              job_outputs_num_new = len(outputs_list[job_outputs_num:])
              for num in range(job_outputs_num_new):
                  res = outputs_list[job_outputs_num + num]
                  res = ast.literal_eval(res)
                  if verbose:
                      logger.info(
                          "Stream %d: %s\n\n %s\n\n"
                          % (num, res["response"], res)
                      )
                  else:
                      logger.info("Stream %d" % (job_outputs_num + num))
                  response = res["response"]
                  chunk = response[len(last_response) :]
                  if chunk_response:
                      if chunk:
                          yield chunk
                  else:
                      yield response
                  last_response = response
              job_outputs_num += job_outputs_num_new
              time.sleep(0.01)
  
          outputs_list = job.outputs()
          job_outputs_num_new = len(outputs_list[job_outputs_num:])
          res = {}
          for num in range(job_outputs_num_new):
              res = outputs_list[job_outputs_num + num]
              res = ast.literal_eval(res)
              if verbose:
                  logger.info(
                      "Final Stream %d: %s\n\n%s\n\n"
                      % (num, res["response"], res)
                  )
              else:
                  logger.info(
                      "Final Stream %d" % (job_outputs_num + num)
                  )
              response = res["response"]
              chunk = response[len(last_response) :]
              if chunk_response:
                  if chunk:
                      yield chunk
              else:
                  yield response
              last_response = response
          job_outputs_num += job_outputs_num_new
          logger.info("total job_outputs_num=%d" % job_outputs_num)
      else:
          res = client.predict(
              str(dict(kwargs)), api_name="/submit_nochat_api"
          )
          res = ast.literal_eval(res)
          yield res["response"]
  
imports: import ast
  import os
  import time
  import uuid
  from collections import deque
  from log import logger
label_desc: Use image node_id 6 for calling a global function with example usage: get_response(instruction, gen_kwargs, verbose, chunk_response, stream_output) without return types