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]