This repository was archived by the owner on Jul 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/Chain/StructuredOutput Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1111use PhpLlm \LlmChain \Exception \InvalidArgumentException ;
1212use PhpLlm \LlmChain \Exception \MissingModelSupport ;
1313use PhpLlm \LlmChain \Model \Response \StructuredResponse ;
14+ use Symfony \Component \PropertyInfo \Extractor \PhpDocExtractor ;
15+ use Symfony \Component \PropertyInfo \PropertyInfoExtractor ;
1416use Symfony \Component \Serializer \Encoder \JsonEncoder ;
17+ use Symfony \Component \Serializer \Normalizer \ArrayDenormalizer ;
1518use Symfony \Component \Serializer \Normalizer \ObjectNormalizer ;
1619use Symfony \Component \Serializer \Serializer ;
1720use Symfony \Component \Serializer \SerializerInterface ;
@@ -24,7 +27,11 @@ public function __construct(
2427 private readonly ResponseFormatFactoryInterface $ responseFormatFactory = new ResponseFormatFactory (),
2528 private ?SerializerInterface $ serializer = null ,
2629 ) {
27- $ this ->serializer = $ serializer ?? new Serializer ([new ObjectNormalizer ()], [new JsonEncoder ()]);
30+ if (null === $ this ->serializer ) {
31+ $ propertyInfo = new PropertyInfoExtractor ([], [new PhpDocExtractor ()]);
32+ $ normalizers = [new ObjectNormalizer (propertyTypeExtractor: $ propertyInfo ), new ArrayDenormalizer ()];
33+ $ this ->serializer = $ serializer ?? new Serializer ($ normalizers , [new JsonEncoder ()]);
34+ }
2835 }
2936
3037 public function processInput (Input $ input ): void
You can’t perform that action at this time.
0 commit comments