Skip to content
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

Several features for OpenAPI toolkit and OpenAI Assistants #3989

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

owengo
Copy link

@owengo owengo commented Feb 5, 2025

The PR proposes to:

  1. Allow OpenAI assistant to call several tools in the same run. This is quite common when the assistant decides to call a second tool after the first one
  2. The OpenAPI Toolkit now supports a "x-strict": true attribute for an action. This creates a function with "strict mode".

The "strict mode" is described here: https://openai.com/index/introducing-structured-outputs-in-the-api/ , https://platform.openai.com/docs/guides/structured-outputs
Basically it allows to drastically reduce hallucination problems while generating tool calls.

The strict mode has the problem that only a subset of the json spec is supported.
One of the caveats is that all fields must be required. So the workaround is to use an "anyOf" schema with the type null.

For example if we want to make the "limit" parameter optional we can specify it like this:

{
            "name": "limit",
            "in": "query",
            "required": true,
            "schema": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Maximum number of records to return (1-100)",
              "title": "Limit"
            },
            "description": "Maximum number of records to return (1-100)"
          },

But then the model will call the api with "limit=null" .
So the PR adds the option to remove null parameters from the api call, so that your api backend won't choke on the null parameter.

…objects, this allows the OpenAI Assistant to have function calls with 'strict' mode. Also allows the OpenAI assistant to call several tools in the same run. And adds a checkbox 'remove Nulls' for the OpenAPI toolkit so that parameters with null values are not passed to the backend api.
@owengo
Copy link
Author

owengo commented Feb 6, 2025

Sorry but I can't reproduce the error, the cypress tests do pass, it's the nodejs cleanup action which seems to have failed

@HenryHengZJ
Copy link
Contributor

can you pull the latest changes? it should be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants