adrianpierce commited on
Commit
1481d5a
1 Parent(s): ae16adf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -18
app.py CHANGED
@@ -48,24 +48,25 @@ user_inputs = {
48
 
49
 
50
  def generate_recipe(user_inputs):
51
- context = """Provide me a recipe based on the user input.
52
- Output this in a valid JSON object with the following properties:
53
- recipe_name (string): the name of the recipe
54
- recipe_serving_size (string): the serving size of the recipe (example: "4 people")
55
- recipe_time (string): the amount of time required to make the recipe (example: "60 minutes (Preparation: 20 minutes, Baking: 40 minutes)")
56
- recipe_ingredients (string): python list of ingredients required to make the recipe
57
- recipe_instructions (string): python list of instructions to make the recipe
58
- """
59
- messages = [
60
- {"role": "system", "content": context},
61
- {"role": "user", "content": str(user_inputs)}
62
- ]
63
-
64
- st.session_state.gpt_response = openai.ChatCompletion.create(
65
- model="gpt-3.5-turbo",
66
- messages=messages,
67
- temperature=0.5
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))