Constructor.
Parameters
$registryWordPressAiClientProvidersProviderRegistryrequired- The provider registry for finding suitable models.
$promptWordPressAiClientBuildersPromptoptional- Optional initial prompt content.
Default:
null $eventDispatcherWordPressAiClientDependenciesPsrEventDispatcherEventDispatcherInterface|nulloptional- Optional event dispatcher for lifecycle events.
Default:
null
Source
public function __construct(ProviderRegistry $registry, $prompt = null, ?EventDispatcherInterface $eventDispatcher = null)
{
$this->registry = $registry;
$this->modelConfig = new ModelConfig();
$this->eventDispatcher = $eventDispatcher;
if ($prompt === null) {
return;
}
// Check if it's a list of Messages - set as messages
if ($this->isMessagesList($prompt)) {
$this->messages = $prompt;
return;
}
// Parse it as a user message
$userMessage = $this->parseMessage($prompt, MessageRoleEnum::user());
$this->messages[] = $userMessage;
}
Changelog
| Version | Description |
|---|---|
| 0.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.