Spaces:
Running
Running
adrianpierce
commited on
Commit
•
1481d5a
1
Parent(s):
ae16adf
Update app.py
Browse files
app.py
CHANGED
@@ -48,24 +48,25 @@ user_inputs = {
|
|
48 |
|
49 |
|
50 |
def generate_recipe(user_inputs):
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
69 |
|
70 |
|
71 |
st.button(label='Submit', on_click=generate_recipe, kwargs=dict(user_inputs=user_inputs))
|
|
|
48 |
|
49 |
|
50 |
def generate_recipe(user_inputs):
|
51 |
+
with st.spinner('Building the perfect recipe for you...'):
|
52 |
+
context = """Provide me a recipe based on the user input.
|
53 |
+
Output this in a valid JSON object with the following properties:
|
54 |
+
recipe_name (string): the name of the recipe
|
55 |
+
recipe_serving_size (string): the serving size of the recipe (example: "4 people")
|
56 |
+
recipe_time (string): the amount of time required to make the recipe (example: "60 minutes (Preparation: 20 minutes, Baking: 40 minutes)")
|
57 |
+
recipe_ingredients (string): python list of ingredients required to make the recipe
|
58 |
+
recipe_instructions (string): python list of instructions to make the recipe
|
59 |
+
"""
|
60 |
+
messages = [
|
61 |
+
{"role": "system", "content": context},
|
62 |
+
{"role": "user", "content": str(user_inputs)}
|
63 |
+
]
|
64 |
+
|
65 |
+
st.session_state.gpt_response = openai.ChatCompletion.create(
|
66 |
+
model="gpt-3.5-turbo",
|
67 |
+
messages=messages,
|
68 |
+
temperature=0.5
|
69 |
+
)
|
70 |
|
71 |
|
72 |
st.button(label='Submit', on_click=generate_recipe, kwargs=dict(user_inputs=user_inputs))
|