Spaces:
Sleeping
Sleeping
OmPrakashSingh1704
commited on
Commit
•
c3deab7
1
Parent(s):
70a6a1f
Update app.py
Browse files
app.py
CHANGED
@@ -116,88 +116,88 @@ def cooking():
|
|
116 |
st.session_state.exclusions = None
|
117 |
|
118 |
def create_detailed_prompt(user_direction, exclusions, serving_size, difficulty):
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
141 |
|
142 |
def generate_recipe(user_inputs):
|
143 |
with spinner('Building the perfect recipe...'):
|
144 |
prompt = create_detailed_prompt(user_inputs['user_direction'], user_inputs['exclusions'],
|
145 |
user_inputs['serving_size'], user_inputs['difficulty'])
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
}
|
171 |
}
|
172 |
}
|
173 |
-
}
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
}
|
188 |
}
|
189 |
}
|
190 |
-
}
|
191 |
-
"required": [
|
192 |
-
"name",
|
193 |
-
"description",
|
194 |
-
"ingredients",
|
195 |
-
"instructions"
|
196 |
-
],
|
197 |
},
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
]
|
200 |
-
|
201 |
generate_kwargs = dict(
|
202 |
temperature=0.9,
|
203 |
max_new_tokens=10000,
|
@@ -237,16 +237,16 @@ def cooking():
|
|
237 |
)
|
238 |
|
239 |
difficulty_dictionary = {
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
248 |
}
|
249 |
-
}
|
250 |
|
251 |
st.session_state.selected_difficulty = st.radio(
|
252 |
"Choose a difficulty level for your recipe.",
|
@@ -263,7 +263,7 @@ def cooking():
|
|
263 |
index=list(difficulty_dictionary).index(st.session_state.selected_difficulty)
|
264 |
)
|
265 |
|
266 |
-
st.session_state.exclusions =
|
267 |
"Any ingredients you want to exclude?",
|
268 |
value=st.session_state.exclusions,
|
269 |
placeholder="gluten, dairy, nuts, cilantro",
|
|
|
116 |
st.session_state.exclusions = None
|
117 |
|
118 |
def create_detailed_prompt(user_direction, exclusions, serving_size, difficulty):
|
119 |
+
if difficulty == "Quick & Easy":
|
120 |
+
prompt = (
|
121 |
+
f"Provide a 'Quick and Easy' recipe for {user_direction} that excludes {exclusions} and has a serving size of {serving_size}. "
|
122 |
+
f"It should require as few ingredients as possible and should be ready in as little time as possible. "
|
123 |
+
f"The steps should be simple, and the ingredients should be commonly found in a household pantry. "
|
124 |
+
f"Provide a detailed ingredient list and step-by-step guide that explains the instructions to prepare in detail."
|
125 |
+
)
|
126 |
+
elif difficulty == "Intermediate":
|
127 |
+
prompt = (
|
128 |
+
f"Provide a classic recipe for {user_direction} that excludes {exclusions} and has a serving size of {serving_size}. "
|
129 |
+
f"The recipe should offer a bit of a cooking challenge but should not require professional skills. "
|
130 |
+
f"The recipe should feature traditional ingredients and techniques that are authentic to its cuisine. "
|
131 |
+
f"Provide a detailed ingredient list and step-by-step guide that explains the instructions to prepare in detail."
|
132 |
+
)
|
133 |
+
elif difficulty == "Professional":
|
134 |
+
prompt = (
|
135 |
+
f"Provide a advanced recipe for {user_direction} that excludes {exclusions} and has a serving size of {serving_size}. "
|
136 |
+
f"The recipe should push the boundaries of culinary arts, integrating unique ingredients, advanced cooking techniques, and innovative presentations. "
|
137 |
+
f"The recipe should be able to be served at a high-end restaurant or would impress at a gourmet food competition. "
|
138 |
+
f"Provide a detailed ingredient list and step-by-step guide that explains the instructions to prepare in detail."
|
139 |
+
)
|
140 |
+
return prompt
|
141 |
+
|
142 |
|
143 |
def generate_recipe(user_inputs):
|
144 |
with spinner('Building the perfect recipe...'):
|
145 |
prompt = create_detailed_prompt(user_inputs['user_direction'], user_inputs['exclusions'],
|
146 |
user_inputs['serving_size'], user_inputs['difficulty'])
|
147 |
|
148 |
+
functions = [
|
149 |
+
{
|
150 |
+
"name": "provide_recipe",
|
151 |
+
"description": "Provides a detailed recipe strictly adhering to the user input/specifications, especially ingredient exclusions and the recipe difficulty",
|
152 |
+
"parameters": {
|
153 |
+
"type": "object",
|
154 |
+
"properties": {
|
155 |
+
"name": {
|
156 |
+
"type": "string",
|
157 |
+
"description": "A creative name for the recipe"
|
158 |
+
},
|
159 |
+
"description": {
|
160 |
+
"type": "string",
|
161 |
+
"description": "a brief one-sentence description of the provided recipe"
|
162 |
+
},
|
163 |
+
"ingredients": {
|
164 |
+
"type": "array",
|
165 |
+
"items": {
|
166 |
+
"type": "object",
|
167 |
+
"properties": {
|
168 |
+
"name": {
|
169 |
+
"type": "string",
|
170 |
+
"description": "Quantity and name of the ingredient"
|
|
|
171 |
}
|
172 |
}
|
173 |
+
}
|
174 |
+
},
|
175 |
+
"instructions": {
|
176 |
+
"type": "array",
|
177 |
+
"items": {
|
178 |
+
"type": "object",
|
179 |
+
"properties": {
|
180 |
+
"step_number": {
|
181 |
+
"type": "number",
|
182 |
+
"description": "The sequence number of this step"
|
183 |
+
},
|
184 |
+
"instruction": {
|
185 |
+
"type": "string",
|
186 |
+
"description": "Detailed description of what to do in this step"
|
187 |
}
|
188 |
}
|
189 |
}
|
190 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
},
|
192 |
+
"required": [
|
193 |
+
"name",
|
194 |
+
"description",
|
195 |
+
"ingredients",
|
196 |
+
"instructions"
|
197 |
+
],
|
198 |
+
},
|
199 |
+
}
|
200 |
]
|
|
|
201 |
generate_kwargs = dict(
|
202 |
temperature=0.9,
|
203 |
max_new_tokens=10000,
|
|
|
237 |
)
|
238 |
|
239 |
difficulty_dictionary = {
|
240 |
+
"Quick & Easy": {
|
241 |
+
"description": "Easy recipes with straightforward instructions. Ideal for beginners or those seeking quick and simple cooking.",
|
242 |
+
},
|
243 |
+
"Intermediate": {
|
244 |
+
"description": "Recipes with some intricate steps that invite a little challenge. Perfect for regular cooks wanting to expand their repertoire with new ingredients and techniques.",
|
245 |
+
},
|
246 |
+
"Professional": {
|
247 |
+
"description": "Complex recipes that demand a high level of skill and precision. Suited for seasoned cooks aspiring to professional-level sophistication and creativity.",
|
248 |
+
}
|
249 |
}
|
|
|
250 |
|
251 |
st.session_state.selected_difficulty = st.radio(
|
252 |
"Choose a difficulty level for your recipe.",
|
|
|
263 |
index=list(difficulty_dictionary).index(st.session_state.selected_difficulty)
|
264 |
)
|
265 |
|
266 |
+
st.session_state.exclusions = text_area(
|
267 |
"Any ingredients you want to exclude?",
|
268 |
value=st.session_state.exclusions,
|
269 |
placeholder="gluten, dairy, nuts, cilantro",
|