Skip to content

Commit cc7b3f8

Browse files
committed
feature #1015 [Platform] Add Decart (Guikingone)
This PR was squashed before being merged into the main branch. Discussion ---------- [Platform] Add `Decart` | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | yes | Issues | #16 | License | MIT Commits ------- 8be0a4c [Platform] Add `Decart`
2 parents 7adba8f + 8be0a4c commit cc7b3f8

File tree

27 files changed

+913
-8
lines changed

27 files changed

+913
-8
lines changed

docs/components/platform.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ Supported Models & Platforms
137137
* `ElevenLabs STT`_ with `ElevenLabs`_ as Platform
138138
* `Cartesia TTS`_ with `Cartesia`_ as Platform
139139
* `Cartesia STT`_ with `Cartesia`_ as Platform
140+
* **Image/Video Models**
141+
* `Decart T2I`_ with `Decart`_ as Platform
142+
* `Decart T2V`_ with `Decart`_ as Platform
140143

141144
Generic Platforms
142145
~~~~~~~~~~~~~~~~~
@@ -548,12 +551,15 @@ Code Examples
548551
.. _`Anthropic`: https://www.anthropic.com/
549552
.. _`AWS Bedrock`: https://aws.amazon.com/bedrock/
550553
.. _`LiteLLM`: https://docs.litellm.ai/docs/
551-
.. _`ElevenLabs`: https://elevenlabs.io/
552-
.. _`ElevenLabs STT`: https://elevenlabs.io/speech-to-text
553-
.. _`ElevenLabs TTS`: https://elevenlabs.io/text-to-speech
554554
.. _`Cartesia`: https://cartesia.ai/
555555
.. _`Cartesia STT`: https://cartesia.ai/ink
556556
.. _`Cartesia TTS`: https://cartesia.ai/sonic
557+
.. _`Decart`: https://decart.ai/
558+
.. _`Decart T2I`: https://platform.decart.ai/models/lucy-image
559+
.. _`Decart T2V`: https://platform.decart.ai/models/lucy
560+
.. _`ElevenLabs`: https://elevenlabs.io/
561+
.. _`ElevenLabs STT`: https://elevenlabs.io/speech-to-text
562+
.. _`ElevenLabs TTS`: https://elevenlabs.io/text-to-speech
557563
.. _`LiteLLM example`: https://github.com/symfony/ai/blob/main/examples/litellm/chat.php
558564
.. _`Meta's Llama`: https://www.llama.com/
559565
.. _`Ollama`: https://ollama.com/

examples/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ ELEVEN_LABS_API_KEY=
5656
CARTESIA_API_KEY=
5757
CARTESIA_API_VERSION=2025-04-16
5858

59+
# For using Decart
60+
DECART_ENDPOINT=https://api.decart.ai/v1
61+
DECART_API_KEY=
62+
5963
# For using SerpApi (tool)
6064
SERP_API_KEY=
6165

examples/decart/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Decart Examples
2+
3+
One use case of Decart is to convert text to image, which creates image files from text input.
4+
5+
```bash
6+
php decart/text-to-image.php > cat.jpg
7+
php decart/text-to-video.php > sunset.mp4
8+
php decart/animated-image.php > animated-accordion.mp4
9+
php decart/image-editing.php > colorized-image.mp4
10+
```

examples/decart/animated-image.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Decart\PlatformFactory;
13+
use Symfony\AI\Platform\Message\Content\Image;
14+
15+
require_once dirname(__DIR__).'/bootstrap.php';
16+
17+
$platform = PlatformFactory::create(
18+
apiKey: env('DECART_API_KEY'),
19+
httpClient: http_client(),
20+
);
21+
22+
$result = $platform->invoke('lucy-pro-i2v', Image::fromFile(dirname(__DIR__, 2).'/fixtures/accordion.jpg'), [
23+
'prompt' => 'Make the man move from right to left while playing accordion',
24+
]);
25+
26+
echo $result->asBinary().\PHP_EOL;

examples/decart/image-editing.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Decart\PlatformFactory;
13+
use Symfony\AI\Platform\Message\Content\Image;
14+
15+
require_once dirname(__DIR__).'/bootstrap.php';
16+
17+
$platform = PlatformFactory::create(
18+
apiKey: env('DECART_API_KEY'),
19+
httpClient: http_client()
20+
);
21+
22+
$result = $platform->invoke('lucy-pro-i2i', Image::fromFile(dirname(__DIR__, 2).'/fixtures/accordion.jpg'), [
23+
'prompt' => 'Colorize the walls',
24+
]);
25+
26+
echo $result->asBinary().\PHP_EOL;

examples/decart/text-to-image.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\Decart\PlatformFactory;
13+
use Symfony\AI\Platform\Message\Content\Text;
14+
15+
require_once dirname(__DIR__).'/bootstrap.php';
16+
17+
$platform = PlatformFactory::create(
18+
apiKey: env('DECART_API_KEY'),
19+
httpClient: http_client(),
20+
);
21+
22+
$result = $platform->invoke('lucy-pro-t2i', new Text('A cat on a kitchen table'));
23+
24+
echo $result->asBinary().\PHP_EOL;

examples/decart/text-to-video.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\Decart\PlatformFactory;
13+
use Symfony\AI\Platform\Message\Content\Text;
14+
15+
require_once dirname(__DIR__).'/bootstrap.php';
16+
17+
$platform = PlatformFactory::create(
18+
apiKey: env('DECART_API_KEY'),
19+
httpClient: http_client(),
20+
);
21+
22+
$result = $platform->invoke('lucy-pro-t2v', new Text('A serene ocean with dolphins jumping at sunset'));
23+
24+
echo $result->asBinary();

fixtures/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ For testing multi-modal features, the repository contains binary media content,
66
* `fixtures/audio.mp3`: davidbain, Creative Commons, see [freesound.org](https://freesound.org/people/davidbain/sounds/136777/)
77
* `fixtures/document.pdf`: Chem8240ja, Public Domain, see [Wikipedia](https://en.m.wikipedia.org/wiki/File:Re_example.pdf)
88
* `fixtures/image.jpg`: Chris F., Creative Commons, see [pexels.com](https://www.pexels.com/photo/blauer-und-gruner-elefant-mit-licht-1680755/)
9+
* `fixtures/ocean.mp4`: Ruvim Miksanskiy, Creative Commons, see [pexels.com](https://www.pexels.com/video/waves-crashing-1390942/)

fixtures/ocean.mp4

1.64 MB
Binary file not shown.

src/ai-bundle/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
}
5858
},
5959
"config": {
60-
"sort-packages": true
60+
"sort-packages": true,
61+
"allow-plugins": {
62+
"php-http/discovery": true
63+
}
6164
},
6265
"extra": {
6366
"branch-alias": {

0 commit comments

Comments
 (0)