mirror of
https://github.com/usestrix/strix.git
synced 2026-10-13 03:57:59 +00:00
fix(llm): bound the first stream event by the idle limit when no first-event limit is set
This commit is contained in:
parent
59e645eba5
commit
58d25f447d
2 changed files with 6 additions and 2 deletions
|
|
@ -446,10 +446,12 @@ async def _with_timeouts(
|
|||
first = True
|
||||
while True:
|
||||
limits: list[tuple[float, float, str]] = []
|
||||
gap = first_event if first else idle
|
||||
# Without a first-event bound, the idle bound covers the first event too.
|
||||
on_first = first and bool(first_event)
|
||||
gap = first_event if on_first else idle
|
||||
if gap:
|
||||
limits.append(
|
||||
(gap, gap, "stream_first_event_timeout" if first else "stream_idle_timeout")
|
||||
(gap, gap, "stream_first_event_timeout" if on_first else "stream_idle_timeout")
|
||||
)
|
||||
if total:
|
||||
limits.append((max(0.0, deadline - time.monotonic()), total, "stream_total_timeout"))
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ async def test_first_event_and_whole_stream_are_bounded() -> None:
|
|||
|
||||
with pytest.raises(TimeoutError, match="stream_first_event_timeout"):
|
||||
[event async for event in _with_timeouts(_slow_start(), idle=5, first_event=0.2)]
|
||||
with pytest.raises(TimeoutError, match="stream_idle_timeout"):
|
||||
[event async for event in _with_timeouts(_slow_start(), idle=0.2)]
|
||||
with pytest.raises(TimeoutError, match="stream_total_timeout"):
|
||||
[event async for event in _with_timeouts(_endless(), idle=5, total=0.3)]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue