Skip to content

Commit

Permalink
修复解码时出现的一些乱码
Browse files Browse the repository at this point in the history
  • Loading branch information
ztxz16 committed Jul 6, 2024
1 parent 860bace commit 677bae9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/fastllm_pytools/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,11 @@ def stream_response(self,
stop_token_ids = stop_token_ids):
if one_by_one:
ret = cur[0][lastlen:]
lastlen = len(cur[0])
yield ret
if (ret.encode().find(b'\xef\xbf\xbd') == -1):
lastlen = len(cur[0])
yield ret
else:
yield ""
else:
yield cur[0]
else:
Expand Down Expand Up @@ -670,8 +673,11 @@ async def stream_response_async(self,
stop_token_ids = stop_token_ids):
if one_by_one:
ret = cur[0][lastlen:]
lastlen = len(cur[0])
yield ret
if (ret.encode().find(b'\xef\xbf\xbd') == -1):
lastlen = len(cur[0])
yield ret
else:
yield ""
else:
yield cur[0]
else:
Expand Down

0 comments on commit 677bae9

Please sign in to comment.