Enable automatic retries for self-correction
mainTo enable the self-correction loop, you must set the max_retries parameter in the instructor.chat.completions.create method.
- If
max_retries: 0: The request will fail immediately if validation (includingLLMValidator) fails, throwing aZodError. - If
max_retries > 0:instructorwill catch the validation error, include the error message in a new prompt to the LLM, and attempt to generate a corrected response up to the specified number of times.