Spaces:
Sleeping
Sleeping
File size: 16,852 Bytes
3020731 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | from public_api.public_api_item import get_item
from public_api.utils import humanize_value, translate_velocity, format_hold_type, format_reason_code, format_backend_date, translate_loc_sts
from public_api.public_api_inventory import get_inventory_holds
from public_api.public_api_location import get_location_status
# field_mapping.py
##################################################################
# --- A. Define your translations ---
# Helper for simple flags
#def boolean_to_yesno(val):
# return "Yes" if val is True else "No"
# --- B. Your Configuration Maps ---
# 1. Which fields do you want? (Display Name -> JSON Path)
ITEM_MAPPING = {
"Item": "itemNumber",
"Ignore Pick Consolidation Flag":"itemPickingConfiguration.ignorePickConsolidationFlag",
"Threshold Pick Variance":"itemPickingConfiguration.thresholdPickVariance",
"Color":"color",
"Supplier Lot Flag":"itemAttributes.supplierLotFlag",
#"Lot Format ID":"itemAttributes.lotFormatId",
"Lot Flag":"itemAttributes.lotFlag",
"Revision Flag":"itemAttributes.revisionFlag",
"Origin Flag":"itemAttributes.originFlag",
"Ship Restricted Lot Flag":"itemAttributes.shipRestrictedLotFlag",
"Item Class Name":"itemClassName",
"Department Code":"departmentCode",
"Description": "description",
"Item type":"type",
"Commodity Code":"itemTransportation.commodityCode",
"Is Hazardous": "itemTransportation.hazardousMaterialFlag", # Needs translation
"Report UoM":"reportUom",
"Fit":"fit",
"Aging Profile Name":"itemDateControl.agingProfileName",
"Date Window Value":"itemDateControl.dateWindowValue",
"Shelf Life Time Code":"itemDateControl.shelfLifeTimeCode",
"Date Code":"itemDateControl.dateCode",
"Time To Warn For Expiration":"itemDateControl.timeToWarnForExpiration",
"Date Window Time Code":"itemDateControl.dateWindowTimeCode",
"Shelf Life":"itemDateControl.shelfLife",
"Date Window Type":"itemDateControl.dateWindowType",
"Conveyable Flag":"conveyableFlag",
"Count Near Zero Amount":"itemCountingConfiguration.countNearZeroAmount",
"Adjustment Flag":"itemCountingConfiguration.adjustmentFlag",
"Count Back Flag":"itemCountingConfiguration.countBackFlag",
"Count Near Zero Flag":"itemCountingConfiguration.countNearZeroFlag",
"Count Threshold Unit":"itemCountingConfiguration.countThresholdUnit",
"Count Threshold Cost":"itemCountingConfiguration.countThresholdCost",
"Maximum Extreme Tolerance":"catchConfiguration.maximumExtremeTolerance",
"Catch Unit Type":"catchConfiguration.catchUnitType",
"Maximum Item Tolerance":"catchConfiguration.maximumItemTolerance",
"Minimum Item Tolerance":"catchConfiguration.minimumItemTolerance",
"Average Catch Capture":"catchConfiguration.averageCatchCapture",
"Skip Prompt":"catchConfiguration.skipPrompt",
"Minimum Extreme Tolerance":"catchConfiguration.minimumExtremeTolerance",
"Catch Unit Weight":"catchConfiguration.catchUnitWeight",
"Catch Code":"catchConfiguration.catchCode",
"Catch Unit Cost":"catchConfiguration.catchUnitCost",
"Weight Code":"weightCode",
"Item Hierarchy Name":"itemHierarchyName",
"Receive Flag":"itemReceivingConfiguration.receiveFlag",
"Receive Status":"itemReceivingConfiguration.receiveStatus",
"Item Client ID":"itemClientId",
"ABC Code":"abcCode",
"Unit Cost":"itemCost.unitCost",
"Currency Code":"itemCost.currencyCode",
"Replace Pick Flag":"itemPutawayConfiguration.replacePickFlag",
"Opportunistic Cross Dock Flag":"itemPutawayConfiguration.opportunisticCrossDockFlag",
"Is Default Footprint":"footprints.0.isDefaultFootprint",
"Level Units":"footprints.0.levelUnits",
"Footprint Code":"footprints.0.footprintCode",
"Default LPN Attribute 1":"footprints.0.defaultLpnAttribute1",
"Default LPN Attribute 2":"footprints.0.defaultLpnAttribute2",
"Default LPN Attribute 5":"footprints.0.defaultLpnAttribute5",
#pallet
"Pallet UoM Code":"footprints.0.footprintDetails.0.uomCode",
"Is Pallet Stocking UoM":"footprints.0.footprintDetails.0.isStockingUom",
"Pallet Length":"footprints.0.footprintDetails.0.length",
"Pallet UoM Level":"footprints.0.footprintDetails.0.uomLevel",
"Pallet Net Weight":"footprints.0.footprintDetails.0.netWeight",
"Pallet Gross Weight":"footprints.0.footprintDetails.0.grossWeight",
"Is Pallet Default Receiving UoM":"footprints.0.footprintDetails.0.isDefaultReceivingUom",
"Pallet Unit Quantity":"footprints.0.footprintDetails.0.unitQuantity",
"Pallet Width":"footprints.0.footprintDetails.0.width",
"Is Pallet UoM":"footprints.0.footprintDetails.0.isPalletUom",
"Is Pallet Package UoM":"footprints.0.footprintDetails.0.isPackageUom",
"Is Pallet Case UoM":"footprints.0.footprintDetails.0.isCaseUom",
"Is Pallet Layer UoM":"footprints.0.footprintDetails.0.isLayerUom",
"Pallet Height":"footprints.0.footprintDetails.0.height",
#each
"Each UoM Code":"footprints.0.footprintDetails.1.uomCode",
"Is Each Stocking UoM":"footprints.0.footprintDetails.1.isStockingUom",
"Each Length":"footprints.0.footprintDetails.1.length",
"Each UoM Level":"footprints.0.footprintDetails.1.uomLevel",
"Each Net Weight":"footprints.0.footprintDetails.1.netWeight",
"Each Gross Weight":"footprints.0.footprintDetails.1.grossWeight",
"Is Each Default Receiving UoM":"footprints.0.footprintDetails.1.isDefaultReceivingUom",
"Each Unit Quantity":"footprints.0.footprintDetails.1.unitQuantity",
"Each Width":"footprints.0.footprintDetails.1.width",
"Is Each UoM":"footprints.0.footprintDetails.1.isPalletUom",
"Is Each Package UoM":"footprints.0.footprintDetails.1.isPackageUom",
"Is Each Case UoM":"footprints.0.footprintDetails.1.isCaseUom",
"Is Each Layer UoM":"footprints.0.footprintDetails.1.isLayerUom",
"Each Height":"footprints.0.footprintDetails.1.height",
#case
"Case UoM Code":"footprints.0.footprintDetails.2.uomCode",
"Is Case Stocking UoM":"footprints.0.footprintDetails.2.isStockingUom",
"Case Length":"footprints.0.footprintDetails.2.length",
"Case UoM Level":"footprints.0.footprintDetails.2.uomLevel",
"Case Net Weight":"footprints.0.footprintDetails.2.netWeight",
"Case Gross Weight":"footprints.0.footprintDetails.2.grossWeight",
"Is Case Default Receiving UoM":"footprints.0.footprintDetails.2.isDefaultReceivingUom",
"Case Unit Quantity":"footprints.0.footprintDetails.2.unitQuantity",
"Case Width":"footprints.0.footprintDetails.2.width",
"Is Case UoM":"footprints.0.footprintDetails.2.isPalletUom",
"Is Case Package UoM":"footprints.0.footprintDetails.2.isPackageUom",
"Is Case Case UoM":"footprints.0.footprintDetails.2.isCaseUom",
"Is Case Layer UoM":"footprints.0.footprintDetails.2.isLayerUom",
"Case Height":"footprints.0.footprintDetails.2.height",
"Description":"footprints.0.description",
"Case Level":"footprints.0.caseLevel",
"Default Lpn Attribute 3":"footprints.0.defaultLpnAttribute3",
"Default Lpn Attribute 4":"footprints.0.defaultLpnAttribute4",
"Default Handling Unit":"footprints.0.defaultHandlingUnit",
"Assorted Flag":"assortedFlag",
#"Warehouse ID":"itemId.warehouseId",
#"Item Number":"itemId.itemNumber",
#"Item Client ID":"itemId.itemClientId",
"Size":"size",
"Warehouse ID": "warehouseId",
"Delay Outbound Serial Capture Flag":"itemSerialization.delayOutboundSerialCaptureFlag",
"Serialization Level":"itemSerialization.serializationLevel",
"Serialization Type":"itemSerialization.serializationType",
"Style":"style",
"Velocity Zone Code": "itemVelocity.velocityZoneCode", # Needs translation
"Velocity Zone Recalculation Flag": "itemVelocity.velocityZoneRecalculationFlag", # Often Null
"Load Level":"loadLevel",
}
# 2. How should they look? (Display Name -> Transformer Function)
ITEM_FORMATTERS = {
"Ignore Pick Consolidation Flag":humanize_value,
"Color":humanize_value,
"Supplier Lot Flag":humanize_value,
#"Lot Format ID":"humanize_value,
"Lot Flag":humanize_value,
"Revision Flag":humanize_value,
"Origin Flag":humanize_value,
"Ship Restricted Lot Flag":humanize_value,
"Item Class Name":humanize_value,
"Department Code":humanize_value,
"Commodity Code":humanize_value,
"Is Hazardous":humanize_value,
"Report UoM":humanize_value,
"Fit":humanize_value,
"Aging Profile Name":humanize_value,
"Shelf Life":humanize_value,
"Date Window Type":humanize_value,
"Conveyable Flag":humanize_value,
"Count Near Zero Amount":humanize_value,
"Adjustment Flag":humanize_value,
"Count Back Flag":humanize_value,
"Count Near Zero Flag":humanize_value,
"Maximum Extreme Tolerance":humanize_value,
"Catch Unit Type":humanize_value,
"Maximum Item Tolerance":humanize_value,
"Minimum Item Tolerance":humanize_value,
"Average Catch Capture":humanize_value,
"Skip Prompt":humanize_value,
"Minimum Extreme Tolerance":humanize_value,
"Catch Unit Weight":humanize_value,
"Catch Unit Cost":humanize_value,
"Weight Code":humanize_value,
"Item Hierarchy Name":humanize_value,
"Receive Flag":humanize_value,
#"ABC Code":"abcCode",
"Replace Pick Flag":humanize_value,
"Opportunistic Cross Dock Flag":humanize_value,
"Is Default Footprint":humanize_value,
"Default LPN Attribute 1":humanize_value,
"Default LPN Attribute 2":humanize_value,
"Default LPN Attribute 5":humanize_value,
#pallet
"Is Pallet Stocking UoM":humanize_value,
"Is Pallet Default Receiving UoM":humanize_value,
"Is Pallet UoM":humanize_value,
"Is Pallet Package UoM":humanize_value,
"Is Pallet Case UoM":humanize_value,
"Is Pallet Layer UoM":humanize_value,
#each
"Is Each Stocking UoM":humanize_value,
"Is Each Default Receiving UoM":humanize_value,
"Is Each UoM":humanize_value,
"Is Each Package UoM":humanize_value,
"Is Each Case UoM":humanize_value,
"Is Each Layer UoM":humanize_value,
#case
"Is Case Stocking UoM":humanize_value,
"Is Case Default Receiving UoM":humanize_value,
"Is Case UoM":humanize_value,
"Is Case Package UoM":humanize_value,
"Is Case Case UoM":humanize_value,
"Is Case Layer UoM":humanize_value,
#"Case Level":"footprints.0.caseLevel",
"Default Lpn Attribute 3":humanize_value,
"Default Lpn Attribute 4":humanize_value,
"Assorted Flag":humanize_value,
"Size": humanize_value,
"Delay Outbound Serial Capture Flag":humanize_value,
"Style":humanize_value,
"Velocity Zone Code": translate_velocity, # Needs translation
"Velocity Zone Recalculation Flag": humanize_value # Often Null
}
# field_mapping.py (Add this)
#ITEM_TOOL = {
# "name": "get_item_data",
# "description": "Get real-time warehouse data for a specific item or article number.",
# "parameters": {
# "type": "object",
# "properties": {
# "item_number": {
# "type": "string",
# "description": "The unique item number (e.g., '100002')"
# }
# },
# "required": ["item_number"]
# }
#}
ITEM_TOOL = {
"name": "get_item_data",
"description": ("Retrieve complete real-time warehouse master data for a specific item. "
"Use this for any queries regarding: "
"1. Item Attributes (Lot, Supplier, Revision, Receivable/Receive, Origin flags). "
"2. Picking & Putting Configuration (Consolidation, Thresholds, Cross-dock). "
"3. Dimensions & Footprints (Weights, Heights, and Lengths for Each, Case, or Pallets). "
"4. Date Controls (Shelf life, Aging profiles, and Expiration windows). "
"5. Counting & Tolerance settings (Near zero flags, Catch weights, and extreme tolerances). "
"6. Transportation & Safety (Hazardous material flags and Commodity codes)."),
"parameters": {
"type": "object",
"properties": {
"item_number": {"type": "string", "description": "The item ID (e.g. '100002')"},
#"warehouse_id": {"type": "string", "description": "Warehouse ID. Optional: if not provided, the system uses the user's default session warehouse."},
"fields": {
"type": "array",
"items": {"type": "string"},
"description": "The specific display names of the fields requested by the user (e.g., ['Supplier Lot Flag', 'Color'])."
}
},
"required": ["item_number"]
}
}
HOLD_MAPPING = {
#"Hold Number": "hldnum",
"Warehouse ID": "wh_id",
"Hold Type": "hldtyp",
"Item": "prtnum",
"Item Description": "dsp_prtnum",
"Hold Date": "hlddte",
"User ID": "hld_usr_id",
"Hold Reason Code": "reacod",
"LPN": "lodnum",
"Sub-LPN": "subnum",
"Detail-LPN": "dtlnum",
"Hold Quantity": "untqty"
}
"""
HOLD_TOOL = {
"name": "get_inventory_holds",
"description": "Get inventory hold details by LPN, Load, Sub-load, or Detail ID for a specific warehouse.",
"parameters": {
"type": "object",
"properties": {
"warehouse_id": {"type": "string", "description": "The warehouse ID to filter results (e.g., 'WH1')"},
"lodnum": {"type": "string", "description": "Inventory Load Number/LPN"},
"subnum": {"type": "string", "description": "Inventory Sub Load Number"},
"dtlnum": {"type": "string", "description": "Inventory Detail Number"},
#"lpn": {"type": "string", "description": "License Plate Number"}
},
"required": ["warehouse_id"]
}
}
"""
HOLD_FORMATTERS = {
"Hold Type": format_hold_type,
"Hold Reason Code": format_reason_code,
"Hold Date": format_backend_date
}
HOLD_TOOL = {
"name": "get_inventory_holds",
"description": (
"Retrieve inventory hold records for a warehouse. "
"Use this for ANY query about inventory holds, including: "
"1. Listing ALL holds in a warehouse (when no specific ID is provided). "
"2. Counting the number of hold LPN/inventory. "
"3. Checking a specific LPN, Sub-LPN, or Detail-LPN."
),
"parameters": {
"type": "object",
"properties": {
##"warehouse_id": {
## "type": "string",
## "description": "The warehouse ID. If the user does not specify one, use 'WH1' as the default."
##},
#"warehouse_id": {"type": "string", "description": "The warehouse ID (e.g., 'WH1'). Default to 'WH1' if not specified."},
"lodnum": {"type": "string", "description": "LPN/Inventory/Inventory ID (optional)"},
"subnum": {"type": "string", "description": "Sub-LPN (optional)"},
"dtlnum": {"type": "string", "description": "Detail-LPN (optional)"},
},
"required": []
}
}
LOCATION_STATUS_MAPPING = {
"Location": "stoloc",
"Location Status":"locsts"
}
LOCATION_STATUS_FORMATTERS = {
"Location Status": translate_loc_sts
}
LOCATION_TOOL = {
"name": "get_location_status",
"description": "Check the status of a specific storage location (stoloc/Location).",
"parameters": {
"type": "object",
"properties": {
"stoloc": {
"type": "string",
"description": "The specific storage location or bin name."
},
#"warehouse_id": {
# "type": "string",
# "description": "Optional: Override the default warehouse ID."
#}
},
"required": ["stoloc"] # No longer mandatory for the user to speak it
}
}
TOOL_REGISTRY = {
"get_item_data": {
"function": get_item,
"mapping": ITEM_MAPPING,
"formatters": ITEM_FORMATTERS,
"response_key": "data",
"id_param": "item_number"
},
"get_inventory_holds": {
"function": get_inventory_holds,
"mapping": HOLD_MAPPING,
"formatters": HOLD_FORMATTERS,
"response_key": "data",
"id_param": "lodnum" # Default primary ID to look for
},
"get_location_status": {
"function": get_location_status,
"mapping": LOCATION_STATUS_MAPPING,
"formatters": LOCATION_STATUS_FORMATTERS,
"response_key": "data",
"id_param": "stoloc"
}
}
# Used in the Gemini API Payload
ALL_TOOLS = [ITEM_TOOL,HOLD_TOOL,LOCATION_TOOL] |