Skip to content

Commit 8ea8ae4

Browse files
committed
test(openai): add openai unit test for streaming error in _generate method
- Add test for streaming error with multiple prompts
1 parent 54ea620 commit 8ea8ae4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libs/partners/openai/tests/unit_tests/llms/test_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,13 @@ def test_stream_response_to_generation_chunk() -> None:
108108
assert chunk == GenerationChunk(
109109
text="", generation_info={"finish_reason": None, "logprobs": None}
110110
)
111+
112+
113+
def test_generate_streaming_multiple_prompts_error() -> None:
114+
"""Ensures ValueError when streaming=True and multiple prompts."""
115+
llm = OpenAI(streaming=True)
116+
117+
with pytest.raises(
118+
ValueError, match="Cannot stream results with multiple prompts\\."
119+
):
120+
llm._generate(["foo", "bar"])

0 commit comments

Comments
 (0)