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

.Net: Fix handling of required calls with OpenAI #4474

Merged
merged 4 commits into from
Jan 9, 2024

Conversation

stephentoub
Copy link
Member

The {Azure} OpenAI service allows a tool to be specified as required, in which case it'll always respond with an invocation of that tool; essentially it's a way to get the service to populate the arguments to a method. However, when doing so, the service also always immediately completes the chat with a stop finish reason; it apparently assumes its job is done because it sent back the required function information. That means we'd stop processing the function calls because we were looking for a finish reason of tool call. This changes it to invoke functions if any were specified, regardless of the finish reason.

Fixes #4470

@stephentoub stephentoub marked this pull request as ready for review January 4, 2024 03:36
@stephentoub stephentoub requested a review from a team as a code owner January 4, 2024 03:36
@shawncal shawncal added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Jan 4, 2024
@github-actions github-actions bot changed the title Fix handling of required calls with OpenAI .Net: Fix handling of required calls with OpenAI Jan 4, 2024
@stephentoub stephentoub enabled auto-merge January 4, 2024 03:37
The {Azure} OpenAI service allows a tool to be specified as required, in which case it'll always respond with an invocation of that tool; essentially it's a way to get the service to populate the arguments to a method. However, when doing so, the service also always immediately completes the chat with a stop finish reason; it apparently assumes its job is done because it sent back the required function information. That means we'd stop processing the function calls because we were looking for a finish reason of tool call.  This changes it to invoke functions if any were specified, regardless of the finish reason.
@stephentoub stephentoub added this pull request to the merge queue Jan 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2024
@stephentoub stephentoub enabled auto-merge January 9, 2024 14:44
@stephentoub stephentoub added this pull request to the merge queue Jan 9, 2024
Merged via the queue into microsoft:main with commit 7c3a01c Jan 9, 2024
@stephentoub stephentoub deleted the fixrequired branch January 9, 2024 14:58
Bryan-Roe pushed a commit to Bryan-Roe-ai/semantic-kernel that referenced this pull request Oct 6, 2024
The {Azure} OpenAI service allows a tool to be specified as required, in
which case it'll always respond with an invocation of that tool;
essentially it's a way to get the service to populate the arguments to a
method. However, when doing so, the service also always immediately
completes the chat with a stop finish reason; it apparently assumes its
job is done because it sent back the required function information. That
means we'd stop processing the function calls because we were looking
for a finish reason of tool call. This changes it to invoke functions if
any were specified, regardless of the finish reason.

Fixes microsoft#4470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.Net: ToolCallBehavior = ToolCallBehavior.RequireFunction(wikiFunction, true) seems to be broken
5 participants