Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions model-engine/model_engine_server/common/dtos/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class CompletionSyncV1Request(BaseModel):
"""
Controls the cumulative probability of the top tokens to consider. 1.0 means consider all tokens.
"""
include_stop_str_in_output: Optional[bool] = None
"""
Whether to include the stop strings in output text.
"""


class TokenOutput(BaseModel):
Expand Down Expand Up @@ -240,6 +244,10 @@ class CompletionStreamV1Request(BaseModel):
"""
Controls the cumulative probability of the top tokens to consider. 1.0 means consider all tokens.
"""
include_stop_str_in_output: Optional[bool] = None
"""
Whether to include the stop strings in output text.
"""


class CompletionStreamOutput(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,15 @@ def validate_and_update_completion_params(
"return_token_log_probs is only supported in deepspeed, text-generation-inference, vllm, lightllm."
)

# include_stop_str_in_output
if inference_framework == LLMInferenceFramework.VLLM:
pass
else:
if request.include_stop_str_in_output is not None:
raise ObjectHasInvalidValueException(
"include_stop_str_in_output is only supported in vllm."
)

return request


Expand Down Expand Up @@ -1634,6 +1643,8 @@ async def execute(
vllm_args["top_p"] = request.top_p
if request.return_token_log_probs:
vllm_args["logprobs"] = 1
if request.include_stop_str_in_output is not None:
vllm_args["include_stop_str_in_output"] = request.include_stop_str_in_output

inference_request = SyncEndpointPredictV1Request(
args=vllm_args,
Expand Down Expand Up @@ -1888,6 +1899,8 @@ async def execute(
args["top_p"] = request.top_p
if request.return_token_log_probs:
args["logprobs"] = 1
if request.include_stop_str_in_output is not None:
args["include_stop_str_in_output"] = request.include_stop_str_in_output
args["stream"] = True
elif model_content.inference_framework == LLMInferenceFramework.LIGHTLLM:
args = {
Expand Down