Interface IConversationMessage

Represents a single message within a conversation.

Follows OpenAI's chat completion message format for compatibility with LLM providers.

IConversationMessage

Example

const userMessage: IConversationMessage = {
id: 'msg-001',
conversationId: 'conv-123',
role: 'user',
content: 'What is TypeScript?',
timestamp: Date.now()
};

const assistantMessage: IConversationMessage = {
id: 'msg-002',
conversationId: 'conv-123',
role: 'assistant',
content: 'TypeScript is a typed superset of JavaScript...',
timestamp: Date.now(),
model: 'gpt-4o',
usage: { promptTokens: 10, completionTokens: 50, totalTokens: 60 }
};
interface IConversationMessage {
    id: string;
    conversationId: string;
    role: "tool" | "system" | "user" | "assistant";
    content: string;
    timestamp: number;
    model?: string;
    usage?: ITokenUsage;
    toolCalls?: any[];
    toolCallId?: string;
    name?: string;
    metadata?: Record<string, any>;
}

Properties

id: string

Unique identifier for the message

conversationId: string

ID of the conversation this message belongs to

role: "tool" | "system" | "user" | "assistant"

Message role in conversation

content: string

The text content of the message

timestamp: number

Unix timestamp (milliseconds) when message was created

model?: string

LLM model used to generate this message (for assistant messages)

usage?: ITokenUsage

Token usage statistics for this message

toolCalls?: any[]

Tool/function calls made in this message

toolCallId?: string

ID linking this message to a tool call response

name?: string

Name field for tool/function messages

metadata?: Record<string, any>

Additional metadata for extensibility