File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function listen(callable $listener): self
4848 /**
4949 * Add a message to the conversation
5050 *
51- * @param array<Message > $attachments
51+ * @param array<int, mixed > $attachments
5252 */
5353 public function message (Role $ from , Message $ message , array $ attachments = []): self
5454 {
@@ -201,7 +201,7 @@ public function getTotalTokens(): int
201201 }
202202
203203 /**
204- * @param array<Message > $attachments
204+ * @param array<int, mixed > $attachments
205205 */
206206 protected function validateAttachments (Message $ message , array $ attachments ): void
207207 {
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ abstract class Message
1515
1616 /**
1717 * Create a new message
18+ *
19+ * @param array<int, mixed> $attachments
1820 */
1921 public function __construct (string $ content , ?string $ role = null , array $ attachments = [])
2022 {
@@ -62,13 +64,13 @@ public function addAttachment(Message $attachment): self
6264 }
6365
6466 /**
65- * @param array<Message > $attachments
67+ * @param array<int, mixed > $attachments
6668 */
6769 public function setAttachments (array $ attachments ): self
6870 {
6971 $ this ->attachments = [];
7072 foreach ($ attachments as $ attachment ) {
71- if (! $ attachment instanceof self ) {
73+ if (! $ attachment instanceof Message ) {
7274 throw new \InvalidArgumentException ('Attachments must be Message instances ' );
7375 }
7476 $ this ->attachments [] = $ attachment ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class Image extends Message
1010 * Create a new image message
1111 *
1212 * @param string $content Binary content of the image
13+ * @param array<int, mixed> $attachments
1314 */
1415 public function __construct (string $ content , ?string $ role = null , array $ attachments = [])
1516 {
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ class Text extends Message
88{
99 /**
1010 * Create a new text message
11+ *
12+ * @param array<int, mixed> $attachments
1113 */
1214 public function __construct (string $ content , ?string $ role = null , array $ attachments = [])
1315 {
Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ public function testSendPassesAttachmentsToAdapter(): void
4848 ->send ();
4949
5050 $ this ->assertNotNull ($ adapter ->lastSentMessage );
51- $ this ->assertCount (1 , $ adapter ->lastSentMessage ?->getAttachments() ?? []);
51+ $ this ->assertInstanceOf (Message::class, $ adapter ->lastSentMessage );
52+ $ this ->assertCount (1 , $ adapter ->lastSentMessage ->getAttachments ());
5253 }
5354
5455 public function testRejectsTooManyAttachments (): void
@@ -153,8 +154,7 @@ class ConversationFakeAdapter extends Adapter
153154 public function __construct (
154155 private readonly string $ response ,
155156 private readonly bool $ supportsImageAttachments = true
156- ) {
157- }
157+ ) {}
158158
159159 public function supportsAttachments (): bool
160160 {
You can’t perform that action at this time.
0 commit comments