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/anthropic/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('ANTHROPIC_API_KEY'), httpClient: http_client());
$model = new Claude();
$model = new Claude(Claude::SONNET_37);

$messages = new MessageBag(
Message::forSystem('You are a thoughtful philosopher.'),
Expand Down
2 changes: 1 addition & 1 deletion examples/anthropic/toolcall.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('ANTHROPIC_API_KEY'), httpClient: http_client());
$model = new Claude();
$model = new Claude(Claude::SONNET_37);

$wikipedia = new Wikipedia(http_client());
$toolbox = new Toolbox([$wikipedia], logger: logger());
Expand Down
2 changes: 1 addition & 1 deletion examples/bedrock/toolcall-nova.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}

$platform = PlatformFactory::create();
$model = new Nova();
$model = new Nova(Nova::PRO);

$wikipedia = new Wikipedia(http_client());
$toolbox = new Toolbox([$wikipedia]);
Expand Down
2 changes: 1 addition & 1 deletion examples/elevenlabs/text-to-speech-as-stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
apiKey: env('ELEVEN_LABS_API_KEY'),
httpClient: http_client(),
);
$model = new ElevenLabs(options: [
$model = new ElevenLabs(ElevenLabs::ELEVEN_MULTILINGUAL_V2, [
'voice' => 'Dslrhjl3ZpzrctukrQSN', // Brad (https://elevenlabs.io/app/voice-library?voiceId=Dslrhjl3ZpzrctukrQSN)
'stream' => true,
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/elevenlabs/text-to-speech.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
apiKey: env('ELEVEN_LABS_API_KEY'),
httpClient: http_client(),
);
$model = new ElevenLabs(options: [
$model = new ElevenLabs(ElevenLabs::ELEVEN_MULTILINGUAL_V2, [
'voice' => 'Dslrhjl3ZpzrctukrQSN', // Brad (https://elevenlabs.io/app/voice-library?voiceId=Dslrhjl3ZpzrctukrQSN)
]);

Expand Down
2 changes: 1 addition & 1 deletion examples/mistral/chat-multiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Message::forSystem('Just give short answers.'),
Message::ofUser('What is your favorite color?'),
);
$result = $platform->invoke(new Mistral(), $messages, [
$result = $platform->invoke(new Mistral(Mistral::MISTRAL_LARGE), $messages, [
'temperature' => 1.5,
'n' => 10,
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/mistral/chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('MISTRAL_API_KEY'), http_client());
$model = new Mistral();
$model = new Mistral(Mistral::MISTRAL_LARGE);

$messages = new MessageBag(Message::ofUser('What is the best French cheese?'));
$result = $platform->invoke($model, $messages, [
Expand Down
2 changes: 1 addition & 1 deletion examples/mistral/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('MISTRAL_API_KEY'), http_client());
$model = new Mistral();
$model = new Mistral(Mistral::MISTRAL_LARGE);

$messages = new MessageBag(Message::ofUser('What is the eighth prime number?'));
$result = $platform->invoke($model, $messages, [
Expand Down
2 changes: 1 addition & 1 deletion examples/mistral/token-metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('MISTRAL_API_KEY'), http_client());
$model = new Mistral();
$model = new Mistral(Mistral::MISTRAL_LARGE);

$agent = new Agent($platform, $model, outputProcessors: [new TokenOutputProcessor()], logger: logger());

Expand Down
2 changes: 1 addition & 1 deletion examples/mistral/toolcall-stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('MISTRAL_API_KEY'), http_client());
$model = new Mistral();
$model = new Mistral(Mistral::MISTRAL_LARGE);

$transcriber = new YouTubeTranscriber(http_client());
$toolbox = new Toolbox([$transcriber], logger: logger());
Expand Down
2 changes: 1 addition & 1 deletion examples/mistral/toolcall.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('MISTRAL_API_KEY'), http_client());
$model = new Mistral();
$model = new Mistral(Mistral::MISTRAL_LARGE);

$toolbox = new Toolbox([new Clock()], logger: logger());
$processor = new AgentProcessor($toolbox);
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/academic-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);
$agent = new Agent($platform, $model, outputProcessors: [new SearchResultProcessor()], logger: logger());

$messages = new MessageBag(Message::ofUser('What is the best French cheese of the first quarter-century of 21st century?'));
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);

$messages = new MessageBag(Message::ofUser('What is the best French cheese?'));
$response = $platform->invoke($model, $messages);
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/disable-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);

$messages = new MessageBag(Message::ofUser('What is 2 + 2?'));
$response = $platform->invoke($model, $messages, [
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/image-input-url.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);
$agent = new Agent($platform, $model, outputProcessors: [new SearchResultProcessor()], logger: logger());

$messages = new MessageBag(
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/pdf-input-url.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);
$agent = new Agent($platform, $model, outputProcessors: [new SearchResultProcessor()], logger: logger());

$messages = new MessageBag(
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);
$agent = new Agent($platform, $model, outputProcessors: [new SearchResultProcessor()], logger: logger());

$messages = new MessageBag(
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/token-metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);
$agent = new Agent($platform, $model, outputProcessors: [new TokenOutputProcessor()], logger: logger());

$messages = new MessageBag(
Expand Down
2 changes: 1 addition & 1 deletion examples/perplexity/web-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
$model = new Perplexity();
$model = new Perplexity(Perplexity::SONAR);

$messages = new MessageBag(Message::ofUser('What is the best French cheese?'));
$response = $platform->invoke($model, $messages, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ final class ModelOverrideInputProcessorTest extends TestCase
{
public function testProcessInputWithValidModelOption()
{
$gpt = new Gpt();
$claude = new Claude();
$gpt = new Gpt(Gpt::GPT_4O);
$claude = new Claude(Claude::SONNET_37);
$input = new Input($gpt, new MessageBag(), ['model' => $claude]);

$processor = new ModelOverrideInputProcessor();
Expand All @@ -47,7 +47,7 @@ public function testProcessInputWithValidModelOption()

public function testProcessInputWithoutModelOption()
{
$gpt = new Gpt();
$gpt = new Gpt(Gpt::GPT_4O);
$input = new Input($gpt, new MessageBag());

$processor = new ModelOverrideInputProcessor();
Expand All @@ -61,7 +61,7 @@ public function testProcessInputWithInvalidModelOption()
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Option "model" must be an instance of "'.Model::class.'".');

$gpt = new Gpt();
$gpt = new Gpt(Gpt::GPT_4O);
$model = new MessageBag();
$input = new Input($gpt, new MessageBag(), ['model' => $model]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testProcessInputAddsSystemMessageWhenNoneExists()
{
$processor = new SystemPromptInputProcessor('This is a system prompt');

$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
$input = new Input(new Gpt(Gpt::GPT_4O), new MessageBag(Message::ofUser('This is a user message')));
$processor->processInput($input);

$messages = $input->messages->getMessages();
Expand All @@ -66,7 +66,7 @@ public function testProcessInputDoesNotAddSystemMessageWhenOneExists()
Message::forSystem('This is already a system prompt'),
Message::ofUser('This is a user message'),
);
$input = new Input(new Gpt(), $messages);
$input = new Input(new Gpt(Gpt::GPT_4O), $messages);
$processor->processInput($input);

$messages = $input->messages->getMessages();
Expand All @@ -93,7 +93,7 @@ public function execute(ToolCall $toolCall): mixed
},
);

$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
$input = new Input(new Gpt(Gpt::GPT_4O), new MessageBag(Message::ofUser('This is a user message')));
$processor->processInput($input);

$messages = $input->messages->getMessages();
Expand Down Expand Up @@ -133,7 +133,7 @@ public function execute(ToolCall $toolCall): mixed
true,
);

$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
$input = new Input(new Gpt(Gpt::GPT_4O), new MessageBag(Message::ofUser('This is a user message')));
$processor->processInput($input);

$messages = $input->messages->getMessages();
Expand Down Expand Up @@ -175,7 +175,7 @@ public function execute(ToolCall $toolCall): mixed
},
);

$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
$input = new Input(new Gpt(Gpt::GPT_4O), new MessageBag(Message::ofUser('This is a user message')));
$processor->processInput($input);

$messages = $input->messages->getMessages();
Expand All @@ -198,7 +198,7 @@ public function testWithTranslatedSystemPrompt()
{
$processor = new SystemPromptInputProcessor('This is a', null, $this->getTranslator(), true);

$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')), []);
$input = new Input(new Gpt(Gpt::GPT_4O), new MessageBag(Message::ofUser('This is a user message')), []);
$processor->processInput($input);

$messages = $input->messages->getMessages();
Expand All @@ -218,7 +218,7 @@ public function testWithTranslationDomainSystemPrompt()
'prompts'
);

$input = new Input(new Gpt(), new MessageBag(), []);
$input = new Input(new Gpt(Gpt::GPT_4O), new MessageBag(), []);
$processor->processInput($input);

$messages = $input->messages->getMessages();
Expand Down
2 changes: 1 addition & 1 deletion src/platform/src/Bridge/Anthropic/Claude.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Claude extends Model
* @param array<string, mixed> $options The default options for the model usage
*/
public function __construct(
string $name = self::SONNET_37,
string $name,
array $options = ['max_tokens' => 1000],
) {
$capabilities = [
Expand Down
2 changes: 1 addition & 1 deletion src/platform/src/Bridge/Bedrock/Nova/Nova.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class Nova extends Model
* @param array<string, mixed> $options The default options for the model usage
*/
public function __construct(
string $name = self::PRO,
string $name,
array $options = ['max_tokens' => 1000],
) {
$capabilities = [
Expand Down
2 changes: 1 addition & 1 deletion src/platform/src/Bridge/ElevenLabs/ElevenLabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class ElevenLabs extends Model
public const SCRIBE_V1_EXPERIMENTAL = 'scribe_v1_experimental';

public function __construct(
string $name = self::ELEVEN_MULTILINGUAL_V2,
string $name,
array $options = [],
) {
parent::__construct($name, [], $options);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/src/Bridge/Mistral/Embeddings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class Embeddings extends Model
* @param array<string, mixed> $options
*/
public function __construct(
string $name = self::MISTRAL_EMBED,
string $name,
array $options = [],
) {
parent::__construct($name, [Capability::INPUT_MULTIPLE], $options);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/src/Bridge/Mistral/Mistral.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class Mistral extends Model
* @param array<string, mixed> $options
*/
public function __construct(
string $name = self::MISTRAL_LARGE,
string $name,
array $options = [],
) {
$capabilities = [
Expand Down
2 changes: 1 addition & 1 deletion src/platform/src/Bridge/OpenAi/Gpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Gpt extends Model
* @param array<mixed> $options The default options for the model usage
*/
public function __construct(
string $name = self::GPT_4O,
string $name,
array $options = [],
) {
$capabilities = [
Expand Down
2 changes: 1 addition & 1 deletion src/platform/src/Bridge/Perplexity/Perplexity.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Perplexity extends Model
* @param array<string, mixed> $options
*/
public function __construct(
string $name = self::SONAR,
string $name,
array $options = [],
) {
$capabilities = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testSupportsNormalization()
$normalizer = new AssistantMessageNormalizer();

$this->assertTrue($normalizer->supportsNormalization(new AssistantMessage('Hello'), context: [
Contract::CONTEXT_MODEL => new Claude(),
Contract::CONTEXT_MODEL => new Claude(Claude::SONNET_37),
]));
$this->assertFalse($normalizer->supportsNormalization('not an assistant message'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/tests/Bridge/Anthropic/ModelClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ModelClientTest extends TestCase

protected function setUp(): void
{
$this->model = new Claude();
$this->model = new Claude(Claude::SONNET_37);
}

public function testAnthropicBetaHeaderIsSetWithSingleBetaFeature()
Expand Down
2 changes: 1 addition & 1 deletion src/platform/tests/Bridge/Bedrock/Nova/ContractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testConvert(MessageBag $bag, array $expected)
new UserMessageNormalizer(),
);

$this->assertEquals($expected, $contract->createRequestPayload(new Nova(), $bag));
$this->assertEquals($expected, $contract->createRequestPayload(new Nova(Nova::PRO), $bag));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testItCanCreatePayloadWithAudio()

$contract = ElevenLabsContract::create();

$payload = $contract->createRequestPayload(new ElevenLabs(), $audio);
$payload = $contract->createRequestPayload(new ElevenLabs(ElevenLabs::ELEVEN_MULTILINGUAL_V2), $audio);

$this->assertSame([
'type' => 'input_audio',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testSupportsModel()
'https://api.elevenlabs.io/v1',
);

$this->assertTrue($client->supports(new ElevenLabs()));
$this->assertTrue($client->supports(new ElevenLabs(ElevenLabs::ELEVEN_MULTILINGUAL_V2)));
$this->assertFalse($client->supports(new Model('any-model')));
}

Expand Down Expand Up @@ -129,7 +129,7 @@ public function testClientCannotPerformTextToSpeechRequestWithoutValidPayload()
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The payload must contain a "text" key');
$this->expectExceptionCode(0);
$client->request(new ElevenLabs(options: [
$client->request(new ElevenLabs(ElevenLabs::ELEVEN_MULTILINGUAL_V2, [
'voice' => 'Dslrhjl3ZpzrctukrQSN',
]), []);
}
Expand All @@ -154,7 +154,7 @@ public function testClientCanPerformTextToSpeechRequest()
'my-api-key',
);

$client->request(new ElevenLabs(options: [
$client->request(new ElevenLabs(ElevenLabs::ELEVEN_MULTILINGUAL_V2, [
'voice' => 'Dslrhjl3ZpzrctukrQSN',
]), [
'text' => 'foo',
Expand Down Expand Up @@ -183,7 +183,7 @@ public function testClientCanPerformTextToSpeechRequestAsStream()
'my-api-key',
);

$result = $client->request(new ElevenLabs(options: [
$result = $client->request(new ElevenLabs(ElevenLabs::ELEVEN_MULTILINGUAL_V2, [
'voice' => 'Dslrhjl3ZpzrctukrQSN',
'stream' => true,
]), [
Expand Down
Loading