Skip to content

Commit e49e206

Browse files
update service catalog example and packaging data
1 parent 361de1b commit e49e206

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/browsergym/workarena/data_files/task_configs/order_packaging_and_shipping.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"parcel_details": "a box of office supplies",
77
"parcel_keywords": "office supplies",
88
"quantity": 1,
9-
"goal": "I need to do a Inter-office shipment. The package ships to 10369 Democracy Lane, Fairfax,VA. The parcel contains Packaging and Shipping."
9+
"goal": "I need to do a Inter-office shipment. The package ships to 10369 Democracy Lane, Fairfax,VA. The parcel contains a box of office supplies."
1010
},
1111
{
1212
"item": "Packaging and Shipping",
@@ -15,7 +15,7 @@
1515
"parcel_details": "a set of high performance laptops for the team to use",
1616
"parcel_keywords": "laptop",
1717
"quantity": 1,
18-
"goal": "I need to do a Inter-office shipment. The package ships to Hyderabad. The parcel contains Packaging and Shipping."
18+
"goal": "I need to do a Inter-office shipment. The package ships to Hyderabad. The parcel contains a set of high performance laptops for the team to use."
1919
},
2020
{
2121
"item": "Packaging and Shipping",
@@ -24,7 +24,7 @@
2424
"parcel_details": "a bottle of wine",
2525
"parcel_keywords": "bottle wine",
2626
"quantity": 1,
27-
"goal": "I need to do a External Address shipment. The package ships to 7972 Pines Boulevard, Pembroke Pines,FL. The parcel contains Packaging and Shipping."
27+
"goal": "I need to do a External Address shipment. The package ships to 7972 Pines Boulevard, Pembroke Pines,FL. The parcel contains a bottle of wine."
2828
},
2929
{
3030
"item": "Packaging and Shipping",
@@ -33,7 +33,7 @@
3333
"parcel_details": "a couple of Brother printers",
3434
"parcel_keywords": "Brother printer",
3535
"quantity": 1,
36-
"goal": "I need to do a External Address shipment. The package ships to SHS quadra 5, Bloco E., Brasilia. The parcel contains Packaging and Shipping."
36+
"goal": "I need to do a External Address shipment. The package ships to SHS quadra 5, Bloco E., Brasilia. The parcel contains a couple of Brother printers."
3737
},
3838
{
3939
"item": "Packaging and Shipping",
@@ -42,6 +42,6 @@
4242
"parcel_details": "a thank you note",
4343
"parcel_keywords": "thank you",
4444
"quantity": 1,
45-
"goal": "I need to do a External Address shipment. The package ships to Seybold, 36 Northeast 1st Street #407, Miami,FL. The parcel contains Packaging and Shipping."
45+
"goal": "I need to do a External Address shipment. The package ships to Seybold, 36 Northeast 1st Street #407, Miami,FL. The parcel contains a thank you note."
4646
}
4747
]

src/browsergym/workarena/tasks/service_catalog.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,10 @@ def _get_incident_short_description(self) -> str | None:
896896
},
897897
)
898898
response.raise_for_status()
899-
result = response.json().get("result", {})
900-
return result.get("short_description")
899+
result = response.json().get("result", [])
900+
if len(result) != 1:
901+
return None
902+
return result[0].get("short_description")
901903

902904
def _get_incident_work_notes(self) -> dict | None:
903905
# get incident work notes
@@ -914,7 +916,6 @@ def _get_incident_work_notes(self) -> dict | None:
914916
result = response.json().get("result", [])
915917
if len(result) != 1:
916918
return None
917-
918919
return result[0]["value"]
919920

920921
def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:
@@ -979,11 +980,12 @@ def _get_location(self, location_sys_id: str):
979980
)
980981
response.raise_for_status()
981982
result = response.json().get("result", [])
983+
if len(result) != 1:
984+
return None
982985
return result[0]["name"]
983986

984987
def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:
985988
requested_item = self._get_requested_item(page)
986-
print(requested_item)
987989
if requested_item is None:
988990
return 0, False, "", {"message": "The requested item is incorrect."}
989991

@@ -994,17 +996,22 @@ def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str
994996
return 0, False, "", {"message": "The requested quantity is incorrect."}
995997

996998
# validate values
997-
if not requested_item[self.FIELD_NAME_MAPPING["shipping_type"]].lower() == self.SHIPPING_TYPE_MAPPING[self.config["shipping_type"]].lower():
999+
if not requested_item["options"].get(self.FIELD_NAME_MAPPING["shipping_type"]).lower() == self.SHIPPING_TYPE_MAPPING[self.config["shipping_type"]].lower():
9981000
return 0, False, "", {"message": "The requested shipping type is incorrect."}
9991001

10001002
# for destination, we need to do a lookup
10011003
# TODO: for now we only look at the destination field, but we could also setup the postcode, city, address line 1/2, etc.
1002-
destination = self._get_location(requested_item[self.FIELD_NAME_MAPPING["destination"]])
1004+
destination = self._get_location(requested_item["options"].get(self.FIELD_NAME_MAPPING["destination"]))
1005+
if destination is None:
1006+
return 0, False, "", {"message": "The requested destination is incorrect."}
10031007
if not destination.lower() == self.config["destination"].lower():
10041008
return 0, False, "", {"message": "The requested destination is incorrect."}
10051009

1006-
for keyword in self.config["keywords"].split(" "):
1007-
if not keyword.lower() in requested_item[self.FIELD_NAME_MAPPING["parcel_details"]].lower():
1010+
parcel_details = requested_item["options"].get(self.FIELD_NAME_MAPPING["parcel_details"])
1011+
if parcel_details is None:
1012+
return 0, False, "", {"message": "The requested parcel details is incorrect."}
1013+
for keyword in self.config["parcel_keywords"].split(" "):
1014+
if not keyword.lower() in parcel_details.lower():
10081015
return 0, False, "", {"message": "The requested parcel details does not contain the expected keyword."}
10091016

10101017
return 1, True, "", {"message": "Task completed successfully."}
@@ -1030,11 +1037,11 @@ class OrderSoftwareAccessTask(OrderFromServiceCatalogTask):
10301037

10311038
def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str, dict]:
10321039
requested_item = self._get_requested_item(page)
1033-
print(requested_item)
10341040
if requested_item is None:
10351041
return 0, False, "", {"message": "The requested item is incorrect."}
10361042

1037-
if not requested_item["cat_item"]["display_value"].lower() == self.config["item"].lower():
1043+
# here the `item` field is the software name, but the catalog item contains more info (e.g. `Request Dropbox account`)
1044+
if not self.config["item"].lower() in requested_item["cat_item"]["display_value"].lower():
10381045
return 0, False, "", {"message": "The requested item is incorrect."}
10391046

10401047
if not requested_item["quantity"] == str(self.config["quantity"]):
@@ -1043,7 +1050,7 @@ def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str
10431050
# NOTE: we don't check for `requested for` field.
10441051

10451052
# business justification
1046-
if requested_item["options"]["Business justification"] != self.config["business_justification"]:
1053+
if requested_item["options"].get("Business justification", "") != self.config["business_justification"]:
10471054
return 0, False, "", {"message": "The requested business justification is incorrect."}
10481055

10491056
return 1, True, "", {"message": "Task completed successfully."}

0 commit comments

Comments
 (0)