Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lvhan028 committed Sep 24, 2024
1 parent 468446a commit e66731a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lmdeploy/serve/async_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,7 @@ async def generate(
yield GenOut(response, self.id2step[str(session_id)],
len(input_ids), tokens, finish_reason, res,
logprobs)
if outputs.status > ResponseType.FINISH:
yield GenOut(
response='internal error happened',
history_token_len=self.id2step[str(session_id)],
input_token_len=len(input_ids),
generate_token_len=0,
finish_reason='error',
token_ids=[])
else:
if outputs.status <= ResponseType.FINISH:
finish_reason = 'length' \
if tokens >= gen_config.max_new_tokens else 'stop'
# utf-8 char at the end means it's a potential unfinished
Expand All @@ -607,6 +599,14 @@ async def generate(
response = ''
yield GenOut(response, self.id2step[str(session_id)],
len(input_ids), tokens, finish_reason)
else:
yield GenOut(
response='internal error happened',
history_token_len=self.id2step[str(session_id)],
input_token_len=len(input_ids),
generate_token_len=0,
finish_reason='error',
token_ids=[])
# update step
self.id2step[str(session_id)] += len(input_ids) + tokens
if sequence_end:
Expand Down

0 comments on commit e66731a

Please sign in to comment.