tonyliu404 commited on
Commit
741d587
·
verified ·
1 Parent(s): bb92baa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -18,6 +18,7 @@ import matplotlib.pyplot as plt
18
  from matplotlib.colors import LinearSegmentedColormap
19
  import textwrap
20
  import plotly.graph_objects as go
 
21
 
22
  st.set_page_config(
23
  page_title="Food Chain",
@@ -266,20 +267,24 @@ def display_response(response):
266
  if isinstance(response, str):
267
  # Convert JSON string to dictionary if necessary
268
  response = json.loads(response)
269
-
270
- st.write(f"**Name:** {response['name'].capitalize()}")
271
- st.write(f"**Preparation Time:** {response['minutes']} minutes")
272
- st.write(f"**Description:** {response['description'].capitalize()}")
273
- st.write(f"**Tags:** {', '.join(response['tags'])}")
274
- st.write("### Ingredients")
275
- st.write(", ".join([ingredient.capitalize() for ingredient in response['ingredients']]))
276
- st.write(f"**Total Ingredients:** {response['n_ingredients']}")
277
- st.write("### Nutrition Information (per serving)")
278
- st.write(", ".join(response['formatted_nutrition']))
279
- st.write(f"**Number of Steps:** {response['n_steps']}")
280
- st.write("### Steps")
281
- for step in response['formatted_steps']:
282
- st.write(capitalize_after_number(step))
 
 
 
 
283
 
284
  def display_dishes_in_grid(dishes, cols=3):
285
  rows = len(dishes) // cols + int(len(dishes) % cols > 0)
 
18
  from matplotlib.colors import LinearSegmentedColormap
19
  import textwrap
20
  import plotly.graph_objects as go
21
+ import streamlit_scrollable_textbox as stx
22
 
23
  st.set_page_config(
24
  page_title="Food Chain",
 
267
  if isinstance(response, str):
268
  # Convert JSON string to dictionary if necessary
269
  response = json.loads(response)
270
+
271
+ stx.scrollableTextbox(f"""
272
+ **Name:** {response['name'].capitalize()}
273
+ **Preparation Time:** {response['minutes']} minutes
274
+ **Description:** {response['description'].capitalize()}
275
+ **Tags:** {', '.join(response['tags'])}
276
+
277
+ ### Ingredients
278
+ {", ".join([ingredient.capitalize() for ingredient in response['ingredients']])}
279
+ **Total Ingredients:** {response['n_ingredients']}
280
+
281
+ ### Nutrition Information (per serving)
282
+ {", ".join(response['formatted_nutrition'])}
283
+ **Number of Steps:** {response['n_steps']}
284
+
285
+ ### Steps
286
+ {chr(10).join([capitalize_after_number(step) for step in response['formatted_steps']])}
287
+ """)
288
 
289
  def display_dishes_in_grid(dishes, cols=3):
290
  rows = len(dishes) // cols + int(len(dishes) % cols > 0)