mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
87e502c6bc
Co-authored-by: jacoblee93 <jacoblee93@gmail.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
24 lines
806 B
Plaintext
24 lines
806 B
Plaintext
```python
|
|
from langchain.prompts.chat import (
|
|
ChatPromptTemplate,
|
|
SystemMessagePromptTemplate,
|
|
HumanMessagePromptTemplate,
|
|
)
|
|
|
|
template = "You are a helpful assistant that translates {input_language} to {output_language}."
|
|
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
|
|
human_template = "{text}"
|
|
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
|
|
|
|
chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])
|
|
|
|
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.")
|
|
]
|
|
```
|