-
-
Notifications
You must be signed in to change notification settings - Fork 195
[Platform] Add Venice support
#1625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Guikingone
wants to merge
3
commits into
symfony:main
Choose a base branch
from
Guikingone:platform/venice
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,141
−0
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,3 +210,6 @@ OVH_AI_SECRET_KEY= | |
| # amazee.ai | ||
| AMAZEEAI_LLM_KEY= | ||
| AMAZEEAI_LLM_API_URL= | ||
|
|
||
| # For using Venice | ||
| VENICE_API_KEY= | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 - | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
8 changes: 8 additions & 0 deletions
8
src/platform/src/Bridge/Venice/.github/PULL_REQUEST_TEMPLATE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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! |
20 changes: 20 additions & 0 deletions
20
src/platform/src/Bridge/Venice/.github/workflows/close-pull-request.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| vendor/ | ||
| composer.lock | ||
| phpunit.xml | ||
| .phpunit.result.cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| CHANGELOG | ||
| ========= | ||
|
|
||
| 0.5 | ||
| --- | ||
|
|
||
| * Add the bridge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and please add the path repo for now, see #1702