SSSSSSSiao commited on
Commit
acf9444
·
verified ·
1 Parent(s): 77df6ce

Update app.py

Browse files

Polish missing field logic

Files changed (1) hide show
  1. app.py +28 -7
app.py CHANGED
@@ -79,9 +79,13 @@ Return only valid JSON with this exact shape:
79
  Rules:
80
  - Use only facts from this one message.
81
  - Do not invent details.
82
- - Put pickup or delivery time in pickup_time.
83
- - Put pickup place or delivery address in delivery_address.
 
 
 
84
  - If unknown, use an empty string.
 
85
  - missing_fields can only contain: quantity, flavor, pickup_time, delivery_address, payment_status.
86
  """
87
 
@@ -146,13 +150,30 @@ def missing_list(order):
146
  else:
147
  fields = [str(part).strip() for part in raw if str(part).strip()]
148
 
 
 
 
149
  item = text_value(order.get("item"))
150
- if item and not text_value(order.get("quantity")):
 
 
 
 
 
 
151
  fields.append("quantity")
152
- if item and not text_value(order.get("pickup_time")) and not text_value(order.get("delivery_address")):
153
- fields.append("pickup_time")
154
- if item and not text_value(order.get("payment_status")):
155
- fields.append("payment_status")
 
 
 
 
 
 
 
 
156
 
157
  return sorted(set(fields))
158
 
 
79
  Rules:
80
  - Use only facts from this one message.
81
  - Do not invent details.
82
+ - Put dates and times in pickup_time, such as "tomorrow", "Saturday morning", or "Friday 5pm".
83
+ - Put pickup places or delivery addresses in delivery_address, such as "farmers market".
84
+ - "pickup at the farmers market" means delivery_address is "farmers market", not pickup_time.
85
+ - "paid already" means payment_status is "paid".
86
+ - "I can pay Venmo" means payment_status is "can pay Venmo".
87
  - If unknown, use an empty string.
88
+ - Do not ask for flavor unless the product clearly needs a flavor choice.
89
  - missing_fields can only contain: quantity, flavor, pickup_time, delivery_address, payment_status.
90
  """
91
 
 
150
  else:
151
  fields = [str(part).strip() for part in raw if str(part).strip()]
152
 
153
+ allowed = {"quantity", "flavor", "pickup_time", "delivery_address", "payment_status"}
154
+ fields = [field for field in fields if field in allowed]
155
+
156
  item = text_value(order.get("item"))
157
+ quantity = text_value(order.get("quantity"))
158
+ flavor = text_value(order.get("flavor"))
159
+ pickup_time = text_value(order.get("pickup_time"))
160
+ delivery_address = text_value(order.get("delivery_address"))
161
+ payment_status = text_value(order.get("payment_status"))
162
+
163
+ if item and not quantity:
164
  fields.append("quantity")
165
+
166
+ if pickup_time:
167
+ fields = [field for field in fields if field != "pickup_time"]
168
+ if delivery_address:
169
+ fields = [field for field in fields if field != "delivery_address"]
170
+ if payment_status:
171
+ fields = [field for field in fields if field != "payment_status"]
172
+ if flavor:
173
+ fields = [field for field in fields if field != "flavor"]
174
+
175
+ if "flavor" in fields and item.lower() not in ["cake", "birthday cake", "cupcakes"]:
176
+ fields = [field for field in fields if field != "flavor"]
177
 
178
  return sorted(set(fields))
179