Use a Message when there is no variables to be formatted, use a MessageTemplate when there are variables to be formatted. You can also use just a string (note: this will automatically get inferred as a HumanMessagePromptTemplate.)new_prompt = (    prompt    + HumanMessage(content="hi")    + AIMessage(content="what?")    + "{input}")Under the hood, this creates an instance of the ChatPromptTemplate class, so you can use it just as you did before!new_prompt.format_messages(input="i said hi")    [SystemMessage(content='You are a nice pirate', additional_kwargs={}),     HumanMessage(content='hi', additional_kwargs={}, example=False),     AIMessage(content='what?', additional_kwargs={}, example=False),     HumanMessage(content='i said hi', additional_kwargs={}, example=False)]You can also use it in an LLMChain, just like before.from langchain.chat_models import ChatOpenAIfrom langchain.chains import LLMChainmodel = ChatOpenAI()chain = LLMChain(llm=model, prompt=new_prompt)chain.run("i said hi")    'Oh, hello! How can I assist you today?'PreviousSerializationNextValidate templateString prompt pipeliningChat prompt pipeliningCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
The idea behind prompt pipelining is to provide a user friendly interface for composing different parts of prompts together. You can do this with either string prompts or chat prompts. Constructing prompts this way allows for easy reuse of components.
The idea behind prompt pipelining is to provide a user friendly interface for composing different parts of prompts together. You can do this with either string prompts or chat prompts. Constructing prompts this way allows for easy reuse of components. ->: Use a Message when there is no variables to be formatted, use a MessageTemplate when there are variables to be formatted. You can also use just a string (note: this will automatically get inferred as a HumanMessagePromptTemplate.)new_prompt = (    prompt    + HumanMessage(content="hi")    + AIMessage(content="what?")    + "{input}")Under the hood, this creates an instance of the ChatPromptTemplate class, so you can use it just as you did before!new_prompt.format_messages(input="i said hi")    [SystemMessage(content='You are a nice pirate', additional_kwargs={}),     HumanMessage(content='hi', additional_kwargs={}, example=False),     AIMessage(content='what?', additional_kwargs={}, example=False),     HumanMessage(content='i said hi', additional_kwargs={}, example=False)]You can also use it in an LLMChain, just like before.from langchain.chat_models import ChatOpenAIfrom langchain.chains import LLMChainmodel = ChatOpenAI()chain = LLMChain(llm=model, prompt=new_prompt)chain.run("i said hi")    'Oh, hello! How can I assist you today?'PreviousSerializationNextValidate templateString prompt pipeliningChat prompt pipeliningCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.