|
|
@ -27,6 +27,8 @@ LangChain also provides `MessagesPlaceholder`, which gives you full control of w
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from langchain.prompts import MessagesPlaceholder
|
|
|
|
from langchain.prompts import MessagesPlaceholder
|
|
|
|
|
|
|
|
from langchain.prompts import HumanMessagePromptTemplate
|
|
|
|
|
|
|
|
from langchain.prompts import ChatPromptTemplate
|
|
|
|
|
|
|
|
|
|
|
|
human_prompt = "Summarize our conversation so far in {word_count} words."
|
|
|
|
human_prompt = "Summarize our conversation so far in {word_count} words."
|
|
|
|
human_message_template = HumanMessagePromptTemplate.from_template(human_prompt)
|
|
|
|
human_message_template = HumanMessagePromptTemplate.from_template(human_prompt)
|
|
|
@ -36,6 +38,8 @@ chat_prompt = ChatPromptTemplate.from_messages([MessagesPlaceholder(variable_nam
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
|
|
|
|
from langchain.schema.messages import HumanMessage, AIMessage
|
|
|
|
|
|
|
|
|
|
|
|
human_message = HumanMessage(content="What is the best way to learn programming?")
|
|
|
|
human_message = HumanMessage(content="What is the best way to learn programming?")
|
|
|
|
ai_message = AIMessage(content="""\
|
|
|
|
ai_message = AIMessage(content="""\
|
|
|
|
1. Choose a programming language: Decide on a programming language that you want to learn.
|
|
|
|
1. Choose a programming language: Decide on a programming language that you want to learn.
|
|
|
|