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-corepromptschatChatMessagePromptTemplate
    Class●Since v0.1

    ChatMessagePromptTemplate

    Chat message prompt template.

    Copy
    ChatMessagePromptTemplate(
      self,
      *args: Any = (),
      **kwargs: Any = {}
    )

    Bases

    BaseStringMessagePromptTemplate

    Attributes

    attribute
    role: str

    Role of the message.

    Methods

    method
    format

    Format the prompt template.

    method
    aformat

    Async format the prompt template.

    Inherited fromBaseStringMessagePromptTemplate

    Attributes

    Aprompt: StringPromptTemplate
    —

    String prompt template.

    Aadditional_kwargs: dict
    —

    Currently inherited from BaseMessage, but not used.

    Ainput_variables: list[str]
    —

    Template input variables.

    Methods

    Mfrom_template
    —

    Create a class from a string template.

    Mfrom_template_file
    —

    Create a class from a template file.

    Mformat_messages
    —

    Format messages from kwargs.

    Maformat_messages
    —

    Async format messages from kwargs.

    Mpretty_repr
    —

    Return a pretty representation of the message for display.

    Inherited fromBaseMessagePromptTemplate

    Attributes

    Ainput_variables: list[str]
    —

    Template input variables.

    Methods

    Mis_lc_serializable
    —

    Return True as this class is serializable.

    Mget_lc_namespace
    —

    Get the namespace of the LangChain object.

    Mformat_messages
    —

    Format messages from kwargs.

    Maformat_messages
    —

    Async format messages from kwargs.

    Mpretty_repr
    —

    Return a pretty representation of the message for display.

    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
    —

    Return True as this class is 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
    —

    Convert the graph to a JSON-serializable format.

    Mto_json_not_implemented
    —

    Serialize a "not implemented" object.

    View source on GitHub