55namespace LLM \Agents \JsonSchema \Mapper \Integration \Spiral ;
66
77use CuyZ \Valinor \Cache \FileSystemCache ;
8- use CuyZ \Valinor \Mapper \TreeMapper ;
98use LLM \Agents \JsonSchema \Mapper \MapperBuilder ;
109use LLM \Agents \JsonSchema \Mapper \SchemaMapper ;
1110use LLM \Agents \Tool \SchemaMapperInterface ;
1211use Spiral \Boot \Bootloader \Bootloader ;
1312use Spiral \Boot \DirectoriesInterface ;
1413use Spiral \Boot \Environment \AppEnvironment ;
14+ use Spiral \JsonSchemaGenerator \Generator ;
1515
1616final class SchemaMapperBootloader extends Bootloader
1717{
1818 public function defineSingletons (): array
1919 {
2020 return [
21- SchemaMapperInterface::class => SchemaMapper::class,
22-
23- TreeMapper::class => static fn (
24- MapperBuilder $ builder ,
25- ) => $ builder ->build (),
26- MapperBuilder::class => static fn (
21+ SchemaMapperInterface::class => static function (
2722 DirectoriesInterface $ dirs ,
2823 AppEnvironment $ env ,
29- ) => new MapperBuilder (
30- cache: match ($ env ) {
31- AppEnvironment::Production => new FileSystemCache (
32- cacheDir: $ dirs ->get ('runtime ' ) . 'cache/valinor ' ,
33- ),
34- default => null ,
35- },
36- ),
24+ Generator $ generator ,
25+ ) {
26+ $ mapper = (new MapperBuilder (
27+ cache: match ($ env ) {
28+ AppEnvironment::Production => new FileSystemCache (
29+ cacheDir: $ dirs ->get ('runtime ' ) . 'cache/valinor ' ,
30+ ),
31+ default => null ,
32+ },
33+ ))->build ();
34+
35+ return new SchemaMapper (
36+ generator: $ generator ,
37+ mapper: $ mapper ,
38+ );
39+ },
3740 ];
3841 }
3942}
0 commit comments