curved-monitor-89515
02/25/2025, 6:25 PMconst agent = new multimodal.MultimodalAgent({ model });
const session = await agent
.start(ctx.room, participant)
.then((session) => session);
session.conversation.item.create(llm.ChatMessage.create({
role: llm.ChatRole.ASSISTANT,
text: 'Good morning',
}));
session.response.create();
gray-monkey-83525
02/25/2025, 6:25 PMsession.conversation.item.create
method is used to append the message to the conversation, and session.response.create
triggers the LLM to generate a response based on the updated conversation context.
Would you like more detail on how this process works?
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1729541882.418149 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.curved-monitor-89515
02/25/2025, 6:27 PMgray-monkey-83525
02/25/2025, 6:27 PMcurved-monitor-89515
02/25/2025, 6:30 PMgray-monkey-83525
02/25/2025, 6:30 PMcurved-monitor-89515
02/25/2025, 6:32 PMgray-monkey-83525
02/25/2025, 6:32 PMsession.conversation.item.create
method to add the greeting message to the conversation history.
3. Directly Use TTS for Speaking: Instead of relying on the LLM to generate the initial response, use a TTS service to directly speak the greeting.
Here's a simplified example:
const { MultimodalAgent } = require('@livekit/agents');
const { ChatMessage, ChatRole } = require('@livekit/agents/llm');
async function startAgent(ctx, participant) {
const agent = new MultimodalAgent({ model });
const session = await agent.start(ctx.room, participant);
// Add greeting to conversation history
session.conversation.item.create(ChatMessage.create({
role: ChatRole.ASSISTANT,
text: 'Good morning',
}));
// Directly use TTS to speak the greeting
await ttsService.speak('Good morning');
}
startAgent(ctx, participant);
In this example, ttsService.speak
is a placeholder for whatever TTS service you are using to output the audio. You would replace this with the actual method call to your TTS service.
Would you like more detail on integrating a specific TTS service?
Sources:
- https://docs.livekit.io/agents/openai/multimodal-agent/
- https://docs.livekit.io/agents/openai/multimodalagent/ 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.