Class: LiveKit::AgentDispatchServiceClient
- Inherits:
-
Twirp::Client
- Object
- Twirp::Client
- LiveKit::AgentDispatchServiceClient
- Includes:
- AuthMixin
- Defined in:
- lib/livekit/agent_dispatch_service_client.rb
Overview
Client for LiveKit’s Agent Dispatch Service, which manages agent assignments to rooms This client handles creating, deleting, and retrieving agent dispatches
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
Instance Method Summary collapse
-
#create_dispatch(room_name, agent_name, metadata: nil) ⇒ LiveKit::Proto::AgentDispatch
Creates a new agent dispatch for a named agent.
-
#delete_dispatch(dispatch_id, room_name) ⇒ LiveKit::Proto::AgentDispatch
Deletes an existing agent dispatch.
-
#get_dispatch(dispatch_id, room_name) ⇒ LiveKit::Proto::AgentDispatch?
Retrieves a specific agent dispatch by ID.
-
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ AgentDispatchServiceClient
constructor
A new instance of AgentDispatchServiceClient.
-
#list_dispatch(room_name) ⇒ Array<LiveKit::Proto::AgentDispatch>
Lists all agent dispatches for a specific room.
Methods included from AuthMixin
Constructor Details
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ AgentDispatchServiceClient
Returns a new instance of AgentDispatchServiceClient.
13 14 15 16 17 |
# File 'lib/livekit/agent_dispatch_service_client.rb', line 13 def initialize(base_url, api_key: nil, api_secret: nil) super(File.join(Utils.to_http_url(base_url), "/twirp")) @api_key = api_key @api_secret = api_secret end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/livekit/agent_dispatch_service_client.rb', line 11 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
11 12 13 |
# File 'lib/livekit/agent_dispatch_service_client.rb', line 11 def api_secret @api_secret end |
Instance Method Details
#create_dispatch(room_name, agent_name, metadata: nil) ⇒ LiveKit::Proto::AgentDispatch
Creates a new agent dispatch for a named agent
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/livekit/agent_dispatch_service_client.rb', line 24 def create_dispatch( # room to dispatch agent to room_name, # agent to dispatch agent_name, # optional, metadata to send along with the job metadata: nil ) request = Proto::CreateAgentDispatchRequest.new( room: room_name, agent_name: agent_name, metadata: , ) self.rpc( :CreateDispatch, request, headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), ) end |
#delete_dispatch(dispatch_id, room_name) ⇒ LiveKit::Proto::AgentDispatch
Deletes an existing agent dispatch
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/livekit/agent_dispatch_service_client.rb', line 48 def delete_dispatch(dispatch_id, room_name) request = Proto::DeleteAgentDispatchRequest.new( dispatch_id: dispatch_id, room: room_name, ) self.rpc( :DeleteDispatch, request, headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), ) end |
#get_dispatch(dispatch_id, room_name) ⇒ LiveKit::Proto::AgentDispatch?
Retrieves a specific agent dispatch by ID
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/livekit/agent_dispatch_service_client.rb', line 64 def get_dispatch(dispatch_id, room_name) request = Proto::ListAgentDispatchRequest.new( dispatch_id: dispatch_id, room: room_name, ) res = self.rpc( :ListDispatch, request, headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), ) if res.agent_dispatches.size > 0 return res.agent_dispatches[0] end nil end |
#list_dispatch(room_name) ⇒ Array<LiveKit::Proto::AgentDispatch>
Lists all agent dispatches for a specific room
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/livekit/agent_dispatch_service_client.rb', line 83 def list_dispatch(room_name) request = Proto::ListAgentDispatchRequest.new( room: room_name, ) res = self.rpc( :ListDispatch, request, headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), ) res.agent_dispatches end |