-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Sanitize function names (#10257)
### Motivation and Context Currently, if an AI model hallucinates a function name (e.g., `bar.foo` instead of the advertised `bar-foo`) that contains disallowed characters (not in the range of `a-zA-Z0-9_-`), SK identifies it as an error case and sends the error back to the model along with the original function call. Given that the original function call contains the disallowed function name, the request to the AI model fails with the error: _Invalid 'messages[6].tool_calls[0].function.name': string does not match pattern. Expected a string that matches the pattern `^[a-zA-Z0-9_-]+$`._ ### Description This PR replaces disallowed characters in function names with an underscore for all function calls before sending them to the AI model. This fix prevents the request to the AI model from failing and allows the model to auto-recover. More context: [Function Calling Reliability ADR](https://github.com/microsoft/semantic-kernel/blob/main/docs/decisions/0063-function-calling-reliability.md#function-calling-reliability) Closes: #9850
- Loading branch information
1 parent
ef28a1e
commit e98155a
Showing
2 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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