Fix: duplicate output by async_chat_streamly (#11842)

### What problem does this PR solve?

Fix: duplicate output by async_chat_streamly
Refact: revert manual modification

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] Refactoring

---------

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
Magicbook1108
2025-12-09 19:21:52 +08:00
committed by GitHub
parent a94b3b9df2
commit ca2d6f3301
2 changed files with 9 additions and 16 deletions

View File

@ -146,7 +146,6 @@ class Base(ABC):
request_kwargs["stop"] = stop
response = await self.async_client.chat.completions.create(**request_kwargs)
async for resp in response:
if not resp.choices:
continue
@ -161,7 +160,6 @@ class Base(ABC):
else:
reasoning_start = False
ans = resp.choices[0].delta.content
tol = total_token_count_from_response(resp)
if not tol:
tol = num_tokens_from_string(resp.choices[0].delta.content)
@ -193,7 +191,7 @@ class Base(ABC):
except Exception as e:
e = await self._exceptions_async(e, attempt)
if e:
yield e
yield e
yield total_tokens
return