Skip to content
Merged
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
28 changes: 28 additions & 0 deletions examples/voyage/multiple-embeddings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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.
*/

use Symfony\AI\Platform\Bridge\Voyage\PlatformFactory;
use Symfony\AI\Platform\Bridge\Voyage\Voyage;

require_once dirname(__DIR__).'/bootstrap.php';

$platform = PlatformFactory::create(env('VOYAGE_API_KEY'), http_client());
$embeddings = new Voyage();

$text1 = 'Once upon a time, there was a country called Japan. It was a beautiful country with a lot of mountains and rivers.';
$text2 = 'The people of Japan were very kind and hardworking. They loved their country very much and took care of it.';
$text3 = 'The country was very peaceful and prosperous. The people lived happily ever after.';

$result = $platform->invoke($embeddings, [$text1, $text2, $text3]);

echo 'Dimensions Text 1: '.$result->asVectors()[0]->getDimensions().\PHP_EOL;
echo 'Dimensions Text 2: '.$result->asVectors()[1]->getDimensions().\PHP_EOL;
echo 'Dimensions Text 3: '.$result->asVectors()[2]->getDimensions().\PHP_EOL;