From 133c77d7c34478d123797d20fefab0f7d829a155 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Sat, 30 Aug 2025 01:35:03 +0200 Subject: [PATCH] Add Voyage example with multiple text inputs --- examples/voyage/multiple-embeddings.php | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/voyage/multiple-embeddings.php diff --git a/examples/voyage/multiple-embeddings.php b/examples/voyage/multiple-embeddings.php new file mode 100644 index 000000000..f3610328b --- /dev/null +++ b/examples/voyage/multiple-embeddings.php @@ -0,0 +1,28 @@ + + * + * 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;