Download baim/baseline.py from devildasdf/devils-agent: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/devildasdf/devils-agent/resolve/main/baim/baseline.py
- Command line
-
hf download hf://devildasdf/devils-agent/baim/baseline.py
-
curl -L -o baseline.py https://huggingface.co/devildasdf/devils-agent/resolve/main/baim/baseline.py
1.16 kB
| """Deterministic comparison baseline, explicitly not the proposed final agent.""" | |
| from dataclasses import asdict | |
| import re | |
| from .actions import Action,Decision,Kind | |
| from .features import candidates,lexical | |
| class LexicalRoleBaseline: | |
| def predict(self,goal,state,ticket): | |
| elements = [asdict(e) for e in state.elements] | |
| indices = candidates(goal,elements) | |
| if not indices: | |
| return Decision(ticket,Action(Kind.ASK_USER,('No candidate.',))) | |
| index = max(indices,key=lambda i:(lexical(goal,elements[i])[2],lexical(goal,elements[i])[0])) | |
| element = state.elements[index] | |
| if element.role in {'textbox','searchbox'}: | |
| kind = Kind.TYPE | |
| elif element.role in {'combobox','listbox'}: | |
| kind = Kind.SELECT | |
| else: | |
| kind = Kind.CLICK | |
| args = (element.ref,) | |
| if kind in {Kind.TYPE,Kind.SELECT}: | |
| values = re.findall(r'"([^"\n]*)"',goal) | |
| if len(values)!=1: | |
| return Decision(ticket,Action(Kind.ASK_USER,('No unambiguous literal.',))) | |
| args += (values[0],) | |
| return Decision(ticket,Action(kind,args)) | |