Skip to content
Draft
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
3 changes: 3 additions & 0 deletions examples/.env
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,6 @@ OVH_AI_SECRET_KEY=
# amazee.ai
AMAZEEAI_LLM_KEY=
AMAZEEAI_LLM_API_URL=

# For using Venice
VENICE_API_KEY=
1 change: 1 addition & 0 deletions examples/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"symfony/ai-transformers-php-platform": "^0.5",
"symfony/ai-typesense-store": "^0.5",
"symfony/ai-vektor-store": "^0.6",
"symfony/ai-venice-platform": "^0.6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"symfony/ai-venice-platform": "^0.6",
"symfony/ai-venice-platform": "dev-main",

and please add the path repo for now, see #1702

"symfony/ai-vertex-ai-platform": "^0.5",
"symfony/ai-voyage-platform": "^0.5",
"symfony/ai-weaviate-store": "^0.5",
Expand Down
9 changes: 9 additions & 0 deletions examples/venice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Venice Examples

One use case of Venice is to convert text to speech, which creates audio files from text input.

To run the examples, you can use additional tools like (mpg123)[https://www.mpg123.de/]:

```bash
php venice/text-to-speech.php | mpg123 -
```
32 changes: 32 additions & 0 deletions examples/venice/chat-as-stream.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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\Venice\PlatformFactory;
use Symfony\AI\Platform\Message\Message;
use Symfony\AI\Platform\Message\MessageBag;

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

$platform = PlatformFactory::create(env('VENICE_API_KEY'), httpClient: http_client());

$messages = new MessageBag(
Message::forSystem('You are a helpful assistant.'),
Message::ofUser('Tina has one brother and one sister. How many sisters do Tina\'s siblings have?'),
);

$result = $platform->invoke('venice-uncensored', $messages, [
'stream' => true,
]);

foreach ($result->asStream() as $word) {
echo $word;
}
echo \PHP_EOL;
31 changes: 31 additions & 0 deletions examples/venice/chat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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\Venice\PlatformFactory;
use Symfony\AI\Platform\Message\Message;
use Symfony\AI\Platform\Message\MessageBag;

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

$platform = PlatformFactory::create(env('VENICE_API_KEY'), httpClient: http_client());

$messages = new MessageBag(
Message::forSystem('You are a helpful assistant.'),
Message::ofUser('Tina has one brother and one sister. How many sisters do Tina\'s siblings have?'),
);

try {
$result = $platform->invoke('venice-uncensored', $messages);

echo $result->asText().\PHP_EOL;
} catch (InvalidArgumentException $e) {
echo $e->getMessage()."\nMaybe use a different model?\n";
}
24 changes: 24 additions & 0 deletions examples/venice/embeddings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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\Venice\PlatformFactory;

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

$platform = PlatformFactory::create(env('VENICE_API_KEY'), httpClient: http_client());

$response = $platform->invoke('text-embedding-bge-m3', <<<TEXT
Once upon a time, there was a country called Japan. It was a beautiful country with a lot of mountains and rivers.
The people of Japan were very kind and hardworking. They loved their country very much and took care of it. The
country was very peaceful and prosperous. The people lived happily ever after.
TEXT);

echo 'Dimensions: '.$response->asVectors()[0]->getDimensions().\PHP_EOL;
24 changes: 24 additions & 0 deletions examples/venice/image-generation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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\Venice\PlatformFactory;

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

$platform = PlatformFactory::create(env('VENICE_API_KEY'), httpClient: http_client());

try {
$result = $platform->invoke('venice-uncensored', 'A beautiful sunset over a mountain range');

echo $result->asText().\PHP_EOL;
} catch (InvalidArgumentException $e) {
echo $e->getMessage()."\nMaybe use a different model?\n";
}
23 changes: 23 additions & 0 deletions examples/venice/text-to-speech.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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\Venice\PlatformFactory;
use Symfony\AI\Platform\Message\Content\Text;

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

$platform = PlatformFactory::create(env('VENICE_API_KEY'), httpClient: http_client());

$result = $platform->invoke('tts-kokoro', new Text('Hello world'), [
'voice' => 'am_liam',
]);

echo $result->asBinary().\PHP_EOL;
1 change: 1 addition & 0 deletions splitsh.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"ai-replicate-platform": "src/platform/src/Bridge/Replicate",
"ai-scaleway-platform": "src/platform/src/Bridge/Scaleway",
"ai-transformers-php-platform": "src/platform/src/Bridge/TransformersPhp",
"ai-venice-platform": "src/platform/src/Bridge/Venice",
"ai-vertex-ai-platform": "src/platform/src/Bridge/VertexAi",
"ai-voyage-platform": "src/platform/src/Bridge/Voyage",
"ai-store": {
Expand Down
1 change: 1 addition & 0 deletions src/ai-bundle/config/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
->append($import('platform/perplexity'))
->append($import('platform/scaleway'))
->append($import('platform/transformersphp'))
->append($import('platform/venice'))
->append($import('platform/vertexai'))
->append($import('platform/voyage'))
->end()
Expand Down
26 changes: 26 additions & 0 deletions src/ai-bundle/config/platform/venice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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\Component\Config\Definition\Configurator;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

return (new ArrayNodeDefinition('voyage'))
->children()
->stringNode('api_key')->end()
->stringNode('endpoint')
->defaultValue('https://api.venice.ai/api/v1/')
->end()
->stringNode('http_client')
->defaultValue('http_client')
->info('Service ID of the HTTP client to use')
->end()
->end();
4 changes: 4 additions & 0 deletions src/ai-bundle/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
use Symfony\AI\Platform\Bridge\Replicate\ModelCatalog as ReplicateModelCatalog;
use Symfony\AI\Platform\Bridge\Scaleway\ModelCatalog as ScalewayModelCatalog;
use Symfony\AI\Platform\Bridge\TransformersPhp\ModelCatalog as TransformersPhpModelCatalog;
use Symfony\AI\Platform\Bridge\Venice\Contract\Contract as VeniceContract;
use Symfony\AI\Platform\Bridge\Venice\ModelCatalog as VeniceModelCatalog;
use Symfony\AI\Platform\Bridge\VertexAi\Contract\GeminiContract as VertexAiGeminiContract;
use Symfony\AI\Platform\Bridge\VertexAi\ModelCatalog as VertexAiModelCatalog;
use Symfony\AI\Platform\Bridge\Voyage\ModelCatalog as VoyageModelCatalog;
Expand Down Expand Up @@ -90,6 +92,8 @@
->factory([GeminiContract::class, 'create'])
->set('ai.platform.contract.huggingface', Contract::class)
->factory([HuggingFaceContract::class, 'create'])
->set('ai.platform.contract.venice', Contract::class)
->factory([VeniceContract::class, 'create'])
->set('ai.platform.contract.vertexai.gemini', Contract::class)
->factory([VertexAiGeminiContract::class, 'create'])
->set('ai.platform.contract.ollama', Contract::class)
Expand Down
25 changes: 25 additions & 0 deletions src/ai-bundle/src/AiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
use Symfony\AI\Platform\Bridge\Perplexity\PlatformFactory as PerplexityPlatformFactory;
use Symfony\AI\Platform\Bridge\Scaleway\PlatformFactory as ScalewayPlatformFactory;
use Symfony\AI\Platform\Bridge\TransformersPhp\PlatformFactory as TransformersPhpPlatformFactory;
use Symfony\AI\Platform\Bridge\Venice\PlatformFactory as VenicePlatformFactory;
use Symfony\AI\Platform\Bridge\VertexAi\PlatformFactory as VertexAiPlatformFactory;
use Symfony\AI\Platform\Bridge\Voyage\PlatformFactory as VoyagePlatformFactory;
use Symfony\AI\Platform\Capability;
Expand Down Expand Up @@ -722,6 +723,30 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
return;
}

if ('venice' === $type) {
if (!ContainerBuilder::willBeAvailable('symfony/ai-venice-platform', VoyagePlatformFactory::class, ['symfony/ai-bundle'])) {
throw new RuntimeException('Voyage platform configuration requires "symfony/ai-venice-platform" package. Try running "composer require symfony/ai-venice-platform".');
}

$definition = (new Definition(Platform::class))
->setFactory(VenicePlatformFactory::class.'::create')
->setLazy(true)
->setArguments([
$platform['api_key'] ?? null,
$platform['endpoint'],
new Reference($platform['http_client']),
new Reference('ai.platform.contract.'.$type),
new Reference('event_dispatcher'),
])
->addTag('proxy', ['interface' => PlatformInterface::class])
->addTag('ai.platform', ['name' => $type]);

$container->setDefinition('ai.platform.'.$type, $definition);
$container->registerAliasForArgument('ai.platform.'.$type, PlatformInterface::class, $type);

return;
}

if ('vertexai' === $type && isset($platform['location'], $platform['project_id'])) {
if (!ContainerBuilder::willBeAvailable('symfony/ai-vertex-ai-platform', VertexAiPlatformFactory::class, ['symfony/ai-bundle'])) {
throw new RuntimeException('VertexAI platform configuration requires "symfony/ai-vertex-ai-platform" package. Try running "composer require symfony/ai-vertex-ai-platform".');
Expand Down
3 changes: 3 additions & 0 deletions src/ai-bundle/tests/DependencyInjection/AiBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7872,6 +7872,9 @@ private function getFullConfig(): array
'voyage' => [
'api_key' => 'voyage_key_full',
],
'venice' => [
'api_key' => 'venice_api_key',
],
'vertexai' => [
'location' => 'global',
'project_id' => '123',
Expand Down
3 changes: 3 additions & 0 deletions src/platform/src/Bridge/Venice/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.git* export-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---

Please submit your PR here instead:
https://github.com/symfony/ai

This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Close Pull Request

on:
pull_request_target:
types: [opened]

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.

However, you should instead open your PR on the main repository:
https://github.com/symfony/ai

This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
4 changes: 4 additions & 0 deletions src/platform/src/Bridge/Venice/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml
.phpunit.result.cache
7 changes: 7 additions & 0 deletions src/platform/src/Bridge/Venice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CHANGELOG
=========

0.5
---

* Add the bridge
21 changes: 21 additions & 0 deletions src/platform/src/Bridge/Venice/Contract/Contract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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\Bridge\Venice\Contract;

use Symfony\AI\Platform\Contract as PlatformContract;

/**
* @author Guillaume Loulier <personal@guillaumeloulier.fr>
*/
final class Contract extends PlatformContract
{
}
19 changes: 19 additions & 0 deletions src/platform/src/Bridge/Venice/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2025-present Fabien Potencier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading
Loading