Skip to content

Commit 66c5c22

Browse files
committed
minor #372 [Examples] Add Voyage example with multiple text inputs (chr-hertel)
This PR was merged into the main branch. Discussion ---------- [Examples] Add Voyage example with multiple text inputs | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | | License | MIT Was written anyways for testing #360 - let's bring it in. Commits ------- 133c77d Add Voyage example with multiple text inputs
2 parents eac6a44 + 133c77d commit 66c5c22

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\AI\Platform\Bridge\Voyage\PlatformFactory;
13+
use Symfony\AI\Platform\Bridge\Voyage\Voyage;
14+
15+
require_once dirname(__DIR__).'/bootstrap.php';
16+
17+
$platform = PlatformFactory::create(env('VOYAGE_API_KEY'), http_client());
18+
$embeddings = new Voyage();
19+
20+
$text1 = 'Once upon a time, there was a country called Japan. It was a beautiful country with a lot of mountains and rivers.';
21+
$text2 = 'The people of Japan were very kind and hardworking. They loved their country very much and took care of it.';
22+
$text3 = 'The country was very peaceful and prosperous. The people lived happily ever after.';
23+
24+
$result = $platform->invoke($embeddings, [$text1, $text2, $text3]);
25+
26+
echo 'Dimensions Text 1: '.$result->asVectors()[0]->getDimensions().\PHP_EOL;
27+
echo 'Dimensions Text 2: '.$result->asVectors()[1]->getDimensions().\PHP_EOL;
28+
echo 'Dimensions Text 3: '.$result->asVectors()[2]->getDimensions().\PHP_EOL;

0 commit comments

Comments
 (0)