-
Notifications
You must be signed in to change notification settings - Fork 2.1k
vLLM: Move from guided_options_request to structured_outputs #1805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/smolagents/models.py
Outdated
) | ||
# Override the OpenAI schema for VLLM compatibility | ||
guided_options_request = {"guided_json": response_format["json_schema"]["schema"]} if response_format else None | ||
structured_outputs = StructuredOutputsParams(json=response_format["json_schema"]["schema"]) if response_format else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qjflores suggested a fix when he opened the issue,
# Convert old guided_options_request format to new structured_outputs
structured_outputs_params = None
if response_format:
if "json_schema" in response_format:
# Extract the JSON schema from the response_format
json_schema = response_format["json_schema"]["schema"]
structured_outputs_params = StructuredOutputsParams(json=json_schema)
elif "choice" in response_format:
# Handle choice-based structured outputs
structured_outputs_params = StructuredOutputsParams(choice=response_format["choice"])
elif "regex" in response_format:
# Handle regex-based structured outputs
structured_outputs_params = StructuredOutputsParams(regex=response_format["regex"])
elif "grammar" in response_format:
# Handle grammar-based structured outputs
structured_outputs_params = StructuredOutputsParams(grammar=response_format["grammar"])
elif "structural_tag" in response_format:
# Handle structural tag-based structured outputs
structured_outputs_params = StructuredOutputsParams(structural_tag=response_format["structural_tag"])
else:
print(f"WARNING: Unsupported response_format type: {response_format}")
structured_outputs_params = None
But if I understand correctly, JSON is the only structured output param that is used
smolagents/src/smolagents/agents.py
Line 1631 in f042c0c
additional_args["response_format"] = CODEAGENT_RESPONSE_FORMAT |
CODEAGENT_RESPONSE_FORMAT
descriptionsmolagents/src/smolagents/models.py
Line 41 in f042c0c
"json_schema": { |
So I simplified his solution and incorporated it in the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me
] | ||
vllm = [ | ||
"vllm", | ||
"vllm>=0.10.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add some version control logic like the following
json_schema = response_format["json_schema"]["schema"]
if parse(vllm.__version__) >= parse("0.10.2"):
from vllm.outputs import StructuredOutputsParams
if response_format:
structured_outputs = StructuredOutputsParams(json=json_schema)
else:
if response_format:
guided_options_request = {"guided_json": json_schema}
But I think that adds unnecessary complexity. Might be simpler to just force the version to be >= 0.10.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToolCallingAgent, | ||
stream_to_gradio, | ||
) | ||
from smolagents.memory import ActionStep, AgentMemory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: Style changes were merged to main. make style
from a different commit
cc: @albertvillanova / @aymeric-roucher for review |
thank you! |
This is a PR to fix, #1794
With VLLM > 0.10.1, The
guided_options_request
was deprecated. This moves to the recommened structured_outputs approachhttps://github.com/vllm-project/vllm/blob/main/docs/features/structured_outputs.md#structured-outputs
Based on my understanding of the changelog (https://github.com/vllm-project/vllm/releases), They deprecated the parameter in 0.10.2 (Last month) and completely removed support for V0 APIs in 0.11 (Last week)
Tested it with the following code
and I was able to reproduce the issue
After the fix with vLLM 0.11
