Skip to content

Commit

Permalink
fix: all runners sse output (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
larme authored Feb 2, 2024
1 parent 6c909aa commit 9f9195f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions openllm-python/src/openllm/_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def generate_iterator(self, prompt_token_ids, request_id, stop=None, adapt
spaces_between_special_tokens=False,
clean_up_tokenization_spaces=True, #
)
yield GenerationOutput(
out = GenerationOutput(
prompt_token_ids=prompt_token_ids, #
prompt='',
finished=request_output.is_last,
Expand All @@ -109,7 +109,7 @@ async def generate_iterator(self, prompt_token_ids, request_id, stop=None, adapt
)
],
).model_dump_json()

yield bentoml.io.SSE(out).marshal()

@registry
class vLLMRunnable(bentoml.Runnable):
Expand Down Expand Up @@ -286,7 +286,7 @@ async def generate_iterator(self, prompt_token_ids, request_id, stop=None, adapt
if config['logprobs']:
sample_logprobs.append({token: token_logprobs})

yield GenerationOutput(
out = GenerationOutput(
prompt='',
finished=False,
outputs=[
Expand All @@ -303,13 +303,14 @@ async def generate_iterator(self, prompt_token_ids, request_id, stop=None, adapt
prompt_logprobs=prompt_logprobs if config['prompt_logprobs'] else None,
request_id=request_id,
).model_dump_json()
yield bentoml.io.SSE(out).marshal()
if stopped:
break
else:
finish_reason = 'length'
if stopped:
finish_reason = 'stop'
yield GenerationOutput(
out = GenerationOutput(
prompt='',
finished=True,
outputs=[
Expand All @@ -326,6 +327,7 @@ async def generate_iterator(self, prompt_token_ids, request_id, stop=None, adapt
prompt_logprobs=prompt_logprobs if config['prompt_logprobs'] else None,
request_id=request_id,
).model_dump_json()
yield bentoml.io.SSE(out).marshal()

# Clean
del past_key_values, out
Expand Down

0 comments on commit 9f9195f

Please sign in to comment.