File tree Expand file tree Collapse file tree 10 files changed +71
-11
lines changed Expand file tree Collapse file tree 10 files changed +71
-11
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \AI \Platform \Message ;
13
13
14
14
use Symfony \AI \Platform \Response \ToolCall ;
15
+ use Symfony \Component \Uid \AbstractUid ;
16
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
15
17
use Symfony \Component \Uid \Uuid ;
16
18
17
19
/**
18
20
* @author Denis Zunke <[email protected] >
19
21
*/
20
22
final readonly class AssistantMessage implements MessageInterface
21
23
{
22
- public Uuid $ id ;
24
+ public AbstractUid & TimeBasedUidInterface $ id ;
23
25
24
26
/**
25
27
* @param ?ToolCall[] $toolCalls
@@ -36,7 +38,7 @@ public function getRole(): Role
36
38
return Role::Assistant;
37
39
}
38
40
39
- public function getId (): Uuid
41
+ public function getId (): AbstractUid & TimeBasedUidInterface
40
42
{
41
43
return $ this ->id ;
42
44
}
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \AI \Platform \Message ;
13
13
14
- use Symfony \Component \Uid \Uuid ;
14
+ use Symfony \Component \Uid \AbstractUid ;
15
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
15
16
16
17
/**
17
18
* @author Denis Zunke <[email protected] >
@@ -20,5 +21,5 @@ interface MessageInterface
20
21
{
21
22
public function getRole (): Role ;
22
23
23
- public function getId (): Uuid ;
24
+ public function getId (): AbstractUid & TimeBasedUidInterface ;
24
25
}
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \AI \Platform \Message ;
13
13
14
+ use Symfony \Component \Uid \AbstractUid ;
15
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
14
16
use Symfony \Component \Uid \Uuid ;
15
17
16
18
/**
17
19
* @author Denis Zunke <[email protected] >
18
20
*/
19
21
final readonly class SystemMessage implements MessageInterface
20
22
{
21
- public Uuid $ id ;
23
+ public AbstractUid & TimeBasedUidInterface $ id ;
22
24
23
25
public function __construct (public string $ content )
24
26
{
@@ -30,7 +32,7 @@ public function getRole(): Role
30
32
return Role::System;
31
33
}
32
34
33
- public function getId (): Uuid
35
+ public function getId (): AbstractUid & TimeBasedUidInterface
34
36
{
35
37
return $ this ->id ;
36
38
}
Original file line number Diff line number Diff line change 12
12
namespace Symfony \AI \Platform \Message ;
13
13
14
14
use Symfony \AI \Platform \Response \ToolCall ;
15
+ use Symfony \Component \Uid \AbstractUid ;
16
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
15
17
use Symfony \Component \Uid \Uuid ;
16
18
17
19
/**
18
20
* @author Denis Zunke <[email protected] >
19
21
*/
20
22
final readonly class ToolCallMessage implements MessageInterface
21
23
{
22
- public Uuid $ id ;
24
+ public AbstractUid & TimeBasedUidInterface $ id ;
23
25
24
26
public function __construct (
25
27
public ToolCall $ toolCall ,
@@ -33,7 +35,7 @@ public function getRole(): Role
33
35
return Role::ToolCall;
34
36
}
35
37
36
- public function getId (): Uuid
38
+ public function getId (): AbstractUid & TimeBasedUidInterface
37
39
{
38
40
return $ this ->id ;
39
41
}
Original file line number Diff line number Diff line change 15
15
use Symfony \AI \Platform \Message \Content \ContentInterface ;
16
16
use Symfony \AI \Platform \Message \Content \Image ;
17
17
use Symfony \AI \Platform \Message \Content \ImageUrl ;
18
+ use Symfony \Component \Uid \AbstractUid ;
19
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
18
20
use Symfony \Component \Uid \Uuid ;
19
21
20
22
/**
27
29
*/
28
30
public array $ content ;
29
31
30
- public Uuid $ id ;
32
+ public AbstractUid & TimeBasedUidInterface $ id ;
31
33
32
34
public function __construct (
33
35
ContentInterface ...$ content ,
@@ -41,7 +43,7 @@ public function getRole(): Role
41
43
return Role::User;
42
44
}
43
45
44
- public function getId (): Uuid
46
+ public function getId (): AbstractUid & TimeBasedUidInterface
45
47
{
46
48
return $ this ->id ;
47
49
}
Original file line number Diff line number Diff line change 42
42
use Symfony \AI \Platform \Message \SystemMessage ;
43
43
use Symfony \AI \Platform \Message \UserMessage ;
44
44
use Symfony \AI \Platform \Model ;
45
+ use Symfony \Component \Uid \AbstractUid ;
46
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
45
47
use Symfony \Component \Uid \Uuid ;
46
48
47
49
#[Large]
@@ -208,7 +210,7 @@ public function getRole(): Role
208
210
return Role::User;
209
211
}
210
212
211
- public function getId (): Uuid
213
+ public function getId (): AbstractUid & TimeBasedUidInterface
212
214
{
213
215
return Uuid::v7 ();
214
216
}
Original file line number Diff line number Diff line change 20
20
use Symfony \AI \Platform \Message \Role ;
21
21
use Symfony \AI \Platform \Response \ToolCall ;
22
22
use Symfony \AI \Platform \Tests \Helper \UuidAssertionTrait ;
23
+ use Symfony \Component \Uid \AbstractUid ;
24
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
23
25
use Symfony \Component \Uid \UuidV7 ;
24
26
25
27
#[CoversClass(AssistantMessage::class)]
@@ -86,4 +88,14 @@ public function sameMessagesHaveDifferentUids(): void
86
88
self ::assertIsUuidV7 ($ message1 ->getId ()->toRfc4122 ());
87
89
self ::assertIsUuidV7 ($ message2 ->getId ()->toRfc4122 ());
88
90
}
91
+
92
+ #[Test]
93
+ public function messageIdImplementsRequiredInterfaces (): void
94
+ {
95
+ $ message = new AssistantMessage ('test ' );
96
+
97
+ self ::assertInstanceOf (AbstractUid::class, $ message ->getId ());
98
+ self ::assertInstanceOf (TimeBasedUidInterface::class, $ message ->getId ());
99
+ self ::assertInstanceOf (UuidV7::class, $ message ->getId ());
100
+ }
89
101
}
Original file line number Diff line number Diff line change 18
18
use Symfony \AI \Platform \Message \Role ;
19
19
use Symfony \AI \Platform \Message \SystemMessage ;
20
20
use Symfony \AI \Platform \Tests \Helper \UuidAssertionTrait ;
21
+ use Symfony \Component \Uid \AbstractUid ;
22
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
21
23
use Symfony \Component \Uid \UuidV7 ;
22
24
23
25
#[CoversClass(SystemMessage::class)]
@@ -66,4 +68,14 @@ public function sameMessagesHaveDifferentUids(): void
66
68
self ::assertIsUuidV7 ($ message1 ->getId ()->toRfc4122 ());
67
69
self ::assertIsUuidV7 ($ message2 ->getId ()->toRfc4122 ());
68
70
}
71
+
72
+ #[Test]
73
+ public function messageIdImplementsRequiredInterfaces (): void
74
+ {
75
+ $ message = new SystemMessage ('test ' );
76
+
77
+ self ::assertInstanceOf (AbstractUid::class, $ message ->getId ());
78
+ self ::assertInstanceOf (TimeBasedUidInterface::class, $ message ->getId ());
79
+ self ::assertInstanceOf (UuidV7::class, $ message ->getId ());
80
+ }
69
81
}
Original file line number Diff line number Diff line change 19
19
use Symfony \AI \Platform \Message \ToolCallMessage ;
20
20
use Symfony \AI \Platform \Response \ToolCall ;
21
21
use Symfony \AI \Platform \Tests \Helper \UuidAssertionTrait ;
22
+ use Symfony \Component \Uid \AbstractUid ;
23
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
22
24
use Symfony \Component \Uid \UuidV7 ;
23
25
24
26
#[CoversClass(ToolCallMessage::class)]
@@ -72,4 +74,15 @@ public function sameMessagesHaveDifferentUids(): void
72
74
self ::assertIsUuidV7 ($ message1 ->getId ()->toRfc4122 ());
73
75
self ::assertIsUuidV7 ($ message2 ->getId ()->toRfc4122 ());
74
76
}
77
+
78
+ #[Test]
79
+ public function messageIdImplementsRequiredInterfaces (): void
80
+ {
81
+ $ toolCall = new ToolCall ('foo ' , 'bar ' );
82
+ $ message = new ToolCallMessage ($ toolCall , 'test ' );
83
+
84
+ self ::assertInstanceOf (AbstractUid::class, $ message ->getId ());
85
+ self ::assertInstanceOf (TimeBasedUidInterface::class, $ message ->getId ());
86
+ self ::assertInstanceOf (UuidV7::class, $ message ->getId ());
87
+ }
75
88
}
Original file line number Diff line number Diff line change 22
22
use Symfony \AI \Platform \Message \Role ;
23
23
use Symfony \AI \Platform \Message \UserMessage ;
24
24
use Symfony \AI \Platform \Tests \Helper \UuidAssertionTrait ;
25
+ use Symfony \Component \Uid \AbstractUid ;
26
+ use Symfony \Component \Uid \TimeBasedUidInterface ;
25
27
use Symfony \Component \Uid \UuidV7 ;
26
28
27
29
#[CoversClass(UserMessage::class)]
@@ -116,4 +118,14 @@ public function sameMessagesHaveDifferentUids(): void
116
118
self ::assertIsUuidV7 ($ message1 ->getId ()->toRfc4122 ());
117
119
self ::assertIsUuidV7 ($ message2 ->getId ()->toRfc4122 ());
118
120
}
121
+
122
+ #[Test]
123
+ public function messageIdImplementsRequiredInterfaces (): void
124
+ {
125
+ $ message = new UserMessage (new Text ('test ' ));
126
+
127
+ self ::assertInstanceOf (AbstractUid::class, $ message ->getId ());
128
+ self ::assertInstanceOf (TimeBasedUidInterface::class, $ message ->getId ());
129
+ self ::assertInstanceOf (UuidV7::class, $ message ->getId ());
130
+ }
119
131
}
You can’t perform that action at this time.
0 commit comments