@@ -73,7 +73,7 @@ The core feature of LLM Chain is to interact with language models via messages.
73
73
a ** MessageBag** to a ** Chain** , which takes care of LLM invocation and response handling.
74
74
75
75
Messages can be of different types, most importantly ` UserMessage ` , ` SystemMessage ` , or ` AssistantMessage ` , and can also
76
- have different content types, like ` Text ` or ` Image ` .
76
+ have different content types, like ` Text ` , ` Image ` or ` Audio ` .
77
77
78
78
#### Example Chain call with messages
79
79
@@ -453,13 +453,13 @@ use PhpLlm\LlmChain\Model\Message\Content\Image;
453
453
use PhpLlm\LlmChain\Model\Message\Message;
454
454
use PhpLlm\LlmChain\Model\Message\MessageBag;
455
455
456
- // Initialize Platoform , LLM & Chain
456
+ // Initialize Platform , LLM & Chain
457
457
458
458
$messages = new MessageBag(
459
459
Message::forSystem('You are an image analyzer bot that helps identify the content of images.'),
460
460
Message::ofUser(
461
461
'Describe the image as a comedian would do it.',
462
- new Image(dirname(__DIR__).'/tests/Fixture/image.png '), // Path to an image file
462
+ new Image(dirname(__DIR__).'/tests/Fixture/image.jpg '), // Path to an image file
463
463
new Image('https://foo.com/bar.png'), // URL to an image
464
464
new Image('data:image/png;base64,...'), // Data URL of an image
465
465
),
@@ -472,6 +472,30 @@ $response = $chain->call($messages);
472
472
1 . ** Image Description** : [ image-describer-binary.php] ( examples/image-describer-binary.php ) (with binary file)
473
473
1 . ** Image Description** : [ image-describer-url.php] ( examples/image-describer-url.php ) (with URL)
474
474
475
+ ### Audio Processing
476
+
477
+ Similar to images, some LLMs also support audio as input, which is just another ` Content ` type within the ` UserMessage ` :
478
+
479
+ ``` php
480
+ use PhpLlm\LlmChain\Model\Message\Content\Audio;
481
+ use PhpLlm\LlmChain\Model\Message\Message;
482
+ use PhpLlm\LlmChain\Model\Message\MessageBag;
483
+
484
+ // Initialize Platform, LLM & Chain
485
+
486
+ $messages = new MessageBag(
487
+ Message::ofUser(
488
+ 'What is this recording about?',
489
+ new Audio(dirname(__DIR__).'/tests/Fixture/audio.mp3'), // Path to an audio file
490
+ ),
491
+ );
492
+ $response = $chain->call($messages);
493
+ ```
494
+
495
+ #### Code Examples
496
+
497
+ 1 . ** Audio Description** : [ audio-describer.php] ( examples/audio-describer.php )
498
+
475
499
### Embeddings
476
500
477
501
Creating embeddings of word, sentences or paragraphs is a typical use case around the interaction with LLMs and
@@ -617,3 +641,10 @@ Contributions are always welcome, so feel free to join the development of this l
617
641
[ ![ LLM Chain Contributors] ( https://contrib.rocks/image?repo=php-llm/llm-chain ' LLM Chain Contributors ')] ( https://github.com/php-llm/llm-chain/graphs/contributors )
618
642
619
643
Made with [ contrib.rocks] ( https://contrib.rocks ) .
644
+
645
+ ### Fixture Licenses
646
+
647
+ For testing multi-modal features, the repository contains binary media content, with the following owners and licenses:
648
+
649
+ * ` tests/Fixture/image.jpg ` : Chris F., Creative Commons, see [ pexels.com] ( https://www.pexels.com/photo/blauer-und-gruner-elefant-mit-licht-1680755/ )
650
+ * ` tests/Fixture/audio.mp3 ` : davidbain, Creative Commons, see [ freesound.org] ( https://freesound.org/people/davidbain/sounds/136777/ )
0 commit comments