Home / File/ test_anthropic.py — langchain Source File

test_anthropic.py — langchain Source File

Architecture documentation for test_anthropic.py, a python file in the langchain codebase. 1 imports, 0 dependents.

File python CoreAbstractions MessageSchema 1 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  e9360b86_5734_2fa6_ef29_3a5edad0a2b8["test_anthropic.py"]
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  e9360b86_5734_2fa6_ef29_3a5edad0a2b8 --> d758344f_537f_649e_f467_b9d7442e86df
  style e9360b86_5734_2fa6_ef29_3a5edad0a2b8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage
from langchain_core.messages import content as types


def test_convert_to_v1_from_anthropic() -> None:
    message = AIMessage(
        [
            {"type": "thinking", "thinking": "foo", "signature": "foo_signature"},
            {"type": "text", "text": "Let's call a tool."},
            {
                "type": "tool_use",
                "id": "abc_123",
                "name": "get_weather",
                "input": {"location": "San Francisco"},
            },
            {
                "type": "tool_use",
                "id": "abc_234",
                "name": "get_weather_programmatic",
                "input": {"location": "Boston"},
                "caller": {
                    "type": "code_execution_20250825",
                    "tool_id": "srvtoolu_abc234",
                },
            },
            {
                "type": "text",
                "text": "It's sunny.",
                "citations": [
                    {
                        "type": "search_result_location",
                        "cited_text": "The weather is sunny.",
                        "source": "source_123",
                        "title": "Document Title",
                        "search_result_index": 1,
                        "start_block_index": 0,
                        "end_block_index": 2,
                    },
                    {"bar": "baz"},
                ],
            },
            {
                "type": "server_tool_use",
                "name": "web_search",
                "input": {"query": "web search query"},
                "id": "srvtoolu_abc123",
            },
            {
                "type": "web_search_tool_result",
                "tool_use_id": "srvtoolu_abc123",
                "content": [
                    {
                        "type": "web_search_result",
                        "title": "Page Title 1",
                        "url": "<page url 1>",
                        "page_age": "January 1, 2025",
                        "encrypted_content": "<encrypted content 1>",
                    },
                    {
                        "type": "web_search_result",
// ... (450 more lines)

Subdomains

Dependencies

  • langchain_core.messages

Frequently Asked Questions

What does test_anthropic.py do?
test_anthropic.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_anthropic.py?
test_anthropic.py defines 3 function(s): test_convert_to_v1_from_anthropic, test_convert_to_v1_from_anthropic_chunk, test_convert_to_v1_from_anthropic_input.
What does test_anthropic.py depend on?
test_anthropic.py imports 1 module(s): langchain_core.messages.
Where is test_anthropic.py in the architecture?
test_anthropic.py is located at libs/core/tests/unit_tests/messages/block_translators/test_anthropic.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/tests/unit_tests/messages/block_translators).

Analyze Your Own Codebase

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

Try Supermodel Free