Download appendix/code/contract.py from BradJu/attribute-ownership-negative-experiments: direct link, hf CLI and curl.
- Browser
- Download file 3.5 kB
-
https://huggingface.co/datasets/BradJu/attribute-ownership-negative-experiments/resolve/main/appendix/code/contract.py
- Command line
-
hf download hf://datasets/BradJu/attribute-ownership-negative-experiments/appendix/code/contract.py
-
curl -L -o contract.py https://huggingface.co/datasets/BradJu/attribute-ownership-negative-experiments/resolve/main/appendix/code/contract.py
3.5 kB
| """Unrun prompt candidate. Reuses the frozen validator; never replaces old prompts.""" | |
| import json | |
| import environment as frozen | |
| Shop = frozen.Shop | |
| def prompt(row): | |
| return json.dumps({ | |
| 'contract_version': 'local-v2-unrun', | |
| 'instruction': 'Return exactly one JSON object with tool and arguments, no other text. ' | |
| 'Each tool requires exactly the keys listed below. Maximum five calls; ' | |
| 'invalid calls fail immediately, without repair or retry. ' | |
| 'Complete with propose_item or route_service; those end the episode.', | |
| 'tools': { | |
| 'search_catalog': {'required': frozen.TOOLS['search_catalog'], | |
| 'rules': 'query must equal task.target exactly, not a rewritten search phrase. ' | |
| 'filters must be an object, either empty or containing only task.field ' | |
| 'with a string value. Matching is exact; preserve material qualifiers. ' | |
| 'Returns items with id, the queried attribute, and fits.'}, | |
| 'check_fit': {'required': frozen.TOOLS['check_fit'], | |
| 'rules': 'item_ids must be a nonempty list of IDs from the most recent search. ' | |
| 'reference_width must be a string describing the reference footwear width. ' | |
| 'Returns compatible_ids. Do not invent IDs.'}, | |
| 'ask_clarification': {'required': frozen.TOOLS['ask_clarification'], | |
| 'rules': 'field must equal task.field exactly; question must be a nonempty string. ' | |
| 'Returns answer.required (boolean) and answer.value (string).'}, | |
| 'route_service': {'required': frozen.TOOLS['route_service'], | |
| 'rules': 'intent must be repair, return, or advice; target must equal task.target exactly. ' | |
| 'Ends the episode.'}, | |
| 'propose_item': {'required': frozen.TOOLS['propose_item'], | |
| 'rules': 'item_id must be an ID from the most recent search; never invent one. ' | |
| 'For compatibility tasks choose from check_fit compatible_ids. Ends the episode.'}}, | |
| 'workflow_rules': [ | |
| 'Only handle the supplied target and queried field; do not add other product constraints.', | |
| 'For an explicit requirement, search once with that field/value filter, then propose an item. Do not ask.', | |
| 'If inheritance of an old item attribute is unclear, ask once BEFORE searching. If required is true, ' | |
| 'filter by answer.value; otherwise use empty filters. Then propose an item.', | |
| 'No requirement means empty filters, not prohibition of the mentioned value. Do not use any as a value.', | |
| 'For a reference footwear compatibility requirement, search once with empty filters, ' | |
| 'check_fit once, then propose a compatible item. Do not treat reference width as the new item width.', | |
| 'For repair, return or advice about the target, route_service only; do not shop.', | |
| 'If the queried field is absent or outside its field_meaning, search with empty filters; do not ask.', | |
| 'For purchase success this benchmark requires exactly one search and no unnecessary clarification or fit calls.', | |
| 'An empty catalog result has no valid proposal; there is no recovery/abstention tool in this benchmark.' | |
| ], | |
| 'task': row['input'], | |
| }, sort_keys=True) | |