code: def http_bot(
      state,
      model_selector,
      temperature,
      top_p,
      max_new_tokens,
      request: gr.Request,
  ):
      # logger.info(f"http_bot. ip: {request.client.host}")
      start_tstamp = time.time()
      model_name = model_selector
  
      if state.skip_next:
          # This generate call is skipped due to invalid inputs
          yield (state, state.to_gradio_chatbot()) + (
              no_change_btn,
          ) * 5
          return
  
      if len(state.messages) == state.offset + 2:
          # First round of conversation
          template_name = "llava_llama_2"
          new_state = conv_templates[template_name].copy()
          new_state.append_message(
              new_state.roles[0], state.messages[-2][1]
          )
          new_state.append_message(new_state.roles[1], None)
          state = new_state
  
      prompt = state.get_prompt()
  
      images = state.get_images(return_pil=True)
      image_tensors = [
          image_processor.preprocess(image, return_tensors="pt")[
              "pixel_values"
          ]
          .half()
          .cuda()
          for image in images
      ]
      if len(image_tensors) == 0:
          image_tensor = None
      elif len(image_tensors) == 1:
          image_tensor = image_tensors[0]
      else:
          image_tensor = image_tensors
  
      input_ids = (
          tokenizer_image_token(
              prompt, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt"
          )
          .unsqueeze(0)
          .cuda()
      )
      stop_str = (
          state.sep
          if state.sep_style != SeparatorStyle.TWO
          else state.sep2
      )
      keywords = [stop_str]
      stopping_criteria = KeywordsStoppingCriteria(
          keywords, tokenizer, input_ids
      )
  
      with torch.inference_mode():
          output_ids = model.generate(
              input_ids,
              images=image_tensor,
              do_sample=True,
              temperature=float(temperature),
              max_new_tokens=min(int(max_new_tokens), 1536),
              use_cache=True,
              stopping_criteria=[stopping_criteria],
          )
      outputs = tokenizer.decode(
          output_ids[0, input_ids.shape[1] : -1]
      ).strip()
      state.messages[-1][-1] = outputs
  
      tp = state.to_gradio_chatbot()
      for tpp in tp:
          if tpp[-1] is None:
              continue
          tpp[-1] = tpp[-1].replace("\n\n", "\n")
          if "<gen_image>" in tpp[-1] and "</gen_image>" in tpp[-1]:
              tpp[-1] = "The generation is finished: \n\n" + tpp[-1]
  
      yield (state, tp) + (enable_btn,) * 3
  
imports: import argparse
  import datetime
  import json
  import os
  import time
  import gradio
  import requests
  from llmga.llava.conversation import default_conversation, conv_templates, SeparatorStyle
  from llmga.llava.constants import LOGDIR
  from llmga.llava.utils import build_logger, server_error_msg, violates_moderation, moderation_msg
  from llmga.llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN
  from llmga.llava.conversation import conv_templates, SeparatorStyle
  from llmga.llava.model.builder import load_pretrained_model
  from llmga.llava.utils import disable_torch_init
  from llmga.llava.mm_utils import tokenizer_image_token, get_model_name_from_path, KeywordsStoppingCriteria
  import hashlib
  import torch
  from llmga.diffusers.pipeline_stable_diffusion_xl_lpw import StableDiffusionXLPipeline
  import copy
label_desc: Use image node_id 6 for calling a global function with example usage: http_bot(state, model_selector, temperature, top_p, max_new_tokens, request) without return types