I'm registering the agent in railway Actually it'...
# ask-ai
s
I'm registering the agent in railway Actually it's single project and multiple container are running for different personalities, and different languages how can i connect with the particular perosnality and language which i need
t
Thanks for reaching out, Venkateshwara. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're exploring how to connect to a specific personality and language in your multi-container setup! Here's a friendly guide to help you through the process: 1. First, set up the agent with clear instructions and language configurations. For example:
Copy code
session = 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:
Copy code
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:
Copy code
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.py
s
how would i connect it from the frontend
t
Hi there! To help you connect to a specific personality and language from the frontend, here’s a friendly step-by-step guide: 1. Use Presets for Personality and Language: Start by setting up presets in your frontend that define the agent’s personality and language. Each preset should include: • `instructions`: This sets the agent’s personality, like "Maria, a native Spanish speaker from Guadalajara". • `voice`: Choose a TTS voice model that fits. • `sessionConfig`: Make sure it includes TTS and STT settings that match the language. 1. Pass Language Preferences via Participant Attributes: When you generate the token for the frontend, add metadata for the user’s language preferences. For example:
Copy code
const 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:
Copy code
<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:
Copy code
@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