_to_chatml_format() — langchain Function Reference
Architecture documentation for the _to_chatml_format() function in huggingface.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD e1c74edc_c011_1562_1576_22097f85b128["_to_chatml_format()"] 8cf0d6c0_abf8_3ee2_fd00_8bfc8c02058a["ChatHuggingFace"] e1c74edc_c011_1562_1576_22097f85b128 -->|defined in| 8cf0d6c0_abf8_3ee2_fd00_8bfc8c02058a e77e373b_eb20_e566_3771_32082ca0dcc2["_to_chat_prompt()"] e77e373b_eb20_e566_3771_32082ca0dcc2 -->|calls| e1c74edc_c011_1562_1576_22097f85b128 style e1c74edc_c011_1562_1576_22097f85b128 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py lines 966–978
def _to_chatml_format(self, message: BaseMessage) -> dict:
"""Convert LangChain message to ChatML format."""
if isinstance(message, SystemMessage):
role = "system"
elif isinstance(message, AIMessage):
role = "assistant"
elif isinstance(message, HumanMessage):
role = "user"
else:
msg = f"Unknown message type: {type(message)}"
raise ValueError(msg)
return {"role": role, "content": message.content}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _to_chatml_format() do?
_to_chatml_format() is a function in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py.
Where is _to_chatml_format() defined?
_to_chatml_format() is defined in libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py at line 966.
What calls _to_chatml_format()?
_to_chatml_format() is called by 1 function(s): _to_chat_prompt.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free