Skip to content

Commit 426b8e2

Browse files
authored
feat(standard-tests): enable parametrization of output_version (#33301)
1 parent bfed5f6 commit 426b8e2

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.github/scripts/check_diff.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,6 @@ def _get_configs_for_multi_dirs(
280280
# Note: won't run on external repo partners
281281
dirs_to_run["lint"].add("libs/standard-tests")
282282
dirs_to_run["test"].add("libs/standard-tests")
283-
dirs_to_run["lint"].add("libs/cli")
284-
dirs_to_run["test"].add("libs/cli")
285283
dirs_to_run["test"].add("libs/partners/mistralai")
286284
dirs_to_run["test"].add("libs/partners/openai")
287285
dirs_to_run["test"].add("libs/partners/anthropic")

libs/standard-tests/langchain_tests/integration_tests/chat_models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ async def test_ainvoke(self, model: BaseChatModel) -> None:
779779
assert isinstance(result.text, str)
780780
assert len(result.content) > 0
781781

782+
@pytest.mark.parametrize("model", [{}, {"output_version": "v1"}], indirect=True)
782783
def test_stream(self, model: BaseChatModel) -> None:
783784
"""Test to verify that ``model.stream(simple_message)`` works.
784785
@@ -804,13 +805,20 @@ def test_stream(self, model: BaseChatModel) -> None:
804805
805806
"""
806807
num_chunks = 0
808+
full: AIMessageChunk | None = None
807809
for chunk in model.stream("Hello"):
808810
assert chunk is not None
809811
assert isinstance(chunk, AIMessageChunk)
810812
assert isinstance(chunk.content, str | list)
811813
num_chunks += 1
814+
full = chunk if full is None else full + chunk
812815
assert num_chunks > 0
816+
assert isinstance(full, AIMessageChunk)
817+
assert full.content
818+
assert len(full.content_blocks) == 1
819+
assert full.content_blocks[0]["type"] == "text"
813820

821+
@pytest.mark.parametrize("model", [{}, {"output_version": "v1"}], indirect=True)
814822
async def test_astream(self, model: BaseChatModel) -> None:
815823
"""Test to verify that ``await model.astream(simple_message)`` works.
816824
@@ -839,12 +847,18 @@ async def test_astream(self, model: BaseChatModel) -> None:
839847
840848
"""
841849
num_chunks = 0
850+
full: AIMessageChunk | None = None
842851
async for chunk in model.astream("Hello"):
843852
assert chunk is not None
844853
assert isinstance(chunk, AIMessageChunk)
845854
assert isinstance(chunk.content, str | list)
846855
num_chunks += 1
856+
full = chunk if full is None else full + chunk
847857
assert num_chunks > 0
858+
assert isinstance(full, AIMessageChunk)
859+
assert full.content
860+
assert len(full.content_blocks) == 1
861+
assert full.content_blocks[0]["type"] == "text"
848862

849863
def test_batch(self, model: BaseChatModel) -> None:
850864
"""Test to verify that ``model.batch([messages])`` works.
@@ -3007,6 +3021,7 @@ def test_message_with_name(self, model: BaseChatModel) -> None:
30073021
assert isinstance(result.text, str)
30083022
assert len(result.content) > 0
30093023

3024+
@pytest.mark.parametrize("model", [{}, {"output_version": "v1"}], indirect=True)
30103025
def test_agent_loop(self, model: BaseChatModel) -> None:
30113026
"""Test that the model supports a simple ReAct agent loop.
30123027

libs/standard-tests/langchain_tests/unit_tests/chat_models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ def standard_chat_model_params(self) -> dict:
8383
}
8484

8585
@pytest.fixture
86-
def model(self) -> BaseChatModel:
86+
def model(self, request: Any) -> BaseChatModel:
8787
"""Model fixture."""
88+
extra_init_params = getattr(request, "param", None) or {}
8889
return self.chat_model_class(
8990
**{
9091
**self.standard_chat_model_params,
9192
**self.chat_model_params,
92-
}
93+
},
94+
**extra_init_params,
9395
)
9496

9597
@pytest.fixture

0 commit comments

Comments
 (0)