microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.95k stars 3.27k forks source link

.Net: Bug: .NET Bedrock streaming completion is keeping the request thread busy #9519

Open tlecomte opened 1 week ago

tlecomte commented 1 week ago

Describe the bug The current implementation of the Bedrock connector is using response.Stream.AsEnumerable() in BedrockChatCompletionClient.cs#L193, which is keeping the current .NET thread busy while it reads the response stream. This could cause thread exhaustion issues.

To Reproduce Steps to reproduce the behavior:

Expected behavior Replace .AsEnumerable() with something that would read the response stream in an async manner.

Screenshots N/A

Platform

Additional context

tlecomte commented 1 week ago

I realize that, ideally, the AWS .NET SDK would provide a solution out of the box. So I've also created https://github.com/aws/aws-sdk-net/issues/3542 and will suggest a solution there first.

evchaki commented 1 week ago

@RogerBarreto - can you take a look at this? @tlecomte - thanks for submitting this, we will take a look at updating this.