内容
# genpark-inventory-forecasting-skill
> **GenPark AI Agent Skill** -- # Inventory Demand Forecasting Skill
This repository contains the **Inventory Demand Forecasting Skill** — an agent skill configuration interface (`skill.json`), developer Python SDK (`forecaster.py`), and executable validation scripts designed to predict product stock-out dates, compute reorder trigger windows, and auto-draft supplier purchase orders.
---
## 🚀 Capabilities
* **Smoothed Velocity Engine:** Calculates average daily sales velocity from 30-day history while automatically filtering out promotional spike outliers (e.g. flash sale days above 3x average).
* **Stockout & Reorder Projection:** Maps current stock to a projected depletion date, then back-calculates the last safe purchase order date based on supplier lead time + safety buffer.
* **Automated PO Drafting:** Generates structured ERP-ready purchase order payloads (PO number, SKU, quantity, estimated delivery date, unit cost, total cost) for immediate use in procurement systems.
---
## 🛠️ Setup & Installation
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Configuration:
Set your API environment variable if connecting to a live forecasting backend. Otherwise, the client auto-activates in mock mode:
* **PowerShell**:
```powershell
$env:FORECAST_API_KEY="your_api_key"
```
* **bash**:
```bash
export FORECAST_API_KEY="your_api_key"
```
---
## 💻 SDK Usage Reference
```python
from forecaster import InventoryForecastingClient
client = InventoryForecastingClient()
sales_history = [
{"date": "2026-06-01", "units_sold": 20},
{"date": "2026-06-02", "units_sold": 18},
# ... 30 days of data
]
result = client.forecast(
sku="SKU-001",
current_stock=450,
sales_history=sales_history,
lead_time_days=14,
safety_stock_days=7
)
print(f"Stockout Date: {result['stockout_date']}")
print(f"Reorder By: {result['reorder_trigger_date']}")
print(f"Order Qty: {result['suggested_order_quantity']} units")
# Generate purchase order draft
po = client.build_purchase_order(
sku="SKU-001",
qty=result['suggested_order_quantity'],
reorder_date=result['reorder_trigger_date'],
lead_time_days=14,
unit_cost=12.50
)
```
---
## 📜 License
This project is licensed under the MIT License.