BaseMessage
Base class for all types of messages in a conversation. It includes
properties like content, name, and additional_kwargs. It also
includes methods like toDict() and _getType().
import type { BaseMessage } from '@threadplane/middleware/langgraph';Declaration
declare abstract class BaseMessage<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends Serializable implements Message<TStructure, TRole> {
readonly [MESSAGE_SYMBOL]: true;
_getType(): MessageType;
get _printableFields(): Record<string, unknown>;
_updateId(value: string | undefined): void;
static [Symbol.hasInstance](obj: unknown): obj is BaseMessage<MessageStructure<MessageToolSet>, MessageType>;
get [Symbol.toStringTag](): any;
constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);
additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>["additional_kwargs"]>;
content: $InferMessageContent<TStructure, TRole>;
get contentBlocks(): Array<ContentBlock.Standard>;
getType(): MessageType;
id?: string;
static isInstance(obj: unknown): obj is BaseMessage;
get lc_aliases(): Record<string, string>;
static lc_name(): string;
lc_namespace: string[];
lc_serializable: boolean;
name?: string;
response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>["response_metadata"]>;
get text(): string;
toDict(): StoredMessage;
toFormattedString(format?: MessageStringFormat): string;
abstract readonly type: TRole;
}Type parameters
TStructureMessageStructureDefault:MessageStructureTRoleMessageTypeDefault:MessageType
Members
__computed
readonly [MESSAGE_SYMBOL]: true;_getType · overload 1
Deprecated
Use .getType() instead or import the proper typeguard. For example:
import { isAIMessage } from "@langchain/core/messages";
const message = new AIMessage("Hello!");
isAIMessage(message); // true_getType(): MessageType;Returns
MessageType_printableFields
get _printableFields(): Record<string, unknown>;_updateId · overload 1
_updateId(value: string | undefined): void;Parameters
value· requiredstring | undefined
Returns
void[Symbol.hasInstance] · overload 1
static [Symbol.hasInstance](obj: unknown): obj is BaseMessage<MessageStructure<MessageToolSet>, MessageType>;Parameters
obj· requiredunknown
Returns
obj is BaseMessage<MessageStructure<MessageToolSet>, MessageType>[Symbol.toStringTag]
get [Symbol.toStringTag](): any;Constructor · overload 1
Constructs a new instance of the BaseMessage class
constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);Parameters
arg· required$InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>
additional_kwargs
additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>["additional_kwargs"]>;content
content: $InferMessageContent<TStructure, TRole>;contentBlocks
get contentBlocks(): Array<ContentBlock.Standard>;getType · overload 1
Deprecated
Use .type instead The type of the message.
getType(): MessageType;Returns
MessageTypeid
id?: string;isInstance · overload 1
static isInstance(obj: unknown): obj is BaseMessage;Parameters
obj· requiredunknown
Returns
obj is BaseMessagelc_aliases
get lc_aliases(): Record<string, string>;lc_name · overload 1
static lc_name(): string;Returns
stringlc_namespace
lc_namespace: string[];lc_serializable
lc_serializable: boolean;name
name?: string;response_metadata
response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>["response_metadata"]>;text
Get text content of the message.
get text(): string;toDict · overload 1
toDict(): StoredMessage;Returns
StoredMessagetoFormattedString · overload 1
toFormattedString(format?: MessageStringFormat): string;Parameters
format· optionalMessageStringFormat
Returns
stringtype
abstract readonly type: TRole;