File tree Expand file tree Collapse file tree 4 files changed +72
-8
lines changed Expand file tree Collapse file tree 4 files changed +72
-8
lines changed Original file line number Diff line number Diff line change @@ -48,10 +48,11 @@ composer require llm-agents/json-schema-mapper
4848### Setting it up in Spiral
4949
5050If you're using the Spiral framework (and why wouldn't you be? It's awesome!), you'll need to register the bootloader.
51- Here's how:
51+
52+ ** Here's how:**
5253
53541 . Open up your ` app/src/Application/Kernel.php ` file.
54- 2 . Add the SchemaMapperBootloader to the ` defineBootloaders() ` method:
55+ 2 . Add the ` LLM\Agents\JsonSchema\Mapper\Integration\Spiral\ SchemaMapperBootloader` to the ` defineBootloaders() ` method:
5556
5657``` php
5758class Kernel extends \Spiral\Framework\Kernel
@@ -62,13 +63,23 @@ class Kernel extends \Spiral\Framework\Kernel
6263 {
6364 return [
6465 // ... other bootloaders ...
65- \LLM\Agents\JsonSchema\Mapper\Bootloader \SchemaMapperBootloader::class,
66+ \LLM\Agents\JsonSchema\Mapper\Integration\Spiral \SchemaMapperBootloader::class,
6667 ];
6768 }
6869}
6970```
7071
71- And that's it! The bootloader will take care of registering the SchemaMapper for you.
72+ And that's it! The bootloader will take care of registering all the necessary components for you.
73+
74+ ### Setting it up in Laravel
75+
76+ If you're using the Laravel framework, you'll need to register the Service provider.
77+
78+ ** Here's how:**
79+
80+ Just register the ` LLM\Agents\JsonSchema\Mapper\Integration\Laravel\SchemaMapperServiceProvider `
81+
82+ And that's it! The service provider will take care of registering all the necessary components for you.
7283
7384## How to Use It
7485
Original file line number Diff line number Diff line change 66 "php" : " ^8.3" ,
77 "spiral/json-schema-generator" : " ^1.0" ,
88 "llm-agents/agents" : " ^1.0" ,
9- "cuyz/valinor" : " ^1.12" ,
10- "spiral/boot" : " ^3.13"
9+ "cuyz/valinor" : " ^1.12"
1110 },
1211 "require-dev" : {
13- "phpunit/phpunit" : " ^11.3"
12+ "phpunit/phpunit" : " ^11.3" ,
13+ "spiral/boot" : " ^3.13" ,
14+ "illuminate/support" : " ^v11.0"
1415 },
1516 "autoload" : {
1617 "psr-4" : {
2526 "config" : {
2627 "sort-packages" : true
2728 },
29+ "extra" : {
30+ "laravel" : {
31+ "providers" : [
32+ " LLM\\ Agents\\ JsonSchema\\ Mapper\\ Integration\\ Laravel\\ SchemaMapperServiceProvider"
33+ ]
34+ }
35+ },
2836 "minimum-stability" : " dev" ,
2937 "prefer-stable" : true
3038}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace LLM \Agents \JsonSchema \Mapper \Integration \Laravel ;
6+
7+ use CuyZ \Valinor \Cache \FileSystemCache ;
8+ use CuyZ \Valinor \Mapper \TreeMapper ;
9+ use Illuminate \Contracts \Foundation \Application ;
10+ use Illuminate \Support \ServiceProvider ;
11+ use LLM \Agents \JsonSchema \Mapper \MapperBuilder ;
12+ use LLM \Agents \JsonSchema \Mapper \SchemaMapper ;
13+ use LLM \Agents \Tool \SchemaMapperInterface ;
14+
15+ final class SchemaMapperServiceProvider extends ServiceProvider
16+ {
17+ public function register (): void
18+ {
19+ $ this ->app ->singleton (
20+ SchemaMapperInterface::class,
21+ SchemaMapper::class,
22+ );
23+
24+ $ this ->app ->singleton (
25+ TreeMapper::class,
26+ static fn (
27+ Application $ app ,
28+ ) => $ app ->make (MapperBuilder::class)->build (),
29+ );
30+
31+ $ this ->app ->singleton (
32+ MapperBuilder::class,
33+ static fn (
34+ Application $ app ,
35+ ) => new MapperBuilder (
36+ cache: match (true ) {
37+ $ app ->environment ('prod ' ) => new FileSystemCache (
38+ cacheDir: $ app ->storagePath ('cache/valinor ' ),
39+ ),
40+ default => null ,
41+ },
42+ ),
43+ );
44+ }
45+ }
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- namespace LLM \Agents \JsonSchema \Mapper \Bootloader ;
5+ namespace LLM \Agents \JsonSchema \Mapper \Integration \ Spiral ;
66
77use CuyZ \Valinor \Cache \FileSystemCache ;
88use CuyZ \Valinor \Mapper \TreeMapper ;
You can’t perform that action at this time.
0 commit comments