@@ -31,8 +31,11 @@ protected function mapResponse(MessageResponse $message): ChatResult
3131 $ finishReason = $ this ->mapFinishReason ($ message ->stopReason );
3232 $ meta = $ message ->getMeta ();
3333
34- $ toolCalls = collect ($ message ->content )
35- ->filter (fn (object $ content ): bool => $ content instanceof ToolUseContentBlock)
34+ /** @var \Illuminate\Support\Collection<int, \Cortex\SDK\Anthropic\Contracts\ContentBlock> $contentCollection */
35+ $ contentCollection = collect ($ message ->content );
36+ /** @var \Illuminate\Support\Collection<int, ToolUseContentBlock> $toolUseBlocks */
37+ $ toolUseBlocks = $ contentCollection ->filter (fn (object $ content ): bool => $ content instanceof ToolUseContentBlock);
38+ $ toolCalls = $ toolUseBlocks
3639 ->map (function (ToolUseContentBlock $ content ): ToolCall {
3740 return new ToolCall (
3841 $ content ->id ,
@@ -56,11 +59,11 @@ protected function mapResponse(MessageResponse $message): ChatResult
5659 finishReason: $ finishReason ,
5760 usage: $ usage ,
5861 processingTime: $ meta ?->processingTime,
59- providerMetadata: $ meta? ->raw ?? [],
62+ providerMetadata: $ meta ->raw ?? [],
6063 ),
6164 id: $ message ->id ,
6265 ),
63- createdAt: $ meta? ->createdAt ?? new DateTimeImmutable (),
66+ createdAt: $ meta ->createdAt ?? new DateTimeImmutable (),
6467 finishReason: $ finishReason ,
6568 );
6669
@@ -78,6 +81,11 @@ protected function mapResponse(MessageResponse $message): ChatResult
7881 );
7982 }
8083
84+ /**
85+ * @param array<int, \Cortex\SDK\Anthropic\Contracts\ContentBlock> $content
86+ *
87+ * @return array<int, \Cortex\LLM\Data\Messages\Content\TextContent|\Cortex\LLM\Data\Messages\Content\ReasoningContent>
88+ */
8189 protected function mapContent (array $ content ): array
8290 {
8391 return collect ($ content )
0 commit comments