diff --git a/examples/bedrock/chat-claude.php b/examples/bedrock/chat-claude.php index 1da23b022..dac981f23 100644 --- a/examples/bedrock/chat-claude.php +++ b/examples/bedrock/chat-claude.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Symfony\AI\Platform\Bridge\Anthropic\Claude; +use Symfony\AI\Platform\Bridge\Bedrock\Anthropic\Claude; use Symfony\AI\Platform\Bridge\Bedrock\PlatformFactory; use Symfony\AI\Platform\Message\Message; use Symfony\AI\Platform\Message\MessageBag; diff --git a/examples/bedrock/image-claude-binary.php b/examples/bedrock/image-claude-binary.php index 9d3fa9df9..23d94e1f9 100644 --- a/examples/bedrock/image-claude-binary.php +++ b/examples/bedrock/image-claude-binary.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Symfony\AI\Platform\Bridge\Anthropic\Claude; +use Symfony\AI\Platform\Bridge\Bedrock\Anthropic\Claude; use Symfony\AI\Platform\Bridge\Bedrock\PlatformFactory; use Symfony\AI\Platform\Message\Content\Image; use Symfony\AI\Platform\Message\Message; diff --git a/examples/bedrock/toolcall-claude.php b/examples/bedrock/toolcall-claude.php index 16b23403b..21e1f4921 100644 --- a/examples/bedrock/toolcall-claude.php +++ b/examples/bedrock/toolcall-claude.php @@ -13,7 +13,7 @@ use Symfony\AI\Agent\Toolbox\AgentProcessor; use Symfony\AI\Agent\Toolbox\Tool\Wikipedia; use Symfony\AI\Agent\Toolbox\Toolbox; -use Symfony\AI\Platform\Bridge\Anthropic\Claude; +use Symfony\AI\Platform\Bridge\Bedrock\Anthropic\Claude; use Symfony\AI\Platform\Bridge\Bedrock\PlatformFactory; use Symfony\AI\Platform\Message\Message; use Symfony\AI\Platform\Message\MessageBag; diff --git a/src/platform/src/Bridge/Bedrock/Anthropic/Claude.php b/src/platform/src/Bridge/Bedrock/Anthropic/Claude.php new file mode 100644 index 000000000..c5f4754a8 --- /dev/null +++ b/src/platform/src/Bridge/Bedrock/Anthropic/Claude.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\AI\Platform\Bridge\Bedrock\Anthropic; + +use Symfony\AI\Platform\Capability; +use Symfony\AI\Platform\Model; + +/** + * @author Christopher Hertel + */ +class Claude extends Model +{ + public const HAIKU_3 = 'claude-3-haiku-20240307'; + public const HAIKU_35 = 'claude-3-5-haiku-latest'; + public const SONNET_3 = 'claude-3-sonnet-20240229'; + public const SONNET_35 = 'claude-3-5-sonnet-latest'; + public const SONNET_37 = 'claude-3-7-sonnet-latest'; + public const SONNET_4 = 'claude-sonnet-4-20250514'; + public const SONNET_4_0 = 'claude-sonnet-4-0'; + public const OPUS_3 = 'claude-3-opus-20240229'; + public const OPUS_4 = 'claude-opus-4-20250514'; + public const OPUS_4_0 = 'claude-opus-4-0'; + public const OPUS_4_1 = 'claude-opus-4-1'; + + /** + * @param array $options The default options for the model usage + */ + public function __construct(string $name, array $options = []) + { + $capabilities = [ + Capability::INPUT_MESSAGES, + Capability::INPUT_IMAGE, + Capability::OUTPUT_TEXT, + Capability::OUTPUT_STREAMING, + Capability::TOOL_CALLING, + ]; + + if (!isset($options['max_tokens'])) { + $options['max_tokens'] = 1000; + } + + parent::__construct($name, $capabilities, $options); + } +} diff --git a/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeModelClient.php b/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeModelClient.php index a2be5356a..13935a8e9 100644 --- a/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeModelClient.php +++ b/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeModelClient.php @@ -14,7 +14,6 @@ use AsyncAws\BedrockRuntime\BedrockRuntimeClient; use AsyncAws\BedrockRuntime\Input\InvokeModelRequest; use AsyncAws\BedrockRuntime\Result\InvokeModelResponse; -use Symfony\AI\Platform\Bridge\Anthropic\Claude; use Symfony\AI\Platform\Bridge\Bedrock\RawBedrockResult; use Symfony\AI\Platform\Exception\RuntimeException; use Symfony\AI\Platform\Model; diff --git a/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeResultConverter.php b/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeResultConverter.php index 4fe27ad8d..077afb64c 100644 --- a/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeResultConverter.php +++ b/src/platform/src/Bridge/Bedrock/Anthropic/ClaudeResultConverter.php @@ -11,7 +11,6 @@ namespace Symfony\AI\Platform\Bridge\Bedrock\Anthropic; -use Symfony\AI\Platform\Bridge\Anthropic\Claude; use Symfony\AI\Platform\Bridge\Bedrock\RawBedrockResult; use Symfony\AI\Platform\Exception\RuntimeException; use Symfony\AI\Platform\Model; diff --git a/src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeResultConverterTest.php b/src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeResultConverterTest.php index de455def9..6fae26f9c 100644 --- a/src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeResultConverterTest.php +++ b/src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeResultConverterTest.php @@ -15,7 +15,7 @@ use AsyncAws\Core\Test\ResultMockFactory; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; -use Symfony\AI\Platform\Bridge\Anthropic\Claude; +use Symfony\AI\Platform\Bridge\Bedrock\Anthropic\Claude; use Symfony\AI\Platform\Bridge\Bedrock\Anthropic\ClaudeResultConverter; use Symfony\AI\Platform\Bridge\Bedrock\RawBedrockResult; use Symfony\AI\Platform\Exception\RuntimeException; diff --git a/src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeTest.php b/src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeTest.php new file mode 100644 index 000000000..d23a8e853 --- /dev/null +++ b/src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bridge\Bedrock\Anthropic; + +use PHPUnit\Framework\TestCase; +use Symfony\AI\Platform\Bridge\Anthropic\Claude; + +/** + * @author Oskar Stark + */ +final class ClaudeTest extends TestCase +{ + public function testItCreatesClaudeWithDefaultSettings() + { + $claude = new Claude(Claude::SONNET_35); + + $this->assertSame(Claude::SONNET_35, $claude->getName()); + $this->assertSame(['max_tokens' => 1000], $claude->getOptions()); + } + + public function testItCreatesClaudeWithCustomSettingsIncludingMaxTokens() + { + $claude = new Claude(Claude::SONNET_35, ['temperature' => 0.5, 'max_tokens' => 2000]); + + $this->assertSame(Claude::SONNET_35, $claude->getName()); + $this->assertSame(['temperature' => 0.5, 'max_tokens' => 2000], $claude->getOptions()); + } + + public function testItCreatesClaudeWithCustomSettingsWithoutMaxTokens() + { + $claude = new Claude(Claude::SONNET_35, ['temperature' => 0.5]); + + $this->assertSame(Claude::SONNET_35, $claude->getName()); + $this->assertSame(['temperature' => 0.5, 'max_tokens' => 1000], $claude->getOptions()); + } +}