diff --git a/controllers/controller.py b/controllers/controller.py index f52e6a6..b354602 100644 --- a/controllers/controller.py +++ b/controllers/controller.py @@ -1,6 +1,4 @@ -from fastapi import APIRouter, Depends, HTTPException -from sqlalchemy.orm import Session -from typing import List +from fastapi import APIRouter, HTTPException from schemas.schemas import LaptopCreate, LaptopResponse, PredictPriceResponse from services.service import LaptopService import os @@ -12,8 +10,17 @@ MODEL_PATH = os.getenv("MODEL_PATH", "laptop_price_model.pkl") FEATURE_COLUMNS_PATH = os.getenv("FEATURE_COLUMNS_PATH", "feature_columns.pkl") laptop_service = LaptopService(model_path=MODEL_PATH, feature_columns_path=FEATURE_COLUMNS_PATH) -@router.post("/predict_price/", response_model=PredictPriceResponse) +@router.post("/predict_price/", response_model=PredictPriceResponse, summary="Predict laptop price", description="Predict the price of a laptop based on its specifications.", response_description="The predicted price of the laptop.") def predict_price(data: LaptopCreate): + """ + Predict the price of a laptop given its specifications. + + - **processor**: Type of processor (e.g., i5, i7) + - **ram**: Amount of RAM in GB + - **os**: Operating system (e.g., Windows, MacOS) + - **ssd**: Size of SSD in GB + - **display**: Size of the display in inches + """ try: return laptop_service.predict_price(data.dict()) except Exception as e: diff --git a/schemas.py b/schemas.py deleted file mode 100644 index 8f85870..0000000 --- a/schemas.py +++ /dev/null @@ -1,19 +0,0 @@ -from pydantic import BaseModel - -class LaptopBase(BaseModel): - title: str - price: float - processor: str - ram: int - ssd: int - display: float - -class LaptopCreate(LaptopBase): - price: float - -class LaptopResponse(LaptopBase): - id: int - price: float - - class Config: - from_attributes = True