From c0feadec6a0e68f9355044d3f6c435c651da88c9 Mon Sep 17 00:00:00 2001 From: pollutri Date: Thu, 5 Feb 2026 11:44:58 +0100 Subject: [PATCH] Infer Output bug fix --- app.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 919664d..0934fec 100644 --- a/app.py +++ b/app.py @@ -24,7 +24,7 @@ from collections import OrderedDict from pydantic import BaseModel, Field -from fastapi import Depends, FastAPI, HTTPException, File, UploadFile +from fastapi import Depends, FastAPI, HTTPException, File, UploadFile, Query from fastapi.encoders import jsonable_encoder from fastapi.openapi.docs import get_swagger_ui_html from fastapi.openapi.utils import get_openapi @@ -193,19 +193,34 @@ async def get_documentation(): @app.get("/ble-ai/infer", tags=["BLE-AI"]) -async def get_ble_ai_infer(): +async def get_ble_ai_infer(mac: Optional[List[str]] = Query(default=None)): path = config_env.BLE_AI_INFER_CSV if not os.path.isfile(path): raise HTTPException(status_code=404, detail="CSV not found") + mac_filter = None + if mac: + mac_filter = set() + for item in mac: + if not item: + continue + for part in str(item).split(","): + part = part.strip() + if part: + mac_filter.add(part.lower()) + items = [] with open(path, newline="") as f: reader = csv.DictReader(f, delimiter=";") for row in reader: + row_mac = row.get("mac") + if mac_filter is not None: + if not row_mac or row_mac.lower() not in mac_filter: + continue try: items.append( { - "mac": row.get("mac"), + "mac": row_mac, "z": int(row["z"]) if row.get("z") not in (None, "") else None, "x": int(row["x"]) if row.get("x") not in (None, "") else None, "y": int(row["y"]) if row.get("y") not in (None, "") else None,