Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/bedrock/chat-claude.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/bedrock/image-claude-binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/bedrock/toolcall-claude.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
53 changes: 53 additions & 0 deletions src/platform/src/Bridge/Bedrock/Anthropic/Claude.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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 <mail@christopher-hertel.de>
*/
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<string, mixed> $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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
45 changes: 45 additions & 0 deletions src/platform/tests/Bridge/Bedrock/Anthropic/ClaudeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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 <oskarstark@googlemail.com>
*/
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());
}
}