mirror of
				https://github.com/hwchase17/langchain.git
				synced 2025-10-30 23:29:54 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			591 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			591 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| ```python
 | |
| from langchain.prompts.chat import ChatPromptTemplate
 | |
| 
 | |
| template = "You are a helpful assistant that translates {input_language} to {output_language}."
 | |
| human_template = "{text}"
 | |
| 
 | |
| chat_prompt = ChatPromptTemplate.from_messages([
 | |
|     ("system", template),
 | |
|     ("human", human_template),
 | |
| ])
 | |
| 
 | |
| chat_prompt.format_messages(input_language="English", output_language="French", text="I love programming.")
 | |
| ```
 | |
| 
 | |
| ```pycon
 | |
| [
 | |
|     SystemMessage(content="You are a helpful assistant that translates English to French.", additional_kwargs={}),
 | |
|     HumanMessage(content="I love programming.")
 | |
| ]
 | |
| ```
 |