_clean_block() — langchain Function Reference
Architecture documentation for the _clean_block() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 30456995_7e1c_8201_cd0a_0ab4e2ee2d00["_clean_block()"] cfb937d2_ce7f_5338_2b62_6452043ac78a["chat_models.py"] 30456995_7e1c_8201_cd0a_0ab4e2ee2d00 -->|defined in| cfb937d2_ce7f_5338_2b62_6452043ac78a 0040f7d2_abde_821f_7713_ae3da549425c["_convert_message_to_mistral_chat_message()"] 0040f7d2_abde_821f_7713_ae3da549425c -->|calls| 30456995_7e1c_8201_cd0a_0ab4e2ee2d00 style 30456995_7e1c_8201_cd0a_0ab4e2ee2d00 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/mistralai/langchain_mistralai/chat_models.py lines 357–369
def _clean_block(block: dict) -> dict:
# Remove "index" key added for message aggregation in langchain-core
new_block = {k: v for k, v in block.items() if k != "index"}
if block.get("type") == "thinking" and isinstance(block.get("thinking"), list):
new_block["thinking"] = [
(
{k: v for k, v in sb.items() if k != "index"}
if isinstance(sb, dict) and "index" in sb
else sb
)
for sb in block["thinking"]
]
return new_block
Domain
Subdomains
Source
Frequently Asked Questions
What does _clean_block() do?
_clean_block() is a function in the langchain codebase, defined in libs/partners/mistralai/langchain_mistralai/chat_models.py.
Where is _clean_block() defined?
_clean_block() is defined in libs/partners/mistralai/langchain_mistralai/chat_models.py at line 357.
What calls _clean_block()?
_clean_block() is called by 1 function(s): _convert_message_to_mistral_chat_message.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free