-
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
91 additions
and
28 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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LLM\Agents\OpenAI\Client\Integration\Laravel; | ||
|
||
use Illuminate\Contracts\Foundation\Application; | ||
use Illuminate\Support\ServiceProvider; | ||
use LLM\Agents\LLM\LLMInterface; | ||
use LLM\Agents\OpenAI\Client\LLM; | ||
use LLM\Agents\OpenAI\Client\Parsers\ChatResponseParser; | ||
use LLM\Agents\OpenAI\Client\StreamResponseParser; | ||
use OpenAI\Responses\Chat\CreateStreamedResponse; | ||
|
||
final class OpenAIClientServiceProvider extends ServiceProvider | ||
{ | ||
public function register(): void | ||
{ | ||
$this->app->singleton( | ||
LLMInterface::class, | ||
LLM::class, | ||
); | ||
|
||
$this->app->singleton( | ||
StreamResponseParser::class, | ||
static function (Application $app): StreamResponseParser { | ||
$parser = new StreamResponseParser(); | ||
|
||
// Register parsers here | ||
$parser->registerParser( | ||
CreateStreamedResponse::class, | ||
$app->make(ChatResponseParser::class), | ||
); | ||
|
||
return $parser; | ||
}, | ||
); | ||
} | ||
} |
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