.Net: Fix handling of required calls with OpenAI #4474
Merged
+10
−7
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.
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