Query TextSynth API for completion. Retry with back-off until they respond.
(**kwargs)
| 26 | |
| 27 | |
| 28 | def textsynth_completion(**kwargs): |
| 29 | """Query TextSynth API for completion. |
| 30 | Retry with back-off until they respond. |
| 31 | """ |
| 32 | |
| 33 | def _exception_callback(e: Exception, sleep_time: float) -> None: |
| 34 | import traceback |
| 35 | |
| 36 | traceback.print_exc() |
| 37 | |
| 38 | @retry_on_specific_exceptions( |
| 39 | on_exceptions=[_requests.exceptions.RequestException], |
| 40 | max_retries=None, # retry forever, consider changing |
| 41 | on_exception_callback=_exception_callback, |
| 42 | ) |
| 43 | def completion(): |
| 44 | return _requests.post(**kwargs) |
| 45 | |
| 46 | return completion() |
| 47 | |
| 48 | |
| 49 | @register_model("textsynth") |
no test coverage detected