-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from llm-agents-php/feature/laravel-support
Adds laravel support
- Loading branch information
Showing
4 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LLM\Agents\JsonSchema\Mapper\Integration\Laravel; | ||
|
||
use CuyZ\Valinor\Cache\FileSystemCache; | ||
use CuyZ\Valinor\Mapper\TreeMapper; | ||
use Illuminate\Contracts\Foundation\Application; | ||
use Illuminate\Support\ServiceProvider; | ||
use LLM\Agents\JsonSchema\Mapper\MapperBuilder; | ||
use LLM\Agents\JsonSchema\Mapper\SchemaMapper; | ||
use LLM\Agents\Tool\SchemaMapperInterface; | ||
|
||
final class SchemaMapperServiceProvider extends ServiceProvider | ||
{ | ||
public function register(): void | ||
{ | ||
$this->app->singleton( | ||
SchemaMapperInterface::class, | ||
SchemaMapper::class, | ||
); | ||
|
||
$this->app->singleton( | ||
TreeMapper::class, | ||
static fn( | ||
Application $app, | ||
) => $app->make(MapperBuilder::class)->build(), | ||
); | ||
|
||
$this->app->singleton( | ||
MapperBuilder::class, | ||
static fn( | ||
Application $app, | ||
) => new MapperBuilder( | ||
cache: match (true) { | ||
$app->environment('prod') => new FileSystemCache( | ||
cacheDir: $app->storagePath('cache/valinor'), | ||
), | ||
default => null, | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters