@@ -77,7 +77,7 @@ public function getName(): string
7777 public function call (MessageBag $ messages , array $ options = []): ResultInterface
7878 {
7979 $ input = new Input ($ this ->getModel (), $ messages , $ options );
80- array_map (fn (InputProcessorInterface $ processor ) => $ processor ->processInput ($ input ), $ this ->inputProcessors );
80+ array_map (static fn (InputProcessorInterface $ processor ) => $ processor ->processInput ($ input ), $ this ->inputProcessors );
8181
8282 $ model = $ input ->getModel ();
8383 $ messages = $ input ->getMessageBag ();
@@ -86,7 +86,7 @@ public function call(MessageBag $messages, array $options = []): ResultInterface
8686 $ result = $ this ->platform ->invoke ($ model , $ messages , $ options )->getResult ();
8787
8888 $ output = new Output ($ model , $ result , $ messages , $ options );
89- array_map (fn (OutputProcessorInterface $ processor ) => $ processor ->processOutput ($ output ), $ this ->outputProcessors );
89+ array_map (static fn (OutputProcessorInterface $ processor ) => $ processor ->processOutput ($ output ), $ this ->outputProcessors );
9090 array_map (static fn (VoiceProviderInterface $ provider ) => $ provider ->addVoice ($ output ), $ this ->voiceProviders );
9191
9292 return $ output ->getResult ();
@@ -116,14 +116,18 @@ private function initializeProcessors(iterable $processors, string $interface):
116116 /**
117117 * @param VoiceProviderInterface[] $providers
118118 *
119- * @return InputProcessorInterface[]|OutputProcessorInterface []
119+ * @return VoiceProviderInterface []
120120 */
121121 private function initializeVoiceProviders (iterable $ providers ): array
122122 {
123123 foreach ($ providers as $ provider ) {
124124 if (!$ provider instanceof VoiceProviderInterface) {
125125 throw new InvalidArgumentException (\sprintf ('Voice provider "%s" must implement "%s". ' , $ provider ::class, VoiceProviderInterface::class));
126126 }
127+
128+ if ($ provider instanceof AgentAwareInterface) {
129+ $ provider ->setAgent ($ this );
130+ }
127131 }
128132
129133 return $ providers instanceof \Traversable ? iterator_to_array ($ providers ) : $ providers ;
0 commit comments