(session: Session, prompt_template, max_attempts=20)
| 13 | |
| 14 | |
| 15 | def fetch_data(session: Session, prompt_template, max_attempts=20): |
| 16 | for attempt in range(max_attempts): |
| 17 | try: |
| 18 | output = session.action(prompt_template) |
| 19 | assert output is not None |
| 20 | return output |
| 21 | except AssertionError: |
| 22 | print(f"Output is None! Retrying...({attempt + 1}/{max_attempts})") |
| 23 | time.sleep(3) |
| 24 | raise RuntimeError("Failed to fetch data after several attempts") |
| 25 | |
| 26 | class Mind2Web(Task): |
| 27 | def __init__(self, **config): |