Files
semantic-kernel/python/semantic_kernel/connectors
3e771ec540 Python: Add missing index in Bedrock FunctionCallContent instantiation (#12203)
### Motivation and Context
The current implementation of `BedrockChatCompletion` does not correctly
initialize `FunctionCallContent` instances when using the Converse
Stream API, as the index is not set. As a result, when adding two
consecutive `FunctionCallContent` instances that belong to different
function calls, the `__add__` method does not raise a
`ContentAdditionException` exception, and the parameters are incorrectly
merged.

### Description
This PR ensures proper initialization of the index in
`FunctionCallContent` instances by using the `contentBlockIndex` value
returned by the Converse Stream API in both delta and start content
block messages. This prevents parameters from different function calls
from being merged.

See:
-
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ContentBlockDeltaEvent.html
-
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ContentBlockStartEvent.html

Closes #12202

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

Co-authored-by: Javier Cruz <[email protected]>
Co-authored-by: Evan Mattson <[email protected]>
2025-05-23 03:58:40 +00:00
..
2024-11-19 16:36:01 +00:00