diff --git a/src/platform/src/Bridge/Anthropic/Claude.php b/src/platform/src/Bridge/Anthropic/Claude.php index da48bcd07..bec67c1f5 100644 --- a/src/platform/src/Bridge/Anthropic/Claude.php +++ b/src/platform/src/Bridge/Anthropic/Claude.php @@ -34,7 +34,7 @@ class Claude extends Model /** * @param array $options The default options for the model usage */ - public function __construct(string $name, array $options = ['max_tokens' => 1000]) + public function __construct(string $name, array $options = []) { $capabilities = [ Capability::INPUT_MESSAGES, @@ -44,6 +44,10 @@ public function __construct(string $name, array $options = ['max_tokens' => 1000 Capability::TOOL_CALLING, ]; + if (!isset($options['max_tokens'])) { + $options['max_tokens'] = 1000; + } + parent::__construct($name, $capabilities, $options); } } diff --git a/src/platform/tests/Bridge/Anthropic/ClaudeTest.php b/src/platform/tests/Bridge/Anthropic/ClaudeTest.php new file mode 100644 index 000000000..7a9293524 --- /dev/null +++ b/src/platform/tests/Bridge/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 Symfony\AI\Platform\Tests\Bridge\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()); + } +}