Spaces:
Sleeping
Sleeping
Download app.py from Jpreval/GlobalGem2: direct link, hf CLI and curl.
- Browser
- Download file 2.86 kB
-
https://huggingface.co/spaces/Jpreval/GlobalGem2/resolve/main/app.py
- Command line
-
hf download hf://spaces/Jpreval/GlobalGem2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Jpreval/GlobalGem2/resolve/main/app.py
2.86 kB
| import gradio as gr | |
| import pandas as pd | |
| from datetime import datetime | |
| # π§Ό Real CGS janitorial products with simulated competitor prices | |
| def get_real_cgs_data(): | |
| data = { | |
| 'product': [ | |
| '12oz Microwaveable Container', | |
| '16oz Compostable Hot Cup', | |
| 'PET Clear Plastic Cup', | |
| 'Industrial Can Liner 55Gal' | |
| ], | |
| 'cgs_price': [31.99, 59.99, 69.99, 34.95], | |
| 'competitor_price': [33.50, 62.00, 72.00, 36.00], # Simulated competitor prices | |
| 'synthetic_qty': [95, 5, 60, 15], # Simulated inventory levels | |
| 'pricing_action': ['Hold', 'Discount', 'Raise Price', 'Hold'] | |
| } | |
| df = pd.DataFrame(data) | |
| df['price_gap'] = df['competitor_price'] - df['cgs_price'] | |
| df['urgency_tag'] = df.apply(urgency_tag, axis=1) | |
| df['approval_status'] = df.apply(approval_logic, axis=1) | |
| df['flag_for_review'] = df.apply(flag_logic, axis=1) | |
| df['suggested_action'] = df.apply(suggest_action, axis=1) | |
| df['timestamp'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
| return df | |
| # π¦ Urgency tagging | |
| def urgency_tag(row): | |
| if row['pricing_action'] == 'Raise Price' and row['synthetic_qty'] > 80: | |
| return 'π Fast-Moving' | |
| elif row['pricing_action'] == 'Discount' and row['synthetic_qty'] < 10: | |
| return 'π¦ Overstocked' | |
| else: | |
| return 'βΈοΈ Normal' | |
| # β Approval logic | |
| def approval_logic(row): | |
| if row['urgency_tag'] in ['π Fast-Moving', 'π¦ Overstocked']: | |
| return 'β Auto-Approved' | |
| else: | |
| return 'π Pending Review' | |
| # β οΈ Flag logic | |
| def flag_logic(row): | |
| if row['pricing_action'] == 'Discount' and row['synthetic_qty'] > 80: | |
| return 'β οΈ Discounting Fast-Mover' | |
| elif row['pricing_action'] == 'Raise Price' and row['synthetic_qty'] < 10: | |
| return 'β οΈ Raising Price on Overstock' | |
| else: | |
| return '' | |
| # π§ Suggested action | |
| def suggest_action(row): | |
| if row['flag_for_review']: | |
| return 'π Investigate Strategy' | |
| elif row['approval_status'] == 'β Auto-Approved': | |
| return 'π€ Proceed' | |
| else: | |
| return 'π Await Manager Input' | |
| # π Dashboard logic | |
| def run_dashboard(): | |
| return get_real_cgs_data() | |
| # π Gradio layout with colorful HTML header | |
| with gr.Blocks() as demo: | |
| gr.HTML(""" | |
| <style> | |
| body { background-color: #f0f8ff; } | |
| h2 { color: #4b0082; font-size: 28px; } | |
| .gradio-container { border: 2px solid #4b0082; border-radius: 10px; padding: 10px; } | |
| </style> | |
| <h2>π CGS Janitorial Pricing Intelligence</h2> | |
| <p>Real-time insights powered by mock competitor logic and CGS product data.</p> | |
| """) | |
| gr.Dataframe(value=run_dashboard(), label="Strategic Pricing Dashboard") | |
| # π Launch the app | |
| if __name__ == "__main__": | |
| demo.launch() | |