Skip to content

Conversation

@towseef41
Copy link

Summary

  • fix _resize in langchain_openai.chat_models.base so the smaller side is scaled with its own dimension, preserving aspect ratio (e.g., 2048x4096 -> 768x1536)
  • add a regression test covering both orientations to prevent regressions

Fixes #34191

Testing

  • OPENAI_API_KEY=dummy python3 -m uv run --group test pytest tests/unit_tests/chat_models/test_base.py -k resize
  • python3 -m uv run --group lint ruff format langchain_openai/chat_models/base.py tests/unit_tests/chat_models/test_base.py
  • python3 -m uv run --group lint ruff check langchain_openai/chat_models/base.py tests/unit_tests/chat_models/test_base.py

@github-actions github-actions bot added integration Related to a provider partner package integration openai fix labels Dec 3, 2025
@towseef41
Copy link
Author

@ccurme waiting for your review

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 5, 2025

CodSpeed Performance Report

Merging #34192 will not alter performance

Comparing towseef41:fix/resize-aspect-ratio (75065e4) with master (80c3970)

Summary

✅ 6 untouched
⏩ 28 skipped1

Footnotes

  1. 28 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

ccurme
ccurme previously approved these changes Dec 5, 2025
@ccurme ccurme dismissed their stale review December 5, 2025 15:27

thought more

Copy link
Collaborator

@ccurme ccurme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a usage example that demonstrates that something is broken or wrong?

@towseef41
Copy link
Author

Do we have a usage example that demonstrates that something is broken or wrong?

The resize bug is covered by libs/partners/openai/tests/unit_tests/chat_models/test_base.py::test__resize_caps_dimensions_preserving_ratio. It calls _resize with oversized dimensions (2048x4096 and 4096x2048) and asserts the capped sizes keep the aspect ratio (768x1536 and 1536x768). That test is the usage example demonstrating the prior incorrect scaling and validating the fix.

@towseef41 towseef41 requested a review from ccurme December 6, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix integration Related to a provider partner package integration openai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible error in "_resize" function from langchain_openai.chat_models.base: wrong "new height" when width < height

3 participants