-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMessage.php
More file actions
43 lines (35 loc) · 878 Bytes
/
Message.php
File metadata and controls
43 lines (35 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Claude\Claude3Api\Models;
use Claude\Claude3Api\Models\Content\ContentInterface;
class Message
{
private string $role;
private array $content;
public function __construct(string $role, array $content = [])
{
$this->role = $role;
$this->content = $content;
}
public function addContent(ContentInterface $content): self
{
$this->content[] = $content;
return $this;
}
public function toArray(): array
{
return [
'role' => $this->role,
'content' => array_map(function (ContentInterface $content) {
return $content->toArray();
}, $this->content),
];
}
public function getRole(): string
{
return $this->role;
}
public function getContent(): array
{
return $this->content;
}
}