code: def test_prompt_with_context(
      prompt_type, system_prompt, chat_conversation, expected
  ):
      prompt_dict = None  # not used unless prompt_type='custom'
      langchain_mode = "Disabled"
      add_chat_history_to_context = True
      chat = True
      model_max_length = 2048
      memory_restriction_level = 0
      keep_sources_in_context = False
      iinput = ""
      stream_output = False
      debug = False
  
      from src.prompter import Prompter
      from src.gen import history_to_context
  
      t0 = time.time()
      history = [
          ["Hello!", "Hi!"],
          ["How are you?", "I'm good"],
          ["Go to the market?", None],
      ]
      print(
          "duration1: %s %s" % (prompt_type, time.time() - t0),
          flush=True,
      )
      t0 = time.time()
      context = history_to_context(
          history,
          langchain_mode=langchain_mode,
          add_chat_history_to_context=add_chat_history_to_context,
          prompt_type=prompt_type,
          prompt_dict=prompt_dict,
          model_max_length=model_max_length,
          memory_restriction_level=memory_restriction_level,
          keep_sources_in_context=keep_sources_in_context,
          system_prompt=system_prompt,
          chat_conversation=chat_conversation,
      )
      print(
          "duration2: %s %s" % (prompt_type, time.time() - t0),
          flush=True,
      )
      t0 = time.time()
      instruction = history[-1][0]
  
      # get prompt
      prompter = Prompter(
          prompt_type,
          prompt_dict,
          debug=debug,
          stream_output=stream_output,
          system_prompt=system_prompt,
      )
      # for instruction-tuned models, expect this:
      assert prompter.PreResponse
      assert prompter.PreInstruct
      assert prompter.botstr
      assert prompter.humanstr
      print(
          "duration3: %s %s" % (prompt_type, time.time() - t0),
          flush=True,
      )
      t0 = time.time()
      data_point = dict(
          context=context, instruction=instruction, input=iinput
      )
      prompt = prompter.generate_prompt(data_point)
      print(prompt)
      print(
          "duration4: %s %s" % (prompt_type, time.time() - t0),
          flush=True,
      )
      assert prompt == expected
      assert prompt.find(source_prefix) == -1
  
file_path: h2ogpt/tests/test_prompter.py
imports: import time
  import pytest
  from tests.utils import wrap_test_forked
  from src.enums import source_prefix, source_postfix
  from src.prompter import generate_prompt
label_desc: Use image node_id 6 for calling a global function with example usage: test_prompt_with_context(prompt_type, system_prompt, chat_conversation, expected) without return types