Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ def _model_constructor_kwargs(
) -> dict[str, Any]:
raw = (config.get("model") or {}).get("parameters")
parameters = dict(raw) if isinstance(raw, dict) else {}
provider = str((config.get("provider") or {}).get("name") or "").lower()
if provider == "bedrock":
parameters.pop("tools", None)
# Tools are bound from config["tools"]. A tools key here is forwarded raw and rejected.
parameters.pop("tools", None)
parameters["model"] = _resolved_model_name(config, fallback_name)
return parameters

Expand All @@ -191,7 +190,7 @@ def _make_default_chat_model(config: AiConfigRep) -> Any:
Instantiate the appropriate LangChain chat model based on ``config.provider.name``.
Falls back to ``ChatOpenAI`` when the provider is not recognised.
Requires the matching ``langchain-<provider>`` integration package to be installed.
``model.parameters`` are passed through unchanged.
``model.parameters`` are passed through, except ``tools``, which is bound separately.
"""
import importlib

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ async def _traverse_node(node: GraphNode) -> None:
model_cfg = node.config.get("model") or {}
raw = model_cfg.get("parameters")
kwargs = dict(raw) if isinstance(raw, dict) else {}
# Tools are bound from the node config. A tools key here is forwarded raw and rejected.
kwargs.pop("tools", None)
kwargs["model"] = model_cfg.get("name") or "gpt-4o"
chat_model = lc_openai.ChatOpenAI(**kwargs)

Expand Down
1 change: 0 additions & 1 deletion packages/langchain-agents/tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,6 @@ async def test_default_openai_constructor_receives_parameters(self) -> None:
assert ctor.call_args.kwargs == {
"temperature": 0.2,
"max_tokens": 512,
"tools": [{"name": "openai-tool"}],
"model": "gpt-4o",
}

Expand Down
6 changes: 5 additions & 1 deletion packages/langchain-agents/tests/test_native_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ async def test_default_chat_openai_receives_model_parameters(self) -> None:
"config": {
"model": {
"name": "gpt-4o",
"parameters": {"temperature": 0.2, "max_tokens": 512},
"parameters": {
"temperature": 0.2,
"max_tokens": 512,
"tools": [{"name": "openai-tool"}],
},
},
"instructions": "help",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ def _model_constructor_kwargs(
) -> dict[str, Any]:
raw = (config.get("model") or {}).get("parameters")
parameters = dict(raw) if isinstance(raw, dict) else {}
provider = str((config.get("provider") or {}).get("name") or "").lower()
if provider == "bedrock":
parameters.pop("tools", None)
# Tools are bound from config["tools"]. A tools key here is forwarded raw and rejected.
parameters.pop("tools", None)
# Name from the config always wins over a colliding ``model`` key in the parameter bag.
parameters["model"] = _resolved_model_name(config, fallback_name)
return parameters
Expand All @@ -248,7 +247,7 @@ def _make_default_chat_model(config: AiConfigRep, importlib: Any) -> Any:
Instantiate the appropriate LangChain chat model based on ``config.provider.name``.
Falls back to ``ChatOpenAI`` when the provider is not recognised.
Requires the matching ``langchain-<provider>`` integration package to be installed.
``model.parameters`` are passed through unchanged.
``model.parameters`` are passed through, except ``tools``, which is bound separately.
"""
provider = config.get("provider", {}).get("name", "openai").lower()
if provider == "anthropic":
Expand Down
1 change: 0 additions & 1 deletion packages/langchain-messages/tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2381,7 +2381,6 @@ async def test_default_openai_constructor_receives_parameters(self) -> None:
assert ctor.call_args.kwargs == {
"temperature": 0.2,
"max_tokens": 512,
"tools": [{"name": "openai-tool"}],
"model": "gpt-4o",
}

Expand Down
Loading