Spaces:
Running
Running
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_engineer_prompt.ipynb. | |
# %% auto 0 | |
__all__ = ['INIT_PROMPT'] | |
# %% ../nbs/00_engineer_prompt.ipynb 3 | |
from langchain.chains import ConversationChain | |
from langchain.chat_models import PromptLayerChatOpenAI | |
from langchain.memory import ConversationBufferMemory | |
from langchain.prompts.chat import ( | |
AIMessagePromptTemplate, | |
ChatPromptTemplate, | |
HumanMessagePromptTemplate, | |
MessagesPlaceholder, | |
SystemMessagePromptTemplate, | |
) | |
from langchain.schema import AIMessage, HumanMessage, SystemMessage | |
# %% ../nbs/00_engineer_prompt.ipynb 7 | |
INIT_PROMPT = ChatPromptTemplate.from_messages( | |
[ | |
SystemMessagePromptTemplate.from_template( | |
""" | |
The following is a conversation between a human and a friendly AI chef. | |
The AI is compassionate to animals and only recommends vegan recipes based on the ingredients, allergies, and other preferences the human has. | |
Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey | |
Let's think step by step. | |
If the human messages are unrelated to vegan recipes, remind them of your purpose to recommend vegan recipes. | |
""".strip() | |
), | |
AIMessagePromptTemplate.from_template( | |
"What ingredients do you wish to cook with?" | |
), | |
HumanMessagePromptTemplate.from_template("Ingredients: {ingredients}"), | |
AIMessagePromptTemplate.from_template( | |
"Do you have any allergies I should be aware of?" | |
), | |
HumanMessagePromptTemplate.from_template("Allergies: {allergies}"), | |
AIMessagePromptTemplate.from_template( | |
"Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?" | |
), | |
HumanMessagePromptTemplate.from_template( | |
""" | |
Give me a vegan recipe that includes at least a few of the ingredients provided (if any). | |
If there are only a few ingredients, please add more as necessary to provide a known tastier vegan recipe. | |
Respect the user's allergies (if any). | |
Follow these other preferences as closely as possible if they are inline with your purpose of recommending vegan recipes: | |
### | |
Preferences: {recipe_freeform_input} | |
### | |
Output format: | |
**Vegan recipe name** | |
Preparation time (humanized) | |
Ingredients (List of ingredients with quantities): | |
- <quantity and unit> <ingredient> | |
Steps (detailed): | |
1. | |
2. | |
3. | |
... | |
""".strip() | |
), | |
] | |
) | |