code: def test_hf_inference_server(
      base_model,
      force_langchain_evaluate,
      do_langchain,
      pass_prompt_type,
      do_model_lock,
      prompt="Who are you?",
      stream_output=False,
      max_new_tokens=256,
      langchain_mode="Disabled",
      langchain_action=LangChainAction.QUERY.value,
      langchain_agents=[],
      user_path=None,
      langchain_modes=["UserData", "MyData", "LLM", "Disabled"],
      docs_ordering_type="reverse_sort",
  ):
      # HF inference server
      gradio_port = get_inf_port()
      inf_port = gradio_port + 1
      inference_server = "http://127.0.0.1:%s" % inf_port
      docker_hash = run_docker(
          inf_port, base_model, low_mem_mode=True, do_shared=False
      )
  
      if force_langchain_evaluate:
          langchain_mode = "MyData"
      if do_langchain:
          langchain_mode = "UserData"
          from tests.utils import make_user_path_test
  
          user_path = make_user_path_test()
          # from src.gpt_langchain import get_some_dbs_from_hf
          # get_some_dbs_from_hf()
  
      if base_model in [
          "h2oai/h2ogpt-oig-oasst1-512-6_9b",
          "h2oai/h2ogpt-oasst1-512-12b",
      ]:
          prompt_type = PromptType.human_bot.name
      else:
          prompt_type = PromptType.prompt_answer.name
      if isinstance(pass_prompt_type, str):
          prompt_type = "custom"
          prompt_dict = """{'promptA': None, 'promptB': None, 'PreInstruct': None, 'PreInput': None, 'PreResponse': None, 'terminate_response': [], 'chat_sep': '', 'chat_turn_sep': '', 'humanstr': None, 'botstr': None, 'generates_leading_space': False}"""
      else:
          prompt_dict = None
          if not pass_prompt_type:
              prompt_type = None
      if do_model_lock:
          model_lock = [
              {
                  "inference_server": inference_server,
                  "base_model": base_model,
              }
          ]
          base_model = None
          inference_server = None
      else:
          model_lock = None
      main_kwargs = dict(
          base_model=base_model,
          prompt_type=prompt_type,
          prompt_dict=prompt_dict,
          chat=True,
          system_prompt="",
          stream_output=stream_output,
          gradio=True,
          num_beams=1,
          block_gradio_exit=False,
          max_new_tokens=max_new_tokens,
          langchain_mode=langchain_mode,
          langchain_action=langchain_action,
          langchain_agents=langchain_agents,
          user_path=user_path,
          langchain_modes=langchain_modes,
          docs_ordering_type=docs_ordering_type,
          force_langchain_evaluate=force_langchain_evaluate,
          inference_server=inference_server,
          model_lock=model_lock,
      )
  
      try:
          # server that consumes inference server
          from src.gen import main
  
          main(**main_kwargs)
  
          # client test to server that only consumes inference server
          from src.client_test import run_client_chat
  
          res_dict, client = run_client_chat(
              prompt=prompt,
              prompt_type=prompt_type,
              stream_output=stream_output,
              max_new_tokens=max_new_tokens,
              langchain_mode=langchain_mode,
              langchain_action=langchain_action,
              langchain_agents=langchain_agents,
              prompt_dict=prompt_dict,
          )
          assert res_dict["prompt"] == prompt
          assert res_dict["iinput"] == ""
  
          # will use HOST from above
          ret1, ret2, ret3, ret4, ret5, ret6, ret7 = run_client_many(
              prompt_type=None
          )  # client shouldn't have to specify
          # here docker started with falcon before personalization
  
          if isinstance(pass_prompt_type, str):
              assert (
                  "year old student from the" in ret1["response"]
                  or "I am a person who is asking you a question"
                  in ret1["response"]
                  or "year old" in ret1["response"]
              )
              assert "bird" in ret2["response"]
              assert "bird" in ret3["response"]
              assert (
                  "year old student from the" in ret4["response"]
                  or "I am a person who is asking you a question"
                  in ret4["response"]
                  or "year old" in ret4["response"]
              )
              assert (
                  "year old student from the" in ret5["response"]
                  or "I am a person who is asking you a question"
                  in ret5["response"]
                  or "year old" in ret5["response"]
              )
              assert (
                  "year old student from the" in ret6["response"]
                  or "I am a person who is asking you a question"
                  in ret6["response"]
                  or "year old" in ret6["response"]
              )
              assert (
                  "year old student from the" in ret7["response"]
                  or "I am a person who is asking you a question"
                  in ret7["response"]
                  or "year old" in ret7["response"]
              )
          elif base_model == "h2oai/h2ogpt-oig-oasst1-512-6_9b":
              assert "h2oGPT" in ret1["response"]
              assert "Birds" in ret2["response"]
              assert "Birds" in ret3["response"]
              assert "h2oGPT" in ret4["response"]
              assert "h2oGPT" in ret5["response"]
              assert "h2oGPT" in ret6["response"]
              assert "h2oGPT" in ret7["response"]
          else:
              assert (
                  "I am a language model trained" in ret1["response"]
                  or "I am a helpful assistant" in ret1["response"]
                  or "a chat-based assistant" in ret1["response"]
                  or "am a student" in ret1["response"]
                  or "I am an AI language model" in ret1["response"]
              )
              assert "Once upon a time" in ret2["response"]
              assert "Once upon a time" in ret3["response"]
              assert (
                  "I am a language model trained" in ret4["response"]
                  or "I am a helpful assistant" in ret4["response"]
                  or "a chat-based assistant" in ret4["response"]
                  or "am a student" in ret4["response"]
                  or "I am an AI language model" in ret4["response"]
              )
              assert (
                  "I am a language model trained" in ret5["response"]
                  or "I am a helpful assistant" in ret5["response"]
                  or "a chat-based assistant" in ret5["response"]
                  or "am a student" in ret5["response"]
                  or "I am an AI language model" in ret5["response"]
              )
              assert (
                  "I am a language model trained" in ret6["response"]
                  or "I am a helpful assistant" in ret6["response"]
                  or "a chat-based assistant" in ret6["response"]
                  or "am a student" in ret6["response"]
                  or "I am an AI language model" in ret6["response"]
              )
              assert (
                  "I am a language model trained" in ret7["response"]
                  or "I am a helpful assistant" in ret7["response"]
                  or "a chat-based assistant" in ret7["response"]
                  or "am a student" in ret7["response"]
                  or "I am an AI language model" in ret7["response"]
              )
          print("DONE", flush=True)
      finally:
          os.system("docker stop %s" % docker_hash)
  
imports: import os
  import subprocess
  import time
  from datetime import datetime
  import pytest
  from src.utils import get_ngpus_vis, makedirs
  from tests.utils import wrap_test_forked, get_inf_port, get_inf_server
  from tests.test_langchain_units import have_openai_key, have_replicate_key
  from src.client_test import run_client_many, test_client_basic_api_lean
  from src.enums import PromptType, LangChainAction
label_desc: Use image node_id 6 for calling a global function with example usage: test_hf_inference_server(base_model, force_langchain_evaluate, do_langchain, pass_prompt_type, do_model_lock, prompt, stream_output, max_new_tokens, langchain_mode, langchain_action, langchain_agents, user_path, langchain_modes, docs_ordering_type) without return types