adrianpierce commited on
Commit
c3b38bc
·
1 Parent(s): 2363d0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -70,9 +70,10 @@ user_inputs = {
70
 
71
  def generate_recipe(user_inputs):
72
  #with st.spinner('Building the perfect recipe for you...'):
73
- context = """Provide me a recipe based on the user input.
74
  Output this in a valid JSON object with the following properties:
75
  recipe_name (string): the name of the 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
@@ -80,13 +81,13 @@ def generate_recipe(user_inputs):
80
  """
81
  messages = [
82
  {"role": "system", "content": context},
83
- {"role": "user", "content": str(user_inputs)}
84
  ]
85
  st.write(messages[1])
86
  st.session_state.gpt_response = openai.ChatCompletion.create(
87
- model="gpt-3.5-turbo",
88
  messages=messages,
89
- temperature=0.5
90
  )
91
 
92
 
@@ -96,6 +97,7 @@ if st.session_state.gpt_response is not None:
96
  st.divider()
97
  loaded_recipe = json.loads(st.session_state.gpt_response['choices'][0]['message']['content'])
98
  st.header(loaded_recipe['recipe_name'])
 
99
  st.write(f"**Serving Size: {loaded_recipe['recipe_serving_size']}**")
100
  st.write(f"**Time To Make: {loaded_recipe['recipe_time']}**")
101
  st.subheader("Ingredients:")
 
70
 
71
  def generate_recipe(user_inputs):
72
  #with st.spinner('Building the perfect recipe for you...'):
73
+ context = """Provide me a recipe based on the provided python dictionary.
74
  Output this in a valid JSON object with the following properties:
75
  recipe_name (string): the name of the recipe
76
+ recipe_description (string): brief description of the recipe, 3 sentences maximum
77
  recipe_serving_size (string): the serving size of the recipe (example: "4 people")
78
  recipe_time (string): the amount of time required to make the recipe (example: "60 minutes (Preparation: 20 minutes, Baking: 40 minutes)")
79
  recipe_ingredients (string): python list of ingredients required to make the recipe
 
81
  """
82
  messages = [
83
  {"role": "system", "content": context},
84
+ {"role": "user", "content": f'user_input={str(user_inputs)}'}
85
  ]
86
  st.write(messages[1])
87
  st.session_state.gpt_response = openai.ChatCompletion.create(
88
+ model="gpt-4",
89
  messages=messages,
90
+ temperature=0.75
91
  )
92
 
93
 
 
97
  st.divider()
98
  loaded_recipe = json.loads(st.session_state.gpt_response['choices'][0]['message']['content'])
99
  st.header(loaded_recipe['recipe_name'])
100
+ st.write(loaded_recipe['recipe_description'])
101
  st.write(f"**Serving Size: {loaded_recipe['recipe_serving_size']}**")
102
  st.write(f"**Time To Make: {loaded_recipe['recipe_time']}**")
103
  st.subheader("Ingredients:")