Skip to main content

InworldPacket

Module: Inworld.AI. Namespace: Inworld.Packet.

This is the base class for packets sending and receiving from Inworld runtime server.

Variables

VariablesDescription
timestampThe timestamp of the packet.
typeThe type of the packet.
packetIdThe PacketId of the packet.
routingThe Routing of the packet.

Properties

PropertiesDescription
OutgoingTargetsKey/Value Pair for targets to send.
Key is character's full name.
Value is its agent ID (Nullable. We'll fetch it in the UpdateSessionInfo)
ToJsonGenerates the string of json to send to the Inworld server.
SourceGets the SourceType of the source.
IsBroadCastReturns if this packet is broadcasting (targets multiple characters).
SourceNameReturns the agent ID of the source.
TargetNameReturns the agent ID of the target.

API

FunctionDescriptionParameters
PreprocessUsed when creating packets. Depending on the current situation is group chat or single character.
PrepareToSendOriginally OnDequeue in OutgoingPacket.
Always call it before send to fetch the agent ID.
UpdateSessionInfoUpdate the characters in this conversation with updated ID.
Returns the brain name of the characters not found in the current session.
UpdateRoutingUpdate the routing and compose the packet based on the session info.
IsSourceCheck if the agentID is in the source.agentID: target agent ID.
IsTargetCheck if the agentID is in the target or targets.agentID: target agent ID.
IsRelatedCheck if the agentID is either in the target list, is the target, or is the source.agentID: target agent ID.

Source

Module: Inworld.AI. Namespace: Inworld.Packet.

This class defines the format of the sender or the receiver.

VariablesDescription
typeAn enumeration that determines whether this source is a player or a character.
nameThe name of the source. If it's a player, this value should be PLAYER; if it's a character, its value should be the agentID of the character.

Routing

Module: Inworld.AI. Namespace: Inworld.Packet.

This class determines the flow of the packet.

VariablesDescription
sourceThe Source that sent this packet.
targetThe Source that received this packet.
targetsThe list of the Sources that received this packet.

PacketId

Module: Inworld.AI. Namespace: Inworld.Packet.

The PacketId class encapsulates identifiers used to manage different aspects of interactions within the system. These identifiers help track and organize communication between components.

VariablesDescription
packetIdA unique ID assigned to each packet, distinguishing it from others.
utteranceIdRepresents an individual sentence or unit of communication within a conversation. Each utterance may encompass various types of behavior, such as text messages, emotion changes, audio data, and more.
interactionIdRefers to a group of related sentences that are part of a larger interaction. An interaction may consist of multiple utterances.
correlationIdUsed in callback for server packets.
conversationIdUsed in sending group chat packets.
PropertiesDescription
ToStringGets a formatted string that combines the packet's status, interaction ID, utterance ID, and packet ID. The format is $"{Status} I: {interactionId} U: {utteranceId} P: {packetId}"