diff --git a/demo/config/packages/ai.yaml b/demo/config/packages/ai.yaml index c2b38bdbd..0f6e4521a 100644 --- a/demo/config/packages/ai.yaml +++ b/demo/config/packages/ai.yaml @@ -39,12 +39,19 @@ ai: audio: platform: 'ai.platform.openai' model: 'gpt-4o-mini?temperature=1.0' - prompt: 'You are a friendly chatbot that likes to have a conversation with users and asks them some questions.' + prompt: | + You are a friendly, positive and energetic voice assistant. You can engage in light discussions, ask + questions, and do general small-talk. If asked about the Symfony Framework or their community events, + you delegate to your subagent "symfony_blog" and use their answer for answering user's questions. + If you don't know the answer, say so. Keep in mind that you are in a spoken conversation, so keep your + answers concise and to the point. They will be read out loud to the user. tools: # Agent in agent 🤯 - agent: 'blog' name: 'symfony_blog' - description: 'Can answer questions based on the Symfony blog.' + description: | + Subagent, that can answer questions about latest news around the Symfony Framework, like latest + features, events or community news. orchestrator: platform: 'ai.platform.openai' model: 'gpt-4o-mini' diff --git a/demo/src/Audio/Chat.php b/demo/src/Audio/Chat.php index ff40a335a..34d3ba36a 100644 --- a/demo/src/Audio/Chat.php +++ b/demo/src/Audio/Chat.php @@ -12,6 +12,7 @@ namespace App\Audio; use Symfony\AI\Agent\AgentInterface; +use Symfony\AI\Platform\Bridge\OpenAi\TextToSpeech\Voice; use Symfony\AI\Platform\Message\Content\Audio; use Symfony\AI\Platform\Message\Message; use Symfony\AI\Platform\Message\MessageBag; @@ -58,7 +59,14 @@ public function submitMessage(string $message): void \assert($result instanceof TextResult); - $messages->add(Message::ofAssistant($result->getContent())); + $assistantMessage = Message::ofAssistant($result->getContent()); + $messages->add($assistantMessage); + + $result = $this->platform->invoke('tts-1', $result->getContent(), [ + 'voice' => Voice::CORAL, + 'instructions' => 'Speak in a cheerful and positive tone.', + ]); + $assistantMessage->getMetadata()->add('audio', $result->asDataUri('audio/mpeg')); $this->saveMessages($messages); } diff --git a/demo/templates/components/audio.html.twig b/demo/templates/components/audio.html.twig index 303b59b34..0cbff084a 100644 --- a/demo/templates/components/audio.html.twig +++ b/demo/templates/components/audio.html.twig @@ -1,4 +1,4 @@ -{% import "_message.html.twig" as message %} +{% import "_message.html.twig" as msg %}