mirror of
https://github.com/hwchase17/langchain.git
synced 2026-03-18 02:53:16 +00:00
fix(openrouter): include role in sdk model_construct for min dep compat (#35562)
Fix `_wrap_messages_for_sdk` stripping `role` before `model_construct` — on `openrouter==0.6.0` (minimum dep), the SDK models don't auto-populate a default `role`, so `model_dump()` omitted it entirely, causing `KeyError: 'role'` in pre-release checks.
This commit is contained in:
@@ -969,8 +969,7 @@ def _wrap_messages_for_sdk(
|
||||
# Unknown role — pass dict through and hope for the best.
|
||||
wrapped.append(msg)
|
||||
continue
|
||||
fields = {k: v for k, v in msg.items() if k != "role"}
|
||||
wrapped.append(model_cls.model_construct(**fields))
|
||||
wrapped.append(model_cls.model_construct(**msg))
|
||||
return wrapped
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user