code: def prepare_chain(args):
      model_path = args.model_path
      model_family = args.model_family
      n_threads = args.thread_num
      n_ctx = args.context_size
  
      # Use a easy prompt could bring good-enough result
      # You could tune the prompt based on your own model to perform better
      template = """
      {history}
  
      Q: {human_input}
      A:"""
      prompt = PromptTemplate(
          input_variables=["history", "human_input"], template=template
      )
  
      # We use our BigDLCausalLLM to subsititute OpenAI web-required API
      model_family_to_llm = {
          "llama": LlamaLLM,
          "gptneox": GptneoxLLM,
          "bloom": BloomLLM,
          "starcoder": StarcoderLLM,
          "chatglm": ChatGLMLLM,
      }
  
      if model_family in model_family_to_llm:
          langchain_llm = model_family_to_llm[model_family]
      else:
          raise ValueError(f"Unknown model family: {model_family}")
  
      callback_manager = CallbackManager(
          [StreamingStdOutCallbackHandler()]
      )
      llm = langchain_llm(
          model_path=model_path,
          n_threads=n_threads,
          callback_manager=callback_manager,
          verbose=True,
          n_ctx=n_ctx,
          stop=[
              "\n\n"
          ],  # You could tune the stop words based on your own model to perform better
      )
  
      # Following code are complete the same as the use-case
      voiceassitant_chain = LLMChain(
          llm=llm,
          prompt=prompt,
          verbose=True,
          memory=ConversationBufferWindowMemory(k=2),
      )
  
      return voiceassitant_chain
  
file_path: BigDL/python/llm/example/CPU/LangChain/native_int4/voiceassistant.py
imports: from langchain import LLMChain, PromptTemplate
  from bigdl.llm.langchain.llms import *
  from langchain.memory import ConversationBufferWindowMemory
  from langchain.callbacks.manager import CallbackManager
  from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
  import speech_recognition
  import pyttsx3
  import argparse
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_chain(args) and returns: voiceassitant_chain