Internals
Lifecycle
Instructor’s request lifecycle
As Instructor for PHP processes your request, it goes through several stages:
- Initialize and self-configure (with possible overrides defined by developer).
- Analyze classes and properties of the response data model specified by developer.
- Translate data model into a schema that can be provided to LLM.
- Execute request to LLM using specified messages (content) and response model metadata.
- Receive a response from LLM or multiple partial responses (if streaming is enabled).
- Deserialize response received from LLM into originally requested classes and their properties.
- In case response contained unserializable data - create feedback message for LLM and request regeneration of the response.
- Execute validations defined by developer on the deserialized data - if any of them fail, create feedback message for LLM and requests regeneration of the response.
- Repeat the steps 4-8, unless specified limit of retries has been reached or response passes validation.