salmon-airplane-11201
10/01/2025, 7:09 AMtall-airline-16756
10/01/2025, 7:09 AMtall-airline-16756
10/01/2025, 7:10 AMsession = AgentSession(
vad=silero.VAD.load(),
llm=_create_llm(),
stt=_create_stt(),
tts=_create_tts(),
turn_detection=MultilingualModel()
)
1. Next, define the personality instructions when you initialize the agent. Here's how you might do it:
agent = Agent(
instructions="""Your knowledge cutoff is 2023-10. You are a helpful, witty, and friendly AI. Act like a human, but remember that you aren't a human and that you can't do human things in the real world. Your voice and personality should be warm and engaging, with a lively and playful tone."""
)
1. Finally, for switching languages smoothly, you can dynamically update the STT and TTS options like this:
self.tts.update_options(language=language_code)
self.stt.update_options(language=deepgram_language)
If anything feels unclear or if you'd like a hand with any step, please don't hesitate to reach out. I'm here to help you every step of the way!
Sources: livekit-plugins/livekit-plugins-azure/livekit/plugins/azure/stt.py | web/src/data/presets.ts | complex-agents/testing/agent_test.pysalmon-airplane-11201
10/01/2025, 7:34 AMtall-airline-16756
10/01/2025, 7:34 AMconst token = new Token(apiKey, secret, {
identity: 'user123',
name: 'User One',
metadata: JSON.stringify({ 'user.language': 'es' })
});
1. Frontend Connection: Use LiveKit’s SDK to connect to the room and pass along the token like this:
<livekitroom serverurl="{wsUrl}" token="{token}" connect="{true}">
<assistant/>
<roomaudiorenderer/>
</livekitroom>
1. Dynamic Language Switching: If you want to switch the agent’s language during a session, the backend can do this dynamically using function tools like so:
@function_tool
async def switch_to_spanish(self):
await self._switch_language("es")
If you have any questions or need a hand with the implementation, just let me know—I’m here to help!
Sources: complex-agents/shopify-voice-shopper/shopify-voice-frontend/app/page.tsx | Inside a session | LiveKit Docs | Generating tokens | LiveKit Docs | web/src/data/presets.ts | livekit-plugins/livekit-plugins-baseten/livekit/plugins/baseten/stt.py