test_openai_pdf_inputs() — langchain Function Reference
Architecture documentation for the test_openai_pdf_inputs() function in test_base_standard.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 67149d72_8608_202b_f6ee_f7af179c6494["test_openai_pdf_inputs()"] 59b2cda2_7dec_b2fd_a101_d5afcda5ed66["TestOpenAIStandard"] 67149d72_8608_202b_f6ee_f7af179c6494 -->|defined in| 59b2cda2_7dec_b2fd_a101_d5afcda5ed66 style 67149d72_8608_202b_f6ee_f7af179c6494 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/integration_tests/chat_models/test_base_standard.py lines 92–123
def test_openai_pdf_inputs(self, model: BaseChatModel) -> None:
"""Test that the model can process PDF inputs."""
url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
pdf_data = base64.b64encode(httpx.get(url).content).decode("utf-8")
message = HumanMessage(
[
{"type": "text", "text": "What is the document title, verbatim?"},
{
"type": "file",
"mime_type": "application/pdf",
"base64": pdf_data,
"filename": "my-pdf", # OpenAI requires a filename
},
]
)
_ = model.invoke([message])
# Test OpenAI Chat Completions format
message = HumanMessage(
[
{"type": "text", "text": "What is the document title, verbatim?"},
{
"type": "file",
"file": {
"filename": "test file.pdf",
"file_data": f"data:application/pdf;base64,{pdf_data}",
},
},
]
)
_ = model.invoke([message])
Domain
Subdomains
Source
Frequently Asked Questions
What does test_openai_pdf_inputs() do?
test_openai_pdf_inputs() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_base_standard.py.
Where is test_openai_pdf_inputs() defined?
test_openai_pdf_inputs() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_base_standard.py at line 92.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free