Polyglot uses an event system to generate internal notifications at the various stages of the execution process.

It has been built primarily to ensure observability of the internal components of the library.

namespace Cognesy\Utils\Events;

use Cognesy\Events\Event;

class EventDispatcher {
    public function dispatch(Event $event): void { ... }
    public function wiretap(callable $listener): self { ... }
    public function addListener(string $eventClass, callable $listener): self { ... }
}

namespace Cognesy\Polyglot\Inference\Events;

class InferenceResponseReceived extends Event {}

class InferenceRequested extends Event {}

class PartialInferenceResponseReceived extends Event {}