Improve AI logic
This commit is contained in:
@@ -184,7 +184,7 @@ class SupplierSelectionSettings(BaseModel):
|
||||
|
||||
@validator('price_weight', 'lead_time_weight', 'quality_weight', 'reliability_weight')
|
||||
def validate_weights_sum(cls, v, values):
|
||||
weights = [values.get('price_weight', 0.40), values.get('lead_time_weight', 0.20),
|
||||
weights = [values.get('price_weight', 0.40), values.get('lead_time_weight', 0.20),
|
||||
values.get('quality_weight', 0.20), values.get('reliability_weight', 0.20)]
|
||||
total = sum(weights)
|
||||
if total > 1.0:
|
||||
@@ -192,6 +192,32 @@ class SupplierSelectionSettings(BaseModel):
|
||||
return v
|
||||
|
||||
|
||||
class MLInsightsSettings(BaseModel):
|
||||
"""ML Insights configuration settings"""
|
||||
# Inventory ML (Safety Stock Optimization)
|
||||
inventory_lookback_days: int = Field(90, ge=30, le=365, description="Days of demand history for safety stock analysis")
|
||||
inventory_min_history_days: int = Field(30, ge=7, le=180, description="Minimum days of history required")
|
||||
|
||||
# Production ML (Yield Prediction)
|
||||
production_lookback_days: int = Field(90, ge=30, le=365, description="Days of production history for yield analysis")
|
||||
production_min_history_runs: int = Field(30, ge=10, le=100, description="Minimum production runs required")
|
||||
|
||||
# Procurement ML (Supplier Analysis & Price Forecasting)
|
||||
supplier_analysis_lookback_days: int = Field(180, ge=30, le=730, description="Days of order history for supplier analysis")
|
||||
supplier_analysis_min_orders: int = Field(10, ge=5, le=100, description="Minimum orders required for analysis")
|
||||
price_forecast_lookback_days: int = Field(180, ge=90, le=730, description="Days of price history for forecasting")
|
||||
price_forecast_horizon_days: int = Field(30, ge=7, le=90, description="Days to forecast ahead")
|
||||
|
||||
# Forecasting ML (Dynamic Rules)
|
||||
rules_generation_lookback_days: int = Field(90, ge=30, le=365, description="Days of sales history for rule learning")
|
||||
rules_generation_min_samples: int = Field(10, ge=5, le=100, description="Minimum samples required for rule generation")
|
||||
|
||||
# Global ML Settings
|
||||
enable_ml_insights: bool = Field(True, description="Enable/disable ML insights generation")
|
||||
ml_insights_auto_trigger: bool = Field(False, description="Automatically trigger ML insights in daily workflow")
|
||||
ml_confidence_threshold: float = Field(0.80, ge=0.0, le=1.0, description="Minimum confidence threshold for ML recommendations")
|
||||
|
||||
|
||||
# ================================================================
|
||||
# REQUEST/RESPONSE SCHEMAS
|
||||
# ================================================================
|
||||
@@ -210,6 +236,7 @@ class TenantSettingsResponse(BaseModel):
|
||||
safety_stock_settings: SafetyStockSettings
|
||||
moq_settings: MOQSettings
|
||||
supplier_selection_settings: SupplierSelectionSettings
|
||||
ml_insights_settings: MLInsightsSettings
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
@@ -229,6 +256,7 @@ class TenantSettingsUpdate(BaseModel):
|
||||
safety_stock_settings: Optional[SafetyStockSettings] = None
|
||||
moq_settings: Optional[MOQSettings] = None
|
||||
supplier_selection_settings: Optional[SupplierSelectionSettings] = None
|
||||
ml_insights_settings: Optional[MLInsightsSettings] = None
|
||||
|
||||
|
||||
class CategoryUpdateRequest(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user