feat: Better support for tools_strict=True
when using the OpenAIChatGenerator
#9382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues
tools_strict=True
when using theOpenAIChatGenerator
#9411Proposed Changes:
Added
_strictify_function_schema
function to enforce OpenAI's strict schema for tool specifications. This update affects the OpenAIChatGenerator component whentools_strict=True
is enabled.This function:
type="object"
schemas and addadditionalProperties=False
or remove it if it has no-required parameterstype: "object"
parameters that don't have any required params --> this is not supported in strict modeTODO:
{"type": "object", "additionalProperties": True}
need to repair the remaining schema in case one of those removed parameters is a required parameter elsewhere. Look attest_strictify_function_schema_chat_message
intest_openai.py
to see a relevant example whenChatMessage
is in the function schema.How did you test it?
Notes for the reviewer
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.