File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 13
13
use PhpLlm \LlmChain \Platform \ResponseConverter ;
14
14
use Symfony \Component \HttpClient \Chunk \ServerSentEvent ;
15
15
use Symfony \Component \HttpClient \EventSourceHttpClient ;
16
+ use Symfony \Component \HttpClient \Exception \JsonException ;
16
17
use Symfony \Contracts \HttpClient \HttpClientInterface ;
17
18
use Symfony \Contracts \HttpClient \ResponseInterface ;
18
19
use Webmozart \Assert \Assert ;
@@ -72,7 +73,12 @@ private function convertStream(ResponseInterface $response): \Generator
72
73
continue ;
73
74
}
74
75
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
+ }
76
82
77
83
if ('content_block_delta ' != $ data ['type ' ] || !isset ($ data ['delta ' ]['text ' ])) {
78
84
continue ;
Original file line number Diff line number Diff line change 17
17
use PhpLlm \LlmChain \Platform \ResponseConverter as PlatformResponseConverter ;
18
18
use Symfony \Component \HttpClient \Chunk \ServerSentEvent ;
19
19
use Symfony \Component \HttpClient \EventSourceHttpClient ;
20
+ use Symfony \Component \HttpClient \Exception \JsonException ;
20
21
use Symfony \Contracts \HttpClient \ResponseInterface as HttpResponse ;
21
22
22
23
final class ResponseConverter implements PlatformResponseConverter
@@ -70,7 +71,12 @@ private function streamResponse(HttpResponse $response): \Generator
70
71
continue ;
71
72
}
72
73
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
+ }
74
80
}
75
81
}
76
82
You can’t perform that action at this time.
0 commit comments