GlobalGem2 / app.py
Jpreval's picture
Update app.py
766aa15 verified
Raw History Blame Contribute Delete
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()