The prompt to chat models is a list of chat messages. Each chat message is associated…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
The prompt to chat models is a list of chat messages.
Each chat message is associated with content, and an additional parameter called role. For example, in the OpenAI Chat Completions API, a chat message can be associated with an AI assistant, a human or a system role.
Create a chat prompt template like this:
from langchain.prompts import ChatPromptTemplate
chat_template = ChatPromptTemplate.from_messages( [ ("system", "You are a helpful AI bot. Your name is {name}."), ("human", "Hello, how are you doing?"), ("ai", "I'm doing well, thanks!"), ("human", "{user_input}"), ] )
messages = chat_template.format_messages(name="Bob", user_input="What is your name?")
- Assistant
from langchain.prompts import ChatPromptTemplate
chat_template = ChatPromptTemplate.from_messages( [ ("system", "You are a helpful AI bot. Your name is {name}."), ("human", "Hello, how are you doing?"), ("ai", "I'm doing well, thanks!"), ("human", "{user_input}"), ] )
messages = chat_template.format_messages(name="Bob", user_input="What is your name?")