Ask a question to get started
Enter to send•Shift+Enter new line
BaseMessage( self, content: str | list[str | dict] |
Serializable
A map of constructor argument names to secret ids.
List of attribute names that should be included in the serialized kwargs.
Return a unique identifier for this class for serialization purposes.
Serialize the object to JSON.
Serialize a "not implemented" object.
content
str | list[str | dict] | None
None
The contents of the message.
content_blocks
list[types.ContentBlock] | None
**kwargs
Any
{}
Reserved for additional payload data associated with the message.
For example, for a message from an AI, this could include tool calls as encoded by the model provider.
Examples: response headers, logprobs, token counts, model name.
The type of the message. Must be a string that is unique to the message type.
The purpose of this field is to allow for easy identification of the message type when deserializing messages.
An optional name for the message.
This can be used to provide a human-readable name for the message.
Usage of this field is optional, and whether it's used or not is up to the model implementation.
An optional unique identifier for the message.
This should ideally be provided by the provider/model which created the message.
Load content blocks from the message content.
Get the text content of the message as a string.
Can be used as both property (message.text) and method (message.text()).
message.text
message.text()
Handles both string and list content types (e.g. for content blocks). Only extracts blocks with type: 'text'; other block types are ignored.
type: 'text'
As of langchain-core 1.0.0, calling .text() as a method is deprecated. Use .text as a property instead. This method will be removed in 2.0.0.
langchain-core
.text()
.text
BaseMessage is serializable.
BaseMessage
Get the namespace of the LangChain object.
Get a pretty representation of the message.
Print a pretty representation of the message.
Base abstract message class.
Messages are the inputs and outputs of a chat model.
Examples include HumanMessage, AIMessage, and SystemMessage.
HumanMessage
AIMessage
SystemMessage
Typed standard content.
Additional arguments to pass to the parent class.