You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having two separate functions performing the same core conversion logic can lead to inconsistencies, potential bugs, and increased maintenance overhead.
Based on the docstring, langchain_core.messages.utils.convert_to_openai_messages appears to be the intended standard or newer public utility function for this conversion.
Suggestion:
It is suggested to consolidate these implementations. We should migrate the internal usages of _convert_message_to_dict within langchain_openai to use langchain_core.messages.utils.convert_to_openai_messages instead. After migrating the usages, the private _convert_message_to_dict function could potentially be removed or deprecated.
This consolidation would ensure a single source of truth for message conversion and simplify the codebase.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
It appears there are currently two distinct implementations for converting Langchain messages to OpenAI format messages:
langchain_core.messages.utils.convert_to_openai_messages
:langchain/libs/core/langchain_core/messages/utils.py
Line 941 in ce0b1a9
langchain_openai.chat_models.base._convert_message_to_dict
:langchain/libs/partners/openai/langchain_openai/chat_models/base.py
Line 234 in ce0b1a9
The private function
_convert_message_to_dict
is currently used internally in three places withinlangchain_openai.chat_models.base.py
:langchain/libs/partners/openai/langchain_openai/chat_models/base.py
Line 985 in ce0b1a9
langchain/libs/partners/openai/langchain_openai/chat_models/base.py
Line 1279 in ce0b1a9
langchain/libs/partners/openai/langchain_openai/chat_models/base.py
Line 3107 in ce0b1a9
Having two separate functions performing the same core conversion logic can lead to inconsistencies, potential bugs, and increased maintenance overhead.
Based on the docstring,
langchain_core.messages.utils.convert_to_openai_messages
appears to be the intended standard or newer public utility function for this conversion.Suggestion:
It is suggested to consolidate these implementations. We should migrate the internal usages of
_convert_message_to_dict
withinlangchain_openai
to uselangchain_core.messages.utils.convert_to_openai_messages
instead. After migrating the usages, the private_convert_message_to_dict
function could potentially be removed or deprecated.This consolidation would ensure a single source of truth for message conversion and simplify the codebase.
Beta Was this translation helpful? Give feedback.
All reactions