Skip to content

Several features for OpenAPI toolkit and OpenAI Assistants #3989

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 3 commits into from
Feb 28, 2025

Conversation

owengo
Copy link
Contributor

@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
Contributor 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

@AsharibAli
Copy link
Contributor

Amazing work, guys!

Copy link
Contributor

@HenryHengZJ HenryHengZJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works like a charm!
image

truly appreciate the work you put in @owengo !

@HenryHengZJ HenryHengZJ merged commit e58c8b9 into FlowiseAI:main Feb 28, 2025
2 checks passed
galexandrov pushed a commit to xheal/Flowise that referenced this pull request Mar 3, 2025
…#3989)

* Allows 'x-strict' attribute in OpenAPI spec tool and other json spec 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.

* fix lint errors

---------

Co-authored-by: Olivier Schiavo <[email protected]>
JJK801 pushed a commit to JJK801/Flowise that referenced this pull request Apr 9, 2025
…#3989)

* Allows 'x-strict' attribute in OpenAPI spec tool and other json spec 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.

* fix lint errors

---------

Co-authored-by: Olivier Schiavo <[email protected]>
Yshayy pushed a commit to Yshayy/Flowise that referenced this pull request Apr 23, 2025
…#3989)

* Allows 'x-strict' attribute in OpenAPI spec tool and other json spec 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.

* fix lint errors

---------

Co-authored-by: Olivier Schiavo <[email protected]>
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.

5 participants