Spaces:
Build error
Build error
Update app.py
Browse files375 unmodified lines376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429375 unmodified lines# Extracting the id for the warehouse with the name "WH"warehouse_id = next((item['id'] for item in data['result'] if item['name'] == warehouse_name), None)#print(warehouse_id)if warehouse_id is None:print("DB error thrown")return "Please provide a warehouse name available in the database."# print(f"The id for the warehouse named {name} is: {warehouse_id}")# Step 3: Update the placeholder with the actual warehouse_idfor api in apis:if "warehouseId" in api["params"]:api["params"]["warehouseId"] = warehouse_idprint(f"warehouseId: {warehouse_id}")print(f"warehouseId: {apis[1]}")data1 = make_api_request(apis[1]["url"], apis[1]["params"])if (data1):headers = ["S.No", "Warehouse Code", "Warehouse Name", "Customer Code", "Customer Name", "Item Code", "Item Name","Currency", "EAN", "UOM", "Quantity", "Gross Weight", "Volume", "Total Value"]table_data = []for index, item in enumerate(data1['result'], start=1):row = [index, # Serial numberitem['warehouse']['code'],item['warehouse']['name'],item['customer']['code'],item['customer']['name'],item['skuMaster']['code'],item['skuMaster']['name'],item['currency']['code'],item['eanUpc'],item['uom']['code'],item['totalQty'],item['grossWeight'],item['volume'],item['totalValue']]table_data.append(row)# Convert to pandas DataFramedf = pd.DataFrame(table_data, columns=headers)sdf = SmartDataframe(df, config={"llm": llm_chart})# chart = sdf.chat("Can you draw a bar chart with all avaialble item name and quantity.")chart = sdf.chat(question)return chartelse:return "There are no inventory details for the warehouse you have given."# inventory_report("WH:can you give me a bar chart with item name and quantity for the warehouse WH")375 unmodified lines376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430375 unmodified lines# Extracting the id for the warehouse with the name "WH"warehouse_id = next((item['id'] for item in data['result'] if item['name'] == warehouse_name), None)#print(warehouse_id)if (warehouse_id):# print(f"The id for the warehouse named {name} is: {warehouse_id}")# Step 3: Update the placeholder with the actual warehouse_idfor api in apis:if "warehouseId" in api["params"]:api["params"]["warehouseId"] = warehouse_idprint(f"warehouseId: {warehouse_id}")print(f"warehouseId: {apis[1]}")data1 = make_api_request(apis[1]["url"], apis[1]["params"])if (data1):headers = ["S.No", "Warehouse Code", "Warehouse Name", "Customer Code", "Customer Name", "Item Code", "Item Name","Currency", "EAN", "UOM", "Quantity", "Gross Weight", "Volume", "Total Value"]table_data = []for index, item in enumerate(data1['result'], start=1):row = [index, # Serial numberitem['warehouse']['code'],item['warehouse']['name'],item['customer']['code'],item['customer']['name'],item['skuMaster']['code'],item['skuMaster']['name'],item['currency']['code'],item['eanUpc'],item['uom']['code'],item['totalQty'],item['grossWeight'],item['volume'],item['totalValue']]table_data.append(row)# Convert to pandas DataFramedf = pd.DataFrame(table_data, columns=headers)sdf = SmartDataframe(df, config={"llm": llm_chart})# chart = sdf.chat("Can you draw a bar chart with all avaialble item name and quantity.")chart = sdf.chat(question)return chartelse:return "There are no inventory details for the warehouse you have given."else:return "Please provide a warehouse name available in the database."# inventory_report("WH:can you give me a bar chart with item name and quantity for the warehouse WH")
app.py+48-47