(*args, **kwargs)
| 8 | |
| 9 | def retry_wrapper(func): |
| 10 | def wrapper(*args, **kwargs): |
| 11 | max_tries = 5 |
| 12 | tries = 0 |
| 13 | while tries < max_tries: |
| 14 | result = func(*args, **kwargs) |
| 15 | if result: |
| 16 | return result |
| 17 | print("Invalid response from the model, I'm trying again...") |
| 18 | emit_agent("info", {"type": "warning", "message": "Invalid response from the model, trying again..."}) |
| 19 | tries += 1 |
| 20 | time.sleep(2) |
| 21 | print("Maximum 5 attempts reached. try other models") |
| 22 | emit_agent("info", {"type": "error", "message": "Maximum attempts reached. model keeps failing."}) |
| 23 | sys.exit(1) |
| 24 | |
| 25 | return False |
| 26 | return wrapper |
| 27 | |
| 28 |
nothing calls this directly
no test coverage detected