Skip to content

Commit

Permalink
fix: vllm version compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: wxiwnd <[email protected]>
  • Loading branch information
wxiwnd committed Oct 26, 2024
1 parent 820c726 commit 823887f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xinference/model/llm/vllm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ async def async_generate(
request_id: Optional[str] = None,
) -> Union[Completion, AsyncGenerator[CompletionChunk, None]]:
try:
from vllm.sampling_params import GuidedDecodingParams, SamplingParams
from vllm.sampling_params import SamplingParams
except ImportError:
error_message = "Failed to import module 'vllm'"
installation_guide = [
Expand Down Expand Up @@ -533,6 +533,8 @@ async def async_generate(

if VLLM_INSTALLED and vllm.__version__ >= "0.6.3":
# guided decoding only available for vllm >= 0.6.3
from vllm.sampling_params import GuidedDecodingParams

guided_options = GuidedDecodingParams.from_optional(
json=sanitized_generate_config.pop("guided_json", None),
regex=sanitized_generate_config.pop("guided_regex", None),
Expand All @@ -549,6 +551,7 @@ async def async_generate(
guided_decoding=guided_options, **sanitized_generate_config
)
else:
# ignore generate configs
sanitized_generate_config.pop("guided_json", None)
sanitized_generate_config.pop("guided_regex", None)
sanitized_generate_config.pop("guided_choice", None)
Expand Down

0 comments on commit 823887f

Please sign in to comment.