-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:OpenAPI: tool_choice now anyOf (string or ChatTools), docs expanded #218
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
🛠️ Refactor suggestion
Avoid reusing ChatTools in tool_choice; introduce a selector object that only needs a function name
Using ChatTools here invites redefining a tool and duplicating/contradicting entries in tools[]. OpenAI-style selection only needs the function name. Define a minimal selector object and reference that from tool_choice.
Add these schemas under components/schemas (outside this hunk):
This keeps tools[] for full definitions (parameters, descriptions) and tool_choice for selection only.
🛠️ Refactor suggestion
Constrain tool_choice to valid values and prefer oneOf for disjoint types
Right now any string is accepted, which weakens validation and SDK typings. Since object vs. string are disjoint, oneOf is a better fit and the string branch should enumerate the only allowed literals.
Apply this diff within this block:
And add the supporting schema below in components/schemas (example provided in a separate block in the next comment).
🤖 Prompt for AI Agents
💡 Verification agent
❓ Verification inconclusive
Validate the updated spec and sample payloads
Run a quick spec validation and probe example payloads for the new oneOf branch to avoid regressions.
🏁 Script executed:
Length of output: 686
Validate the updated OpenAPI spec with a YAML-based loader
I’ve adjusted the validation approach to avoid the
ResolvingParserAPI mismatch and directly load the YAML. Please run the following to confirm there are no schema errors and that the newanyOfbranch fortool_choiceis correctly recognized:– Verify that the
anyOfarray includes both thestringtype and theChatTools$ref.– Spot-check any code generators or clients (e.g., your OpenAPI-driven SDKs) to ensure they parse the updated
tool_choiceproperty without errors.– Manually craft and send a sample payload covering each
anyOfoption (plain string,ChatToolsobject) to your service endpoint to confirm runtime handling.🏁 Script executed:
Length of output: 1101
Critical: Fix invalid parameter schema in OpenAPI spec
The OpenAPI validation failed due to an invalid cookie parameter definition for
sessionin the/payment/checklistGET operation. The schema usestype: 'String'(capital “S”), which isn’t a valid OpenAPI primitive. It must be lowercasestring. Please correct this and re-validate.• Location to fix (in
src/libs/DeepInfra/openapi.yaml):After updating, rerun the validation:
Once that’s green, you can then proceed to spot-check the new
tool_choiceanyOfbranch and sample payloads.🤖 Prompt for AI Agents