Home / Function/ test_files_api_pdf() — langchain Function Reference

test_files_api_pdf() — langchain Function Reference

Architecture documentation for the test_files_api_pdf() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  331db3d9_c52b_7be4_6d29_2643ebc84047["test_files_api_pdf()"]
  f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"]
  331db3d9_c52b_7be4_6d29_2643ebc84047 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f
  style 331db3d9_c52b_7be4_6d29_2643ebc84047 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 1894–1921

def test_files_api_pdf(block_format: str) -> None:
    """Note: this is a beta feature.

    TODO: Update to remove beta once generally available.
    """
    pdf_file_id = os.getenv("ANTHROPIC_FILES_API_PDF_ID")
    if not pdf_file_id:
        pytest.skip()
    llm = ChatAnthropic(
        model=MODEL_NAME,  # type: ignore[call-arg]
        betas=["files-api-2025-04-14"],
    )
    if block_format == "anthropic":
        block = {"type": "document", "source": {"type": "file", "file_id": pdf_file_id}}
    else:
        # standard block format
        block = {
            "type": "file",
            "file_id": pdf_file_id,
        }
    input_message = {
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this document."},
            block,
        ],
    }
    _ = llm.invoke([input_message])

Domain

Subdomains

Frequently Asked Questions

What does test_files_api_pdf() do?
test_files_api_pdf() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py.
Where is test_files_api_pdf() defined?
test_files_api_pdf() is defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py at line 1894.

Analyze Your Own Codebase

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

Try Supermodel Free