feat(chat): stop an in-flight answer — Send becomes Stop, the partial is kept and persisted, the model stream is torn down

This commit is contained in:
2026-08-29 17:27:04 -04:00
parent 6bf7f456d4
commit 1a60ecbd8b
186 changed files with 1738 additions and 7796 deletions
+6
View File
@@ -289,6 +289,7 @@ def _chunk(
class _FakeChatStream:
def __init__(self, chunks: list) -> None:
self._chunks = list(chunks)
self.close_calls = 0
def __aiter__(self):
self._i = 0
@@ -301,6 +302,11 @@ class _FakeChatStream:
self._i += 1
return chunk
async def close(self) -> None:
"""The openai SDK ``AsyncStream.close()`` (phase 48): ``chat_stream``
awaits it on every exit after a successful ``create()``."""
self.close_calls += 1
class _FakeCompletion:
"""One fake non-streaming ChatCompletion (``choices[].message`` shape).