Polyglot \ Internals
Events System
Learn about the events system in Polyglot.
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.
Copy
namespace Cognesy\Utils\Events;
class EventDispatcher {
public function dispatch(Event $event): void { ... }
public function listen(string $eventClass, callable $listener): self { ... }
public function remove(string $eventClass, callable $listener): self { ... }
public function clear(string $eventClass = ''): self { ... }
}
namespace Cognesy\Polyglot\LLM\Events;
class LLMResponseReceived extends Event {
public function __construct(
public LLMResponse $llmResponse
) { ... }
}
class InferenceRequested extends Event {
public function __construct(
public InferenceRequest $request
) { ... }
}
class PartialLLMResponseReceived extends Event {
public function __construct(
public PartialLLMResponse $partialLLMResponse
) { ... }
}
Assistant
Responses are generated using AI and may contain mistakes.