Spaces:
Running
Running
adrianpierce
commited on
Commit
•
8fec388
1
Parent(s):
e2b0ddc
Update app.py
Browse files
app.py
CHANGED
@@ -69,24 +69,24 @@ user_inputs = {
|
|
69 |
|
70 |
|
71 |
def generate_recipe(user_inputs):
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
|
92 |
st.button(label='Submit', on_click=generate_recipe, kwargs=dict(user_inputs=user_inputs))
|
|
|
69 |
|
70 |
|
71 |
def generate_recipe(user_inputs):
|
72 |
+
with st.spinner('Building the perfect recipe for you...'):
|
73 |
+
context = """You are an expert chef assistant that can make a wide variety of recipes based on user input.
|
74 |
+
Output a recipe in a valid JSON object with the following properties:
|
75 |
+
recipe_name (string): provide a name for the generated recipe
|
76 |
+
recipe_serving_size (string): the serving size of the recipe (example: "4 people")
|
77 |
+
recipe_time (string): the amount of time required to make the recipe (example: "60 minutes (Preparation: 20 minutes, Baking: 40 minutes)")
|
78 |
+
recipe_ingredients (string): python list of ingredients required to make the recipe
|
79 |
+
recipe_instructions (string): python list of instructions to make the recipe
|
80 |
+
"""
|
81 |
+
messages = [
|
82 |
+
{"role": "system", "content": context},
|
83 |
+
{"role": "user", "content": f'user_input={str(user_inputs)}'}
|
84 |
+
]
|
85 |
+
st.session_state.gpt_response = openai.ChatCompletion.create(
|
86 |
+
model="gpt-3.5-turbo",
|
87 |
+
messages=messages,
|
88 |
+
temperature=0.25
|
89 |
+
)
|
90 |
|
91 |
|
92 |
st.button(label='Submit', on_click=generate_recipe, kwargs=dict(user_inputs=user_inputs))
|