Skip to content

Commit 25a8232

Browse files
committed
fixes
1 parent 4e0ee83 commit 25a8232

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/Agents/Conversation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
{

src/Agents/Message.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

src/Agents/Messages/Image.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
{

src/Agents/Messages/Text.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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
{

tests/Agents/ConversationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
{

0 commit comments

Comments
 (0)