``` lkapi = api.LiveKitAPI() crea...
# ask-ai
b
Copy code
lkapi = api.LiveKitAPI() 

        created_room_info = await lkapi.room.create_room(
            api.CreateRoomRequest(name=room_name, agents=[agentName])
        )
error:
Copy code
Failed to create room: Parameter to MergeFrom() must be instance of same class: expected <class 'agent_dispatch.RoomAgentDispatch'> got <class 'str'>.
Parameter to MergeFrom() must be instance of same class: expected <class 'agent_dispatch.RoomAgentDispatch'> got <class 'str'>.
what is the solve for this ?
g
The error indicates that the
agents
parameter in
CreateRoomRequest
expects an instance of
RoomAgentDispatch
, not a string. You need to create a
RoomAgentDispatch
object and pass it to the
agents
parameter. Here's how you can modify your code:
Copy code
from livekit.api import RoomAgentDispatch

# Create a RoomAgentDispatch object
agent_dispatch = RoomAgentDispatch(agent_name=agentName)

# Pass the RoomAgentDispatch object to the agents parameter
created_room_info = await lkapi.room.create_room(
    api.CreateRoomRequest(name=room_name, agents=[agent_dispatch])
)
Would you like more details on this? Sources: - https://livekit-users.slack.com/archives/C07FY8WHGPM/p1728956116.368569 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.