Sander Land commited on
Commit
39495a2
1 Parent(s): 1700c40
Files changed (1) hide show
  1. app.py +15 -14
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
- dish = (dish or DEFAULT_DISH).strip()
51
- co = cohere.Client(api_key=os.environ['CO_API_KEY'])
52
- prompt = f"Give a recipe for {dish}."
53
- if options:
54
- prompt += f" Make sure it is {', '.join(options)}."
55
- logger.info(f"Sending prompt {repr(prompt)}")
56
- start = time.time()
57
- gens = command(co, prompt)
58
- recipe = gens[0].text
59
- num_tokens = len(gens[0].token_likelihoods)
60
- logger.info(f"Generated recipe with {num_tokens} tokens in {time.time()-start:.1f}s: {repr(recipe)}")
61
- st.markdown(f"## Recipe for {' '.join(options)} {dish}")
62
- st.write(recipe)
63
- st.markdown("## Delicious! 10/10 with rice")
 
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):