Skip to content

Commit 3ff8f6d

Browse files
committed
Merge branch 'feature/laravel-support'
2 parents fbc3e44 + 924a3f9 commit 3ff8f6d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: src/Integration/Spiral/OpenAIClientBootloader.php

+15
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
namespace LLM\Agents\OpenAI\Client\Integration\Spiral;
66

7+
use GuzzleHttp\Client as HttpClient;
78
use LLM\Agents\LLM\LLMInterface;
89
use LLM\Agents\OpenAI\Client\LLM;
910
use LLM\Agents\OpenAI\Client\Parsers\ChatResponseParser;
1011
use LLM\Agents\OpenAI\Client\StreamResponseParser;
12+
use OpenAI\Contracts\ClientContract;
1113
use OpenAI\Responses\Chat\CreateStreamedResponse;
1214
use Spiral\Boot\Bootloader\Bootloader;
15+
use Spiral\Boot\EnvironmentInterface;
1316

1417
final class OpenAIClientBootloader extends Bootloader
1518
{
@@ -18,6 +21,18 @@ public function defineSingletons(): array
1821
return [
1922
LLMInterface::class => LLM::class,
2023

24+
ClientContract::class => static fn(
25+
EnvironmentInterface $env,
26+
): ClientContract => \OpenAI::factory()
27+
->withApiKey($env->get('OPENAI_KEY'))
28+
->withHttpHeader('OpenAI-Beta', 'assistants=v1')
29+
->withHttpClient(
30+
new HttpClient([
31+
'timeout' => (int) $env->get('OPENAI_HTTP_CLIENT_TIMEOUT', 2 * 60),
32+
]),
33+
)
34+
->make(),
35+
2136
StreamResponseParser::class => static function (
2237
ChatResponseParser $chatResponseParser,
2338
): StreamResponseParser {

0 commit comments

Comments
 (0)