@@ -73,7 +73,7 @@ The core feature of LLM Chain is to interact with language models via messages.
7373a ** MessageBag** to a ** Chain** , which takes care of LLM invocation and response handling.
7474
7575Messages 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 ` .
7777
7878#### Example Chain call with messages
7979
@@ -453,13 +453,13 @@ use PhpLlm\LlmChain\Model\Message\Content\Image;
453453use PhpLlm\LlmChain\Model\Message\Message;
454454use PhpLlm\LlmChain\Model\Message\MessageBag;
455455
456- // Initialize Platoform , LLM & Chain
456+ // Initialize Platform , LLM & Chain
457457
458458$messages = new MessageBag(
459459 Message::forSystem('You are an image analyzer bot that helps identify the content of images.'),
460460 Message::ofUser(
461461 '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
463463 new Image('https://foo.com/bar.png'), // URL to an image
464464 new Image('data:image/png;base64,...'), // Data URL of an image
465465 ),
@@ -472,6 +472,30 @@ $response = $chain->call($messages);
4724721 . ** Image Description** : [ image-describer-binary.php] ( examples/image-describer-binary.php ) (with binary file)
4734731 . ** Image Description** : [ image-describer-url.php] ( examples/image-describer-url.php ) (with URL)
474474
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+
475499### Embeddings
476500
477501Creating 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
617641[ ![ LLM Chain Contributors] ( https://contrib.rocks/image?repo=php-llm/llm-chain ' LLM Chain Contributors ')] ( https://github.com/php-llm/llm-chain/graphs/contributors )
618642
619643Made 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