mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 15:03:21 +00:00
core,integrations[minor]: Dont error on fields in model_kwargs (#27110)
Given the current erroring behavior, every time we've moved a kwarg from model_kwargs and made it its own field that was a breaking change. Updating this behavior to support the old instantiations / serializations. Assuming build_extra_kwargs was not something that itself is being used externally and needs to be kept backwards compatible
This commit is contained in:
@@ -26,13 +26,12 @@ def test_openai_model_kwargs() -> None:
|
||||
|
||||
|
||||
@pytest.mark.requires("openai")
|
||||
def test_openai_invalid_model_kwargs() -> None:
|
||||
with pytest.raises(ValueError):
|
||||
OpenAI(model_kwargs={"model_name": "foo"})
|
||||
|
||||
# Test that "model" cannot be specified in kwargs
|
||||
with pytest.raises(ValueError):
|
||||
OpenAI(model_kwargs={"model": "gpt-3.5-turbo-instruct"})
|
||||
def test_openai_fields_model_kwargs() -> None:
|
||||
"""Test that for backwards compatibility fields can be passed in as model_kwargs."""
|
||||
llm = OpenAI(model_kwargs={"model_name": "foo"}, api_key="foo")
|
||||
assert llm.model_name == "foo"
|
||||
llm = OpenAI(model_kwargs={"model": "foo"}, api_key="foo")
|
||||
assert llm.model_name == "foo"
|
||||
|
||||
|
||||
@pytest.mark.requires("openai")
|
||||
|
Reference in New Issue
Block a user