feat: Add support for image function tools #654
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.
This PR adds support for image function tools to the OpenAI Agents Python SDK.
It is inspired by the #341 .
Current
function_tool
implementation only allows output to be strictly string, which creates a problem when we want to pass image input in the request data. This PR tackles this problem by both providing a standartfunction_call_output
and additional image-related arguments back-to-back.What's included
ImageFunctionTool
class andimage_function_tool
decoratorUsage
Use the
@image_function_tool
decorator to create tools that work with images:The tool can then be used to allow agents to process and analyze images.
Supporting example script is located at
examples/tools/image_function_tool.py