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
6 changes: 5 additions & 1 deletion src/platform/src/Bridge/Anthropic/Claude.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Claude extends Model
/**
* @param array<string, mixed> $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,
Expand All @@ -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);
}
}
45 changes: 45 additions & 0 deletions src/platform/tests/Bridge/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 Symfony\AI\Platform\Tests\Bridge\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());
}
}