Spaces:
Sleeping
Sleeping
File size: 2,461 Bytes
adaea7c 986fa13 adaea7c 5f3a430 4edc753 adaea7c 4edc753 adaea7c 4edc753 adaea7c 4edc753 adaea7c 4edc753 1230938 986fa13 4edc753 1230938 63ae673 1230938 4edc753 29fa9df 4edc753 1230938 4edc753 1230938 4edc753 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 8
INIT_PROMPT = ChatPromptTemplate.from_messages(
[
SystemMessagePromptTemplate.from_template(
"""The following is a conversation between a human and a friendly vegan AI.
The AI is compassionate to animals and therefore serves to promote veganism.
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.
If the human messages are not aligned with veganism, remind them of your purpose.
The AI NEVER generates vegan recipes itself but instead uses a tool."""
),
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(
"""Preferences: `{recipe_freeform_input}`
Your task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.
Think step by step.
1. If the user listed any ingredients, choose the three ingredients that are most commonly go together in recipes that match the user's preferences (if any are included).
2. If the user provided any allergies, include them in the query.
Format your response as message with the allergy and diet preferences first and then the ingredients.
Examples:
'Vegan gluten-free chicken peppers' or 'Vegan Japanese tofu, brocolli, and miso'"""
),
]
)
|