Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit a78f8f7

Browse files
authored
refactor: ease Bedrock init (#324)
1 parent e6385cc commit a78f8f7

File tree

7 files changed

+8
-26
lines changed

7 files changed

+8
-26
lines changed

examples/bedrock/chat-claude.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
43
use PhpLlm\LlmChain\Bridge\Anthropic\Claude;
54
use PhpLlm\LlmChain\Bridge\Bedrock\PlatformFactory;
65
use PhpLlm\LlmChain\Chain;
@@ -17,9 +16,7 @@
1716
exit(1);
1817
}
1918

20-
$platform = PlatformFactory::create(
21-
new BedrockRuntimeClient()
22-
);
19+
$platform = PlatformFactory::create();
2320
$llm = new Claude();
2421

2522
$chain = new Chain($platform, $llm);

examples/bedrock/chat-llama.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
43
use PhpLlm\LlmChain\Bridge\Bedrock\PlatformFactory;
54
use PhpLlm\LlmChain\Bridge\Meta\Llama;
65
use PhpLlm\LlmChain\Chain;
@@ -17,10 +16,8 @@
1716
exit(1);
1817
}
1918

20-
$platform = PlatformFactory::create(
21-
new BedrockRuntimeClient()
22-
);
23-
$llm = new Llama('llama-3.2-3b-instruct');
19+
$platform = PlatformFactory::create();
20+
$llm = new Llama(Llama::V3_2_3B_INSTRUCT);
2421

2522
$chain = new Chain($platform, $llm);
2623
$messages = new MessageBag(

examples/bedrock/chat-nova.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
43
use PhpLlm\LlmChain\Bridge\Bedrock\Nova\Nova;
54
use PhpLlm\LlmChain\Bridge\Bedrock\PlatformFactory;
65
use PhpLlm\LlmChain\Chain;
@@ -17,9 +16,7 @@
1716
exit(1);
1817
}
1918

20-
$platform = PlatformFactory::create(
21-
new BedrockRuntimeClient()
22-
);
19+
$platform = PlatformFactory::create();
2320
$llm = new Nova(Nova::PRO);
2421

2522
$chain = new Chain($platform, $llm);

examples/bedrock/image-claude-binary.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
43
use PhpLlm\LlmChain\Bridge\Anthropic\Claude;
54
use PhpLlm\LlmChain\Bridge\Bedrock\PlatformFactory;
65
use PhpLlm\LlmChain\Chain;
@@ -18,9 +17,7 @@
1817
exit(1);
1918
}
2019

21-
$platform = PlatformFactory::create(
22-
new BedrockRuntimeClient()
23-
);
20+
$platform = PlatformFactory::create();
2421
$llm = new Claude();
2522

2623
$chain = new Chain($platform, $llm);

examples/bedrock/image-nova.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
43
use PhpLlm\LlmChain\Bridge\Bedrock\Nova\Nova;
54
use PhpLlm\LlmChain\Bridge\Bedrock\PlatformFactory;
65
use PhpLlm\LlmChain\Chain;
@@ -18,9 +17,7 @@
1817
exit(1);
1918
}
2019

21-
$platform = PlatformFactory::create(
22-
new BedrockRuntimeClient()
23-
);
20+
$platform = PlatformFactory::create();
2421
$llm = new Nova(Nova::PRO);
2522

2623
$chain = new Chain($platform, $llm);

examples/bedrock/toolcall-claude.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
43
use PhpLlm\LlmChain\Bridge\Anthropic\Claude;
54
use PhpLlm\LlmChain\Bridge\Bedrock\PlatformFactory;
65
use PhpLlm\LlmChain\Chain;
@@ -21,9 +20,7 @@
2120
exit(1);
2221
}
2322

24-
$platform = PlatformFactory::create(
25-
new BedrockRuntimeClient()
26-
);
23+
$platform = PlatformFactory::create();
2724
$llm = new Claude();
2825

2926
$wikipedia = new Wikipedia(HttpClient::create());

src/Bridge/Bedrock/PlatformFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
final readonly class PlatformFactory
1313
{
1414
public static function create(
15-
?BedrockRuntimeClient $bedrockRuntimeClient = null,
15+
BedrockRuntimeClient $bedrockRuntimeClient = new BedrockRuntimeClient(),
1616
): Platform {
1717
$modelClient[] = new ClaudeHandler($bedrockRuntimeClient);
1818
$modelClient[] = new NovaHandler($bedrockRuntimeClient);

0 commit comments

Comments
 (0)