-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is no way to get bedrock streaming api responses using async io. #3360
Comments
Needs review with the team. |
The normal request / response APIs are using async don't the http client but I agree after revisiting the for response streaming that the At a minimum we should rework the ProcessLoop to use async / await. |
I created a PR to add a new |
@lucasmeijer The PR Norm mentioned was included in the latest version of the |
I'm on #PackageReference Include="AWSSDK.BedrockRuntime" Version="3.7.306" # which still seems to be the most recent version available? |
No, the latest version is https://www.nuget.org/packages/AWSSDK.BedrockRuntime/3.7.307.1 |
Comments on closed issues are hard for our team to see. |
@normj @dscpinheiro (tagging you as requested by the bot above). Good news: the new package works, and allows me to solve my problem. static async IAsyncEnumerable<PayloadPart> PayloadPartsFrom(InvokeModelWithResponseStreamResponse r)
{
ConcurrentQueue<PayloadPart> queue = new();
using SemaphoreSlim semaphore = new(0);
void OnBodyOnChunkReceived(object? sender, EventStreamEventReceivedArgs<PayloadPart> args)
{
queue.Enqueue(args.EventStreamEvent);
semaphore.Release();
}
r.Body.ChunkReceived += OnBodyOnChunkReceived;
var finishTask = r.Body.StartProcessingAsync();
while (true)
{
var t = await Task.WhenAny(semaphore.WaitAsync(), finishTask);
if (t == finishTask)
yield break;
while (queue.TryDequeue(out var p))
yield return p;
}
} |
Describe the bug
This is unfortunate. The threads that are supposed to handle new incoming requests for my server, are now blocked on very long running blocking network calls. (AI model responses are easily 30s, (spread out over many events)).
Expected Behavior
I would expect a way that allows me to use async enumeration:
EnumerateEventsAsync would under the hood not use blocking io, leaving my servers
threads available to do server work, and come back to this network request only when
data is there.
Current Behavior
server threads being blocked.
Reproduction Steps
see code snippet in description
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Targeted .NET Platform
net8
Operating System and version
all
The text was updated successfully, but these errors were encountered: