This repository was archived by the owner on Jul 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1313use PhpLlm \LlmChain \Platform \ResponseConverter ;
1414use Symfony \Component \HttpClient \Chunk \ServerSentEvent ;
1515use Symfony \Component \HttpClient \EventSourceHttpClient ;
16+ use Symfony \Component \HttpClient \Exception \JsonException ;
1617use Symfony \Contracts \HttpClient \HttpClientInterface ;
1718use Symfony \Contracts \HttpClient \ResponseInterface ;
1819use Webmozart \Assert \Assert ;
@@ -72,7 +73,12 @@ private function convertStream(ResponseInterface $response): \Generator
7273 continue ;
7374 }
7475
75- $ data = $ chunk ->getArrayData ();
76+ try {
77+ $ data = $ chunk ->getArrayData ();
78+ } catch (JsonException ) {
79+ // try catch only needed for Symfony 6.4
80+ continue ;
81+ }
7682
7783 if ('content_block_delta ' != $ data ['type ' ] || !isset ($ data ['delta ' ]['text ' ])) {
7884 continue ;
Original file line number Diff line number Diff line change 1717use PhpLlm \LlmChain \Platform \ResponseConverter as PlatformResponseConverter ;
1818use Symfony \Component \HttpClient \Chunk \ServerSentEvent ;
1919use Symfony \Component \HttpClient \EventSourceHttpClient ;
20+ use Symfony \Component \HttpClient \Exception \JsonException ;
2021use Symfony \Contracts \HttpClient \ResponseInterface as HttpResponse ;
2122
2223final class ResponseConverter implements PlatformResponseConverter
@@ -70,7 +71,12 @@ private function streamResponse(HttpResponse $response): \Generator
7071 continue ;
7172 }
7273
73- yield $ chunk ->getArrayData ();
74+ try {
75+ yield $ chunk ->getArrayData ();
76+ } catch (JsonException ) {
77+ // try catch only needed for Symfony 6.4
78+ continue ;
79+ }
7480 }
7581 }
7682
You can’t perform that action at this time.
0 commit comments