Canstralian commited on
Commit
23c859c
·
verified ·
1 Parent(s): 60a3ae1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -1,16 +1,17 @@
 
1
  import gradio as gr
2
 
3
- # Define the sidebar items
4
- sidebar_items = [
5
- {"prompt": "Hello world!", "description": "A simple greeting."},
6
- {"prompt": "What is your name?", "description": "Ask a user for their name."},
7
- # Add more prompt examples and descriptions here...
8
- ]
 
 
 
9
 
10
- def greet(name):
11
- return f"Hello {name}!"
12
-
13
- # Create the interface with left sidebar
14
  iface = gr.Interface(
15
  fn=greet,
16
  inputs="text",
@@ -19,8 +20,8 @@ iface = gr.Interface(
19
  description="Ask a user for their name and greet them."
20
  )
21
 
22
- # Add the left sidebar with prompt examples
23
- iface.sidebar(sidebar_items)
24
 
25
  # Launch the Gradio app
26
- iface.launch()
 
1
+ from gradio import components as gc
2
  import gradio as gr
3
 
4
+ # Create a sidebar component
5
+ sidebar = gc.SideBar()
6
+ for item in sidebar_items:
7
+ prompt_button = gc.Button(text=item["prompt"])
8
+ description = item["description"]
9
+ # Add additional styling or functionality if needed
10
+
11
+ # Append the button and description to the sidebar component
12
+ sidebar.append(prompt_button, description)
13
 
14
+ # Create the interface without a sidebar (since we've added it separately)
 
 
 
15
  iface = gr.Interface(
16
  fn=greet,
17
  inputs="text",
 
20
  description="Ask a user for their name and greet them."
21
  )
22
 
23
+ # Add the left sidebar to the interface
24
+ iface.add_component(sidebar, side="left")
25
 
26
  # Launch the Gradio app
27
+ iface.launch()