File size: 1,302 Bytes
c72da75 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | """Exact historical gate prompt and decoding contract."""
RULES='''Return exactly YES, FIT, NO, or UNSURE. YES: the requested item itself must have the mentioned field value. FIT: width describes reference footwear or feet that the requested insert must fit, not the insert itself. NO: the value concerns another object, is explicitly rejected for the new item, or the request is repair/return. UNSURE: inheritance from an old item or ownership is unresolved. Do not assume an old item attribute carries over. Explicit inheritance is YES. Standard/regular width of the requested item is YES. Only width can be FIT. Explicitly not requiring an attribute is NO: no positive filter, not a prohibition of that value.'''
VALUES={'color':['red','blue','black','gray'], 'material':['nylon','cotton','foam'], 'width':['extra-wide','narrow','standard','wide']}
def messages(request):
import json
return [{'role':'system','content':RULES},{'role':'user','content':json.dumps({k:request[k] for k in ('text','target','field')},ensure_ascii=False)}]
def decision(request,output):
gate=output.strip()
if gate not in {'YES','NO','FIT','UNSURE'}:raise ValueError('invalid gate output')
if gate=='FIT' and request['field']!='width':raise ValueError('FIT only supports width')
return {'gate':gate,'value':None}
|