When I use realtime models, agent doesnt start wit...
# ask-ai
d
When I use realtime models, agent doesnt start with greeting, it jumps into conversation without greeting
t
Thanks for reaching out, Ibragim. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Realtime models in LiveKit do not automatically start with a greeting because they are designed to wait for user input before responding. However, you can configure them to initiate a greeting using one of the following methods: • Use the
generate_reply()
Method:
In multimodal agents, you can trigger an initial response by calling the
generate_reply()
method after starting the agent. For example:
Copy code
agent = MultimodalAgent(model=model, chat_ctx=chat_ctx)
agent.start(ctx.room, participant)

# Enable the agent to speak first
agent.generate_reply()
• Create a Custom
say
Method:
You can implement a custom
say
method to enable the agent to greet users. For example:
Copy code
async def say(self, message: str):
    if self.model and hasattr(self.model, 'sessions'):
        session = self.model.sessions[0]
        session.conversation.item.create(
            llm.ChatMessage(
                role="assistant",
                content=f"Using your voice to respond, please say: {message}"
            )
        )
        session.response.create()
• Use Conversation Items (Node.js): In Node.js implementations, you can manually create conversation items and trigger responses. For example:
Copy code
session.conversation.item.create(
  llm.ChatMessage.create({
    role: llm.ChatRole.USER,
    text: 'Say "How can I help you today?"',
  }),
);
session.response.create();
These approaches allow you to customize the behavior of realtime models to include an initial greeting. Sources: plugins/openai/src/realtime/realtime_model.ts