LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coremessagessystemSystemMessage
    Class●Since v0.1

    SystemMessage

    Copy
    SystemMessage(
      self,
      content: str | list[str | dict] |

    Bases

    BaseMessage

    Used in Docs

    • Agents
    • Build a SQL assistant with on-demand skills
    • Custom middleware
    • Messages
    • Models
    (25 more not shown)

    Constructors

    Attributes

    Inherited fromBaseMessage

    Attributes

    Acontent: str | list[str | dict]
    —

    The contents of the message.

    Aadditional_kwargs: dict
    —

    Reserved for additional payload data associated with the message.

    Aresponse_metadata: dict
    —

    Examples: response headers, logprobs, token counts, model name.

    View source on GitHub
    None
    =
    None
    ,
    content_blocks
    :
    list
    [
    types
    .
    ContentBlock
    ]
    |
    None
    =
    None
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    A
    name
    : str | None
    —

    An optional name for the message.

    Aid: str | None
    —

    An optional unique identifier for the message.

    Amodel_config
    Acontent_blocks: list[types.ContentBlock]
    —

    Load content blocks from the message content.

    Atext: TextAccessor
    —

    Get the text content of the message as a string.

    Methods

    Mis_lc_serializable
    —

    BaseMessage is serializable.

    Mget_lc_namespace
    —

    Get the namespace of the LangChain object.

    Mpretty_repr
    —

    Get a pretty representation of the message.

    Mpretty_print
    —

    Print a pretty representation of the message.

    Inherited fromSerializable

    Attributes

    Alc_secrets: dict[str, str]
    —

    A map of constructor argument names to secret ids.

    Alc_attributes: dict
    —

    List of attribute names that should be included in the serialized kwargs.

    Amodel_config

    Methods

    Mis_lc_serializable
    —

    Is this class serializable?

    Mget_lc_namespace
    —

    Get the namespace of the LangChain object.

    Mlc_id
    —

    Return a unique identifier for this class for serialization purposes.

    Mto_json
    —

    Serialize the object to JSON.

    Mto_json_not_implemented
    —

    Serialize a "not implemented" object.

    constructor
    __init__
    NameType
    contentstr | list[str | dict] | None
    content_blockslist[types.ContentBlock] | None
    attribute
    type: Literal['system']

    The type of the message (used for serialization).

    Message for priming AI behavior.

    The system message is usually passed in as the first of a sequence of input messages.

    Example:

    from langchain_core.messages import HumanMessage, SystemMessage
    
    messages = [
        SystemMessage(content="You are a helpful assistant! Your name is Bob."),
        HumanMessage(content="What is your name?"),
    ]
    
    # Define a chat model and invoke it with the messages
    print(model.invoke(messages))