Event
class.
You can listen to these events and react to them in your application, for example to log information or to monitor the execution process.
Check the list of available event classes in the Cognesy\Instructor\Events
namespace.
print()
- prints a string representation of the event to console outputprintDebug()
- prints a string representation of the event to console output, with additional debug informationasConsole()
- returns the event in a format suitable for console outputasLog()
- returns the event in a format suitable for logging(new StructuredOutput)->onEvent(string $class, callable $callback)
method - receive callback when specified type of event is dispatched(new StructuredOutput)->wiretap(callable $callback)
method - receive any event dispatched by Instructor, may be useful for debugging or performance analysisStructuredOutput
class provides convenience methods allowing client code to receive
model updates when streaming is enabled:
onPartialUpdate(callable $callback)
- to handle partial model updates of the responseonSequenceUpdate(callable $callback)
- to handle partial sequence updates of the response