Skip to content

langchain_openai: Use convert_to_openai_messages internally in langchain-openai #31226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

edwardzjl
Copy link
Contributor

Copy link

vercel bot commented May 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview May 14, 2025 9:25am

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. langchain Related to the langchain package labels May 14, 2025
@edwardzjl edwardzjl force-pushed the lc-to-openai branch 2 times, most recently from 4fdf611 to 82ea63e Compare May 14, 2025 09:15
@edwardzjl
Copy link
Contributor Author

I noticed that langchain_core.messages.utils.convert_to_openai_messages will automatically convert None content to an empty string (""):

if not message.content:
content = "" if text_format == "string" else []

However, langchain_openai.chat_models.base._convert_message_to_dict preserves the content as-is:

else:
formatted_content = content

Since both functions are responsible for converting LangChain messages to OpenAI format, I'm wondering which behavior is preferred. Should they be consistent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
langchain Related to the langchain package size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant