Spaces:
Running
Running
adrianpierce
commited on
Commit
•
3ee69f0
1
Parent(s):
1863ed9
Update Home.py
Browse files
Home.py
CHANGED
@@ -14,6 +14,9 @@ client = OpenAI(
|
|
14 |
if 'gpt_response' not in st.session_state:
|
15 |
st.session_state.gpt_response = None
|
16 |
|
|
|
|
|
|
|
17 |
# functions
|
18 |
def create_detailed_prompt(user_direction, exclusions, serving_size, difficulty):
|
19 |
if difficulty == "Quick & Easy":
|
@@ -104,6 +107,7 @@ def generate_recipe(user_inputs):
|
|
104 |
functions=functions,
|
105 |
function_call={"name":"provide_recipe"}, # auto is default, but we'll be explicit
|
106 |
)
|
|
|
107 |
|
108 |
def create_safe_filename(recipe_name):
|
109 |
# format and generate random URL-safe text string
|
@@ -119,6 +123,7 @@ def save_recipe():
|
|
119 |
filename = create_safe_filename(recipe["name"])
|
120 |
with open(f'/data/{filename}.json', 'w') as f:
|
121 |
json.dump(recipe, f, indent=4)
|
|
|
122 |
|
123 |
# app
|
124 |
st.title("Let's get cooking")
|
@@ -198,4 +203,10 @@ if st.session_state.gpt_response is not None:
|
|
198 |
recipe_md += f"{instruction['step_number']}. {instruction['instruction']} \n"
|
199 |
recipe['md'] = recipe_md
|
200 |
st.markdown(recipe_md)
|
201 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
if 'gpt_response' not in st.session_state:
|
15 |
st.session_state.gpt_response = None
|
16 |
|
17 |
+
if 'recipe_saved' not in st.session_state:
|
18 |
+
st.session_state.recipe_saved = None
|
19 |
+
|
20 |
# functions
|
21 |
def create_detailed_prompt(user_direction, exclusions, serving_size, difficulty):
|
22 |
if difficulty == "Quick & Easy":
|
|
|
107 |
functions=functions,
|
108 |
function_call={"name":"provide_recipe"}, # auto is default, but we'll be explicit
|
109 |
)
|
110 |
+
st.session_state.recipe_saved = False
|
111 |
|
112 |
def create_safe_filename(recipe_name):
|
113 |
# format and generate random URL-safe text string
|
|
|
123 |
filename = create_safe_filename(recipe["name"])
|
124 |
with open(f'/data/{filename}.json', 'w') as f:
|
125 |
json.dump(recipe, f, indent=4)
|
126 |
+
st.session_state.recipe_saved = True
|
127 |
|
128 |
# app
|
129 |
st.title("Let's get cooking")
|
|
|
203 |
recipe_md += f"{instruction['step_number']}. {instruction['instruction']} \n"
|
204 |
recipe['md'] = recipe_md
|
205 |
st.markdown(recipe_md)
|
206 |
+
st.write("")
|
207 |
+
if st.session_state.recipe_saved == True:
|
208 |
+
disable_button = True
|
209 |
+
else:
|
210 |
+
disable_button = False
|
211 |
+
if st.button("Save Recipe", on_click=save_recipe, disabled=disable_button):
|
212 |
+
st.write("Recipe Saved!")
|