Skip to content

Commit cfb78f0

Browse files
deflake the LM test (#8924)
1 parent 68984e2 commit cfb78f0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/streaming/test_streaming.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def __call__(self, x: str, **kwargs):
157157
include_final_prediction_in_output_stream=False,
158158
)
159159
# Turn off the cache to ensure the stream is produced.
160-
with dspy.context(lm=dspy.LM(lm_for_test, cache=False)):
160+
with dspy.context(lm=dspy.LM(lm_for_test, cache=False, temperature=0.0)):
161161
output = program(x="why did a chicken cross the kitchen?")
162162
all_chunks = []
163163
async for value in output:
@@ -221,7 +221,7 @@ def __call__(self, x: str, **kwargs):
221221
include_final_prediction_in_output_stream=False,
222222
)
223223
# Turn off the cache to ensure the stream is produced.
224-
with dspy.context(lm=dspy.LM(lm_for_test, cache=False), adapter=dspy.JSONAdapter()):
224+
with dspy.context(lm=dspy.LM(lm_for_test, cache=False, temperature=0.0), adapter=dspy.JSONAdapter()):
225225
output = program(x="why did a chicken cross the kitchen?")
226226
all_chunks = []
227227
async for value in output:
@@ -289,7 +289,7 @@ def __call__(self, x: str, **kwargs):
289289
async_streaming=False,
290290
)
291291
# Turn off the cache to ensure the stream is produced.
292-
with dspy.context(lm=dspy.LM(lm_for_test, cache=False)):
292+
with dspy.context(lm=dspy.LM(lm_for_test, cache=False, temperature=0.0)):
293293
output = program(x="why did a chicken cross the kitchen?")
294294
all_chunks = []
295295
for value in output:
@@ -437,6 +437,7 @@ async def completion_side_effect(*args, **kwargs):
437437
assert all_chunks[22].chunk == "."
438438
assert all_chunks[22].is_last_chunk is True
439439

440+
440441
@pytest.mark.anyio
441442
async def test_stream_listener_returns_correct_chunk_json_adapter():
442443
class MyProgram(dspy.Module):

0 commit comments

Comments
 (0)