feat: Better support for tools_strict=True
when using the OpenAIChatGenerator
#9411
Labels
P2
Medium priority, add to the next sprint if no P1 available
Is your feature request related to a problem? Please describe.
Currently when a user specifies
tools_strict=True
when using theOpenAIChatGenerator
we only update the providedtool_schema
in a basic way. Namely settingstrict=True
andadditionalProperties=False
at the top-level of the tools schema.This puts the majority of the effort on providing a strict compliant tool schema on the user when creating their tools. This isn't great if our users are relying on the automatic tool schema generation we provide in
create_tool_from_function
and inComponentTool
.A prominent example is when
ChatMessage
ends up in the tool parameter schema. It's by default not strict compliant so would cause an OpenAI error iftools_strict=True
is passed at run time.Describe the solution you'd like
Update our
tools_strict=True
functionality to do a best effort at making the user-provided schema strict compliant. I don't expect we will be able to cover every scenario but at least being able to cover some common examples of types in our component run methods would be nice if they are ever converted into a tool usingComponentTool
.I've started work in this PR #9382 but it's become more involved than I thought to support something like
ChatMessage
and I don't currently have the time to finish it.Additional context
A prominent example of this will be when users create Agent tools using
ComponentTool
+Agent
.Agent
hasList[ChatMessage]
in its run method so if users also want to usetools_strict=True
they would have to manually create the parameters schema of this tool or they would get an OpenAI error if they tried to use our auto generated schema.The text was updated successfully, but these errors were encountered: