DingRTC AIAgent interfaces

更新时间:
复制 MD 格式

This topic describes the DingRTC Web AIAgent SDK interfaces.

Data types

Type

Description

Minimum supported version

AgentStatus

AIAgent status

3.9.0

AIAgentMessage

AIAgent message struct

3.9.0

API list

API

Description

Minimum supported version

startPushToTalk()

Notifies the agent that the local user started push-to-talk.

3.9.0

stopPushToTalk()

Notifies the agent that the local user stopped push-to-talk.

3.9.0

cancelPushToTalk()

Notifies the agent that the local user canceled push-to-talk.

3.9.0

interrupt()

Interrupts the agent.

3.9.0

Event list

DingRTC global events

Event

Callback type

Description

Version

"message"

(messgae: AIAgentMessage) => void;

Notification for a published agent message.

3.9.0

"agent-status"

(newStatus: AgentStatus) => void

Notification for an agent status change.

3.9.0

Data types

AgentStatus

The current status of the agent. Type: string (enum-like)

Indicator

Description

Version

'listening'

The agent is listening for user input.

3.9.0

'thinking'

The agent is thinking.

3.9.0

'responding'

The agent is sending a response.

3.9.0

AIAgentMessage

The structure of an AIAgent message.

Property

Type

Description

Version

message

Uint8Array

Message payload.

3.9.0

uid

string

The UID of the publisher.

3.9.0

reasoning

boolean

Indicates whether this is an inference procedure.

3.9.0

userType

'user' | 'agent'

The publisher type.

3.9.0

end

boolean

Indicates whether the current sentence is complete. This is used for sentence segmentation.

3.9.0

extra

string

Custom content for an inserted message.

3.9.0

API details

startPushToTalk()

Notifies the agent that the local user has started push-to-talk.

Type signature

 startPushToTalk():void;

Back

void

stopPushToTalk()

Notifies the agent that the local user has stopped push-to-talk.

Type signature

stopPushToTalk(): void;

Returns

void

cancelPushToTalk()

Notifies the agent that the local user has canceled push-to-talk.

Type signature

cancelPushToTalk(): void;

Returns

void

interrupt()

Interrupts the agent.

Type signature

interrupt(): void;

Returns

void

Event details

"message"

Receive a message published remotely

Type signature

'message': (message: AIAgentMessage) => void;

Example

rtm.on('message', (message) => {
 console.log(message);
});

"agent-status"

Agent status received

Type signature

'agent-status': (agentStatus: AgentStatus) => void;

Example

rtm.on('agent-status', (status) => {
 console.log(status);
});