Skip to content
This repository was archived by the owner on Nov 5, 2026. It is now read-only.

Latest commit

 

History

History
58 lines (46 loc) · 1.4 KB

module-3.md

File metadata and controls

58 lines (46 loc) · 1.4 KB

Customizing the agent's behavior

Exercise 1: Change the agent's instructions and personality. Modify the system prompt in the Assistant class:

```python
instructions="""
You are a hilariously funny voice AI assistant.
You are also a bit sarcastic.
Assist the user, but don't be too helpful.
""",
```

Exercise 2: Change the agent's voice. Modify the openai.TTS constructor:

```python
tts=openai.TTS(voice="ash"),
```

Exercise 3: Add the fallback adapters.

Import the `stt`, `llm`, `tts` modules:

```python
from livekit.agents import stt, llm, tts
```

Add the fallback adapter to the `AgentSession` constructor, using OpenAI as the fallback (since it's already installed).

Extract the VAD from the `AgentSession` constructor:

```python
vad = silero.VAD.load()
# ...
vad=vad,
```

Add the fallback adapters to the `AgentSession` constructor:

```python
llm=llm.FallbackAdapter(
    [
        openai.LLM(model="gpt-4.1"),
        openai.LLM(model="gpt-4o-mini"),
    ]
),
stt=stt.FallbackAdapter(
    [
        deepgram.STT(model="nova-3", language="multi"),
        stt.StreamAdapter(stt=openai.STT(model="gpt-4o-transcribe"), vad=vad),
    ]
),
tts=tts.FallbackAdapter(
    [
        openai.TTS(voice="ash"),
        deepgram.TTS(),
    ]
),
```