@@ -779,6 +779,7 @@ async def test_ainvoke(self, model: BaseChatModel) -> None:
779
779
assert isinstance (result .text , str )
780
780
assert len (result .content ) > 0
781
781
782
+ @pytest .mark .parametrize ("model" , [{}, {"output_version" : "v1" }], indirect = True )
782
783
def test_stream (self , model : BaseChatModel ) -> None :
783
784
"""Test to verify that ``model.stream(simple_message)`` works.
784
785
@@ -804,13 +805,20 @@ def test_stream(self, model: BaseChatModel) -> None:
804
805
805
806
"""
806
807
num_chunks = 0
808
+ full : AIMessageChunk | None = None
807
809
for chunk in model .stream ("Hello" ):
808
810
assert chunk is not None
809
811
assert isinstance (chunk , AIMessageChunk )
810
812
assert isinstance (chunk .content , str | list )
811
813
num_chunks += 1
814
+ full = chunk if full is None else full + chunk
812
815
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"
813
820
821
+ @pytest .mark .parametrize ("model" , [{}, {"output_version" : "v1" }], indirect = True )
814
822
async def test_astream (self , model : BaseChatModel ) -> None :
815
823
"""Test to verify that ``await model.astream(simple_message)`` works.
816
824
@@ -839,12 +847,18 @@ async def test_astream(self, model: BaseChatModel) -> None:
839
847
840
848
"""
841
849
num_chunks = 0
850
+ full : AIMessageChunk | None = None
842
851
async for chunk in model .astream ("Hello" ):
843
852
assert chunk is not None
844
853
assert isinstance (chunk , AIMessageChunk )
845
854
assert isinstance (chunk .content , str | list )
846
855
num_chunks += 1
856
+ full = chunk if full is None else full + chunk
847
857
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"
848
862
849
863
def test_batch (self , model : BaseChatModel ) -> None :
850
864
"""Test to verify that ``model.batch([messages])`` works.
@@ -3007,6 +3021,7 @@ def test_message_with_name(self, model: BaseChatModel) -> None:
3007
3021
assert isinstance (result .text , str )
3008
3022
assert len (result .content ) > 0
3009
3023
3024
+ @pytest .mark .parametrize ("model" , [{}, {"output_version" : "v1" }], indirect = True )
3010
3025
def test_agent_loop (self , model : BaseChatModel ) -> None :
3011
3026
"""Test that the model supports a simple ReAct agent loop.
3012
3027
0 commit comments