Spaces:
Runtime error
Runtime error
Sander Land
commited on
Commit
•
39495a2
1
Parent(s):
1700c40
spinner
Browse files
app.py
CHANGED
@@ -47,20 +47,21 @@ with st.form("form"):
|
|
47 |
submitted = st.form_submit_button(label="Generate Recipe!")
|
48 |
|
49 |
if submitted:
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
64 |
|
65 |
# Draw chat history.
|
66 |
with st.expander("About", expanded=False):
|
|
|
47 |
submitted = st.form_submit_button(label="Generate Recipe!")
|
48 |
|
49 |
if submitted:
|
50 |
+
with st.spinner("Cooking up something delicious ... please wait a few seconds ... "):
|
51 |
+
dish = (dish or DEFAULT_DISH).strip()
|
52 |
+
co = cohere.Client(api_key=os.environ['CO_API_KEY'])
|
53 |
+
prompt = f"Give a recipe for {dish}."
|
54 |
+
if options:
|
55 |
+
prompt += f" Make sure it is {', '.join(options)}."
|
56 |
+
logger.info(f"Sending prompt {repr(prompt)}")
|
57 |
+
start = time.time()
|
58 |
+
gens = command(co, prompt)
|
59 |
+
recipe = gens[0].text
|
60 |
+
num_tokens = len(gens[0].token_likelihoods)
|
61 |
+
logger.info(f"Generated recipe with {num_tokens} tokens in {time.time()-start:.1f}s: {repr(recipe)}")
|
62 |
+
st.markdown(f"## Recipe for {' '.join(options)} {dish}")
|
63 |
+
st.write(recipe)
|
64 |
+
st.markdown("## Delicious! 10/10 with rice")
|
65 |
|
66 |
# Draw chat history.
|
67 |
with st.expander("About", expanded=False):
|