| 561 | return response.choices[0].text |
| 562 | |
| 563 | def run_cmd(cmd): |
| 564 | cmd = cmd.split("\n")[0] |
| 565 | |
| 566 | if cmd.startswith("SCROLL UP"): |
| 567 | _crawler.scroll("up") |
| 568 | elif cmd.startswith("SCROLL DOWN"): |
| 569 | _crawler.scroll("down") |
| 570 | elif cmd.startswith("CLICK"): |
| 571 | commasplit = cmd.split(",") |
| 572 | id = commasplit[0].split(" ")[1] |
| 573 | _crawler.click(id) |
| 574 | elif cmd.startswith("TYPE"): |
| 575 | spacesplit = cmd.split(" ") |
| 576 | id = spacesplit[1] |
| 577 | text = spacesplit[2:] |
| 578 | text = " ".join(text) |
| 579 | # Strip leading and trailing double quotes |
| 580 | text = text[1:-1] |
| 581 | |
| 582 | if cmd.startswith("TYPESUBMIT"): |
| 583 | text += '\n' |
| 584 | _crawler.type(id, text) |
| 585 | |
| 586 | time.sleep(2) |
| 587 | |
| 588 | objective = "Make a reservation for 2 at 7pm at bistro vida in menlo park" |
| 589 | print("\nWelcome to natbot! What is your objective?") |