_get_message_type_str() — langchain Function Reference
Architecture documentation for the _get_message_type_str() function in utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 1af2071a_e678_b8cd_900b_54874aebb4bc["_get_message_type_str()"] 0b528c80_0ce7_1c74_8932_bc433bcb03c6["utils.py"] 1af2071a_e678_b8cd_900b_54874aebb4bc -->|defined in| 0b528c80_0ce7_1c74_8932_bc433bcb03c6 cbb21a1a_871c_8af4_2881_e51d99e3c0a1["get_buffer_string()"] cbb21a1a_871c_8af4_2881_e51d99e3c0a1 -->|calls| 1af2071a_e678_b8cd_900b_54874aebb4bc style 1af2071a_e678_b8cd_900b_54874aebb4bc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/messages/utils.py lines 247–284
def _get_message_type_str(
m: BaseMessage,
human_prefix: str,
ai_prefix: str,
system_prefix: str,
function_prefix: str,
tool_prefix: str,
) -> str:
"""Get the type string for XML message element.
Args:
m: The message to get the type string for.
human_prefix: The prefix to use for `HumanMessage`.
ai_prefix: The prefix to use for `AIMessage`.
system_prefix: The prefix to use for `SystemMessage`.
function_prefix: The prefix to use for `FunctionMessage`.
tool_prefix: The prefix to use for `ToolMessage`.
Returns:
The type string for the message element.
Raises:
ValueError: If an unsupported message type is encountered.
"""
if isinstance(m, HumanMessage):
return human_prefix.lower()
if isinstance(m, AIMessage):
return ai_prefix.lower()
if isinstance(m, SystemMessage):
return system_prefix.lower()
if isinstance(m, FunctionMessage):
return function_prefix.lower()
if isinstance(m, ToolMessage):
return tool_prefix.lower()
if isinstance(m, ChatMessage):
return m.role
msg = f"Got unsupported message type: {m}"
raise ValueError(msg)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _get_message_type_str() do?
_get_message_type_str() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/utils.py.
Where is _get_message_type_str() defined?
_get_message_type_str() is defined in libs/core/langchain_core/messages/utils.py at line 247.
What calls _get_message_type_str()?
_get_message_type_str() is called by 1 function(s): get_buffer_string.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free