semantic-kernel
semantic-kernel copied to clipboard
.Net: Fix Gemini Auto Invoke when returned function is non-first part
Motivation and Context
Fixes #11651
- Currently Gemini Connectors will not Auto invoke functions when tool calls are returned in the same message with text parts, which is common with 2.5 Flash and Pro models:
"content": {
"parts": [
{
"text": "Running the TimePlugin.Now function..."
},
{
"functionCall": {
"name": "TimePlugin.Now",
"args": {
"param1": "hello"
}
}
}
],
"role": "model"
}
This fixes this to now support auto kernel functions with this behavior and adds unit tests with this data.
Description
- Added unit test data for streaming responses with text & tool parts
- Changed
GetChatMessageContentFromCandidateto return tools from all candidate parts instead of only the first part - Added extra check in
GenerateChatMessageAsyncfor empty Tool results - Fixed stream responses in auto invoke mode with texts & tool parts not returned to the caller, added unit test
Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the SK Contribution Guidelines and the pre-submission formatting script raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile: