Parishri07 commited on
Commit
584533a
Β·
verified Β·
1 Parent(s): b17b983

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -69,14 +69,14 @@ with gr.Blocks(title="RetailGenie Navigator") as demo:
69
  gr.Markdown("## 🧞 RetailGenie – Multi-Store Smart Inventory Assistant")
70
 
71
  with gr.Row():
72
- country = gr.Dropdown(label="🌍 Country", choices=get_subfolders(BASE_DIR), value=None)
73
- state = gr.Dropdown(label="πŸ™οΈ State", value=None)
74
- city = gr.Dropdown(label="🏘️ City", value=None)
75
- store = gr.Dropdown(label="πŸͺ Store", value=None)
76
- category = gr.Dropdown(label="πŸ›οΈ Category", value=None)
77
- product = gr.Dropdown(label="πŸ“¦ Product", value=None)
78
- brand = gr.Dropdown(label="🏷️ Brand", value=None)
79
- quantity = gr.Dropdown(label="πŸ”’ Quantity", visible=False)
80
 
81
  result = gr.Textbox(label="πŸ” Product Info", lines=5)
82
  data_state = gr.State()
@@ -85,37 +85,37 @@ with gr.Blocks(title="RetailGenie Navigator") as demo:
85
 
86
  # Logic: Chain each dropdown to the next
87
  country.change(
88
- lambda c: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c)), value=None),
89
  inputs=country,
90
  outputs=state
91
  )
92
 
93
  state.change(
94
- lambda c, s: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s)), value=None),
95
  inputs=[country, state],
96
  outputs=city
97
  )
98
 
99
  city.change(
100
- lambda c, s, ci: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s, ci)), value=None),
101
  inputs=[country, state, city],
102
  outputs=store
103
  )
104
 
105
  store.change(
106
- lambda c, s, ci, st: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s, ci, st)), value=None),
107
  inputs=[country, state, city, store],
108
  outputs=category
109
  )
110
 
111
  category.change(
112
- lambda c, s, ci, st, cat: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s, ci, st, cat)), value=None),
113
  inputs=[country, state, city, store, category],
114
  outputs=product
115
  )
116
 
117
  product.change(
118
- lambda c, s, ci, st, cat, prod: gr.update(choices=get_csv_files(os.path.join(BASE_DIR, c, s, ci, st, cat, prod)), value=None),
119
  inputs=[country, state, city, store, category, product],
120
  outputs=brand
121
  )
 
69
  gr.Markdown("## 🧞 RetailGenie – Multi-Store Smart Inventory Assistant")
70
 
71
  with gr.Row():
72
+ country = gr.Dropdown(label="🌍 Country", choices=get_subfolders(BASE_DIR), value=None)
73
+ state = gr.Dropdown(label="πŸ™οΈ State", choices=[], visible=True, interactive=False)
74
+ city = gr.Dropdown(label="🏘️ City", choices=[], visible=True, interactive=False)
75
+ store = gr.Dropdown(label="πŸͺ Store", choices=[], visible=True, interactive=False)
76
+ category = gr.Dropdown(label="πŸ›οΈ Category", choices=[], visible=True, interactive=False)
77
+ product = gr.Dropdown(label="πŸ“¦ Product", choices=[], visible=True, interactive=False)
78
+ brand = gr.Dropdown(label="🏷️ Brand", choices=[], visible=True, interactive=False)
79
+ quantity = gr.Dropdown(label="πŸ”’ Quantity", visible=False)
80
 
81
  result = gr.Textbox(label="πŸ” Product Info", lines=5)
82
  data_state = gr.State()
 
85
 
86
  # Logic: Chain each dropdown to the next
87
  country.change(
88
+ lambda c: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c)), value=None,interactive=True),
89
  inputs=country,
90
  outputs=state
91
  )
92
 
93
  state.change(
94
+ lambda c, s: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s)), value=None, interactive=True),
95
  inputs=[country, state],
96
  outputs=city
97
  )
98
 
99
  city.change(
100
+ lambda c, s, ci: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s, ci)), value=None, interactive=True),
101
  inputs=[country, state, city],
102
  outputs=store
103
  )
104
 
105
  store.change(
106
+ lambda c, s, ci, st: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s, ci, st)), value=None, interactive=True),
107
  inputs=[country, state, city, store],
108
  outputs=category
109
  )
110
 
111
  category.change(
112
+ lambda c, s, ci, st, cat: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s, ci, st, cat)), value=None, interactive=True),
113
  inputs=[country, state, city, store, category],
114
  outputs=product
115
  )
116
 
117
  product.change(
118
+ lambda c, s, ci, st, cat, prod: gr.update(choices=get_csv_files(os.path.join(BASE_DIR, c, s, ci, st, cat, prod)), value=None, interactive=True),
119
  inputs=[country, state, city, store, category, product],
120
  outputs=brand
121
  )