Unverified Commit 1325872e authored by Nick Hill's avatar Nick Hill Committed by GitHub
Browse files

[Frontend] Avoid creating guided decoding LogitsProcessor unnecessarily (#9521)

parent 380e1863
......@@ -49,14 +49,17 @@ class GuidedDecodingParams:
@staticmethod
def from_optional(
json: Optional[Union[Dict, BaseModel, str]],
json: Optional[Union[Dict, BaseModel, str]] = None,
regex: Optional[str] = None,
choice: Optional[List[str]] = None,
grammar: Optional[str] = None,
json_object: Optional[bool] = None,
backend: Optional[str] = None,
whitespace_pattern: Optional[str] = None,
) -> "GuidedDecodingParams":
) -> Optional["GuidedDecodingParams"]:
if all(arg is None
for arg in (json, regex, choice, grammar, json_object)):
return None
# Extract json schemas from pydantic models
if isinstance(json, (BaseModel, type(BaseModel))):
json = json.model_json_schema()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment