_resize() — langchain Function Reference
Architecture documentation for the _resize() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d9f589e8_b1c5_45d1_92a1_362c97de0d6e["_resize()"] 2b046911_ea21_8e2e_ba0d_9d03da8d7bda["base.py"] d9f589e8_b1c5_45d1_92a1_362c97de0d6e -->|defined in| 2b046911_ea21_8e2e_ba0d_9d03da8d7bda 7cf4873b_bc13_276a_ae3d_52fa0c9a42ef["_count_image_tokens()"] 7cf4873b_bc13_276a_ae3d_52fa0c9a42ef -->|calls| d9f589e8_b1c5_45d1_92a1_362c97de0d6e style d9f589e8_b1c5_45d1_92a1_362c97de0d6e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/langchain_openai/chat_models/base.py lines 3621–3638
def _resize(width: int, height: int) -> tuple[int, int]:
# larger side must be <= 2048
if width > 2048 or height > 2048:
if width > height:
height = (height * 2048) // width
width = 2048
else:
width = (width * 2048) // height
height = 2048
# smaller side must be <= 768
if width > 768 and height > 768:
if width > height:
width = (width * 768) // height
height = 768
else:
height = (height * 768) // width
width = 768
return width, height
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _resize() do?
_resize() is a function in the langchain codebase, defined in libs/partners/openai/langchain_openai/chat_models/base.py.
Where is _resize() defined?
_resize() is defined in libs/partners/openai/langchain_openai/chat_models/base.py at line 3621.
What calls _resize()?
_resize() is called by 1 function(s): _count_image_tokens.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free