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 | |
import openai | |
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. | |
The AI generates a simple concise keyword query for a vegan recipe, based on the ingredients, allergies, and other preferences the human has, to use in recipe APIs. | |
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 recipes. | |
Only generate keyword queries as other tools should be used to fetch full recipes.""" | |
), | |
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( | |
"""Generate a vegan recipe keyword query that is aligned with the user's allergies and contains at least a few of the ingredients provided (if any). | |
Draw some inspiration from the user's preferences delimited below if any are specified. | |
### | |
Preferences: {recipe_freeform_input} | |
###""" | |
), | |
] | |
) | |