Skip to content

Commit f340e0d

Browse files
committed
Added basic StructuredContent and error passing
1 parent fe8d981 commit f340e0d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Schema/Content/StructuredContent.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
class StructuredContent extends Content
1515
{
16+
/**
17+
* @param mixed[] $data
18+
*/
1619
public function __construct(
1720
private array $data = [],
1821
) {

src/Schema/Result/CallToolResult.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function error(array $content, ?StructuredContent $structuredConte
8181
}
8282

8383
/**
84-
* @param array<int, TextContentData|ImageContentData|AudioContentData|EmbeddedResourceData|StructuredContent> $data
84+
* @param array<int, TextContent|ImageContent|AudioContent|EmbeddedResource|StructuredContent> $data
8585
*/
8686
public static function fromArray(array $data): self
8787
{
@@ -97,7 +97,7 @@ public static function fromArray(array $data): self
9797
$structuredContent = $item;
9898
continue;
9999
}
100-
$contents[] = match ($item->type ?? null) {
100+
$contents[] = match ($item->type) {
101101
// TODO this should be enum, also `resource_link` missing.
102102
// We shouldn't rely on user input for type and just use instanceof instead
103103
'text', 'audio', 'image', 'resource' => $item,
@@ -114,8 +114,8 @@ public static function fromArray(array $data): self
114114

115115
/**
116116
* @return array{
117-
* content: array<TextContent|ImageContent|AudioContent|EmbeddedResource>,
118-
* structuredContent?: StructuredContent,
117+
* content: array<TextContentData|ImageContentData|AudioContentData|EmbeddedResourceData>,
118+
* structuredContent?: mixed[],
119119
* isError: bool,
120120
* }
121121
*/

0 commit comments

Comments
 (0)