Skip to main content

Data Formats

User

type User = {
id: TID;
name: string;
avatar?: string;
}
  • id - Unique identifier for the user.
  • name - Name of the user.
  • avatar - Optional URL to the user's avatar image.

Agent

type ResponseHandler = (data: Message[]) => Message | Promise<Message>;

type Agent = {
id: TID;
name: string;
avatar?: string;
response?: ResponseHandler;
}
  • id - Unique identifier for the agent.
  • name - Name of the agent.
  • avatar - Optional URL to the agent's avatar image.
  • response - Optional response handler that triggers when the agent receives a new message. The handler can return a response message or a promise of a response message.

Chat

type Chat = {
id: TID;
agent: TID;
theme: string;
created: Date;
}
  • id - Unique identifier for the chat.
  • agent - Unique identifier for the agent associated with the chat.
  • theme - Topic or theme of the chat.
  • created - Date when the chat was created.

Message

type Message = {
id: TID;
role: "agent" | "user";
content: string;
typing?: number;
}
  • id - Unique identifier for the message.
  • role - Role of the message sender, either "agent" or "user".
  • content - Text content of the message.
  • typing - Optional field to indicate typing animation.
    • 0 - No typing animation (default).
    • 1 - Typing animation in streaming mode.
    • -1 - Typing animation in finishing mode.