Upload 4 files
Browse files- app.py +79 -0
- dell_plastic_agent.yaml +32 -0
- readme.md +23 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import os
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# -----------------------------
|
| 6 |
+
# Step 1: Identify top 5 keyboard plastics
|
| 7 |
+
# -----------------------------
|
| 8 |
+
def identify_plastics():
|
| 9 |
+
plastics = [
|
| 10 |
+
{"Material": "ABS (Acrylonitrile Butadiene Styrene)", "Reason": "Durable, easy to mold, common in keycaps"},
|
| 11 |
+
{"Material": "PBT (Polybutylene Terephthalate)", "Reason": "Resists wear and shine, used for premium keyboards"},
|
| 12 |
+
{"Material": "PC (Polycarbonate)", "Reason": "Strong, impact resistant, used for cases and frames"},
|
| 13 |
+
{"Material": "PVC (Polyvinyl Chloride)", "Reason": "Cost-effective, used in some lower-end plastic parts"},
|
| 14 |
+
{"Material": "PA (Nylon/Polyamide)", "Reason": "High strength, used for mechanical components"}
|
| 15 |
+
]
|
| 16 |
+
return pd.DataFrame(plastics)
|
| 17 |
+
|
| 18 |
+
# -----------------------------
|
| 19 |
+
# Step 2–5: Supplier dataset, ranking, and report generation
|
| 20 |
+
# -----------------------------
|
| 21 |
+
def build_and_rank_dataset():
|
| 22 |
+
data = [
|
| 23 |
+
["PlastiTech", "ABS", "$1.5–$2.0/kg", 10, "High", 10, "Texas, USA", 10, "Pellets", "High Volume"],
|
| 24 |
+
["FormoChem", "PBT", "$2.0–$2.5/kg", 7, "Premium", 7, "Malaysia", 10, "Pellets", "High Volume"],
|
| 25 |
+
["InduPoly", "PC", "$1.8–$2.2/kg", 5, "High", 10, "Brazil", 10, "Sheets", "High Volume"],
|
| 26 |
+
["MegaResins", "PVC", "$1.0–$1.5/kg", 3, "Medium", 5, "Mexico", 10, "Blocks", "Medium Volume"],
|
| 27 |
+
["StrongBond", "PA", "$2.3–$2.8/kg", 0, "High", 10, "North Carolina, USA", 10, "Pellets", "High Volume"]
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
cols = [
|
| 31 |
+
"Supplier Name", "Material", "Material Cost Range", "Material Cost Score",
|
| 32 |
+
"Material Grade", "Material Grade Score", "Primary Location",
|
| 33 |
+
"Shipping Distance Score", "Delivery Method", "Capacity Capability"
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
df = pd.DataFrame(data, columns=cols)
|
| 37 |
+
# Compute overall score
|
| 38 |
+
df["Overall Score"] = (df["Material Cost Score"] * 5) + (df["Material Grade Score"] * 3) + (df["Shipping Distance Score"] * 2)
|
| 39 |
+
return df
|
| 40 |
+
|
| 41 |
+
# -----------------------------
|
| 42 |
+
# Step 6: Generate and save report
|
| 43 |
+
# -----------------------------
|
| 44 |
+
def generate_report():
|
| 45 |
+
plastics_df = identify_plastics()
|
| 46 |
+
suppliers_df = build_and_rank_dataset()
|
| 47 |
+
|
| 48 |
+
output_file = "dell_keyboard_plastic_suppliers.xlsx"
|
| 49 |
+
os.makedirs(".", exist_ok=True)
|
| 50 |
+
|
| 51 |
+
with pd.ExcelWriter(output_file, engine='openpyxl') as writer:
|
| 52 |
+
plastics_df.to_excel(writer, index=False, sheet_name="Plastic Types")
|
| 53 |
+
suppliers_df.to_excel(writer, index=False, sheet_name="Suppliers")
|
| 54 |
+
|
| 55 |
+
return f"✅ Report generated successfully.\n\nFile saved as: {output_file}"
|
| 56 |
+
|
| 57 |
+
# -----------------------------
|
| 58 |
+
# Optional Gradio UI
|
| 59 |
+
# -----------------------------
|
| 60 |
+
def run_agent():
|
| 61 |
+
message = generate_report()
|
| 62 |
+
df = build_and_rank_dataset()
|
| 63 |
+
return message, df
|
| 64 |
+
|
| 65 |
+
iface = gr.Interface(
|
| 66 |
+
fn=run_agent,
|
| 67 |
+
inputs=[],
|
| 68 |
+
outputs=[gr.Textbox(lines=4, label="Process Log"), gr.Dataframe(label="Supplier Dataset Snapshot")],
|
| 69 |
+
title="Dell Keyboard Plastic Procurement Agent",
|
| 70 |
+
description=(
|
| 71 |
+
"This agent identifies plastics suitable for Dell keyboards, finds suppliers, "
|
| 72 |
+
"ranks them based on cost, material grade, and shipping distance, "
|
| 73 |
+
"and generates an Excel report."
|
| 74 |
+
),
|
| 75 |
+
allow_flagging="never"
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
if __name__ == "__main__":
|
| 79 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|
dell_plastic_agent.yaml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Dell Keyboard Plastic Procurement Agent
|
| 2 |
+
description: >
|
| 3 |
+
Identifies and ranks global plastic suppliers for Dell keyboard manufacturing based on material quality, cost, and logistics.
|
| 4 |
+
|
| 5 |
+
language: python
|
| 6 |
+
|
| 7 |
+
objectives:
|
| 8 |
+
- Identify key plastics used in keyboards.
|
| 9 |
+
- Build and evaluate supplier dataset.
|
| 10 |
+
- Rank suppliers using cost, grade, and shipping criteria.
|
| 11 |
+
- Generate final Excel report.
|
| 12 |
+
- Provide optional Gradio interface for interaction.
|
| 13 |
+
|
| 14 |
+
tasks:
|
| 15 |
+
- title: Identify plastics
|
| 16 |
+
expected_output: DataFrame listing top 5 keyboard plastics with reasons.
|
| 17 |
+
|
| 18 |
+
- title: Build supplier dataset
|
| 19 |
+
expected_output: DataFrame of suppliers with attributes.
|
| 20 |
+
|
| 21 |
+
- title: Rank and compute scores
|
| 22 |
+
expected_output: Adds weighted ranking and scores.
|
| 23 |
+
|
| 24 |
+
- title: Generate Excel report
|
| 25 |
+
expected_output: Exports dell_keyboard_plastic_suppliers.xlsx.
|
| 26 |
+
|
| 27 |
+
metadata:
|
| 28 |
+
author: "User"
|
| 29 |
+
created: "2025-12-10"
|
| 30 |
+
version: "2.0"
|
| 31 |
+
ui: "Gradio interface enabled"
|
| 32 |
+
output_file: "dell_keyboard_plastic_suppliers.xlsx"
|
readme.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dell Keyboard Plastic Procurement Agent 🧠
|
| 2 |
+
|
| 3 |
+
This Hugging Face Space identifies and ranks potential suppliers of plastics used in Dell computer keyboards.
|
| 4 |
+
|
| 5 |
+
## 🚀 Features
|
| 6 |
+
- Identifies top 5 plastic materials used in keyboard manufacturing.
|
| 7 |
+
- Builds supplier dataset with cost, grade, and logistic metrics.
|
| 8 |
+
- Ranks suppliers with weighted scoring formula.
|
| 9 |
+
- Exports full Excel report (`dell_keyboard_plastic_suppliers.xlsx`).
|
| 10 |
+
- Optional interactive Gradio UI to run and preview data.
|
| 11 |
+
|
| 12 |
+
## 🧮 Scoring Formula
|
| 13 |
+
`Overall Score = (Material Cost Score × 5) + (Material Grade Score × 3) + (Shipping Distance Score × 2)`
|
| 14 |
+
|
| 15 |
+
## 📂 Output
|
| 16 |
+
- File: `dell_keyboard_plastic_suppliers.xlsx`
|
| 17 |
+
- Sheets: “Plastic Types”, “Suppliers”
|
| 18 |
+
|
| 19 |
+
## 💻 Local Run
|
| 20 |
+
```bash
|
| 21 |
+
pip install -r requirements.txt
|
| 22 |
+
python app.py
|
| 23 |
+
```
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas>=2.0.0
|
| 2 |
+
openpyxl>=3.1.0
|
| 3 |
+
numpy>=1.25.0
|
| 4 |
+
gradio>=4.0.0
|