langchain.schema.messages.get_buffer_string¶
langchain.schema.messages.get_buffer_string(messages: Sequence[BaseMessage], human_prefix: str = 'Human', ai_prefix: str = 'AI') → str[source]¶
Convert sequence of Messages to strings and concatenate them into one string.
Args:messages: Messages to be converted to strings.
human_prefix: The prefix to prepend to contents of HumanMessages.
ai_prefix: THe prefix to prepend to contents of AIMessages.
Returns:A single string concatenation of all input messages.
Example:from langchain.schema import AIMessage, HumanMessage
messages = [
    HumanMessage(content="Hi, how are you?"),
    AIMessage(content="Good, how are you?"),
]
get_buffer_string(messages)
# -> "Human: Hi, how are you?
AI: Good, how are you?”