Home / Function/ _extract_text_content_from_message() — langchain Function Reference

_extract_text_content_from_message() — langchain Function Reference

Architecture documentation for the _extract_text_content_from_message() function in structured_output.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  43c7c9c7_b2c0_1dcc_4be8_a8f880c39f25["_extract_text_content_from_message()"]
  7ab19be5_f449_5f71_c0e1_871dfc8e0588["ProviderStrategyBinding"]
  43c7c9c7_b2c0_1dcc_4be8_a8f880c39f25 -->|defined in| 7ab19be5_f449_5f71_c0e1_871dfc8e0588
  0fda5ec1_1f54_5091_4c3c_0202a78dacb3["parse()"]
  0fda5ec1_1f54_5091_4c3c_0202a78dacb3 -->|calls| 43c7c9c7_b2c0_1dcc_4be8_a8f880c39f25
  style 43c7c9c7_b2c0_1dcc_4be8_a8f880c39f25 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/structured_output.py lines 423–444

    def _extract_text_content_from_message(message: AIMessage) -> str:
        """Extract text content from an `AIMessage`.

        Args:
            message: The AI message to extract text from

        Returns:
            The extracted text content
        """
        content = message.content
        if isinstance(content, str):
            return content
        parts: list[str] = []
        for c in content:
            if isinstance(c, dict):
                if c.get("type") == "text" and "text" in c:
                    parts.append(str(c["text"]))
                elif "content" in c and isinstance(c["content"], str):
                    parts.append(c["content"])
            else:
                parts.append(str(c))
        return "".join(parts)

Domain

Subdomains

Called By

Frequently Asked Questions

What does _extract_text_content_from_message() do?
_extract_text_content_from_message() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/structured_output.py.
Where is _extract_text_content_from_message() defined?
_extract_text_content_from_message() is defined in libs/langchain_v1/langchain/agents/structured_output.py at line 423.
What calls _extract_text_content_from_message()?
_extract_text_content_from_message() is called by 1 function(s): parse.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free