in src/Custom/Assistants/Streaming/StreamingUpdate.cs [45:79]
internal static IEnumerable<StreamingUpdate> FromSseItem(SseItem<byte[]> sseItem)
{
StreamingUpdateReason updateKind = StreamingUpdateReasonExtensions.FromSseEventLabel(sseItem.EventType);
using JsonDocument dataDocument = JsonDocument.Parse(sseItem.Data);
JsonElement e = dataDocument.RootElement;
ModelReaderWriterOptions serializationOptions = ModelReaderWriterOptions.Json;
return updateKind switch
{
StreamingUpdateReason.ThreadCreated => ThreadUpdate.DeserializeThreadCreationUpdates(e, updateKind, serializationOptions),
StreamingUpdateReason.RunCreated
or StreamingUpdateReason.RunQueued
or StreamingUpdateReason.RunInProgress
or StreamingUpdateReason.RunCompleted
or StreamingUpdateReason.RunIncomplete
or StreamingUpdateReason.RunFailed
or StreamingUpdateReason.RunCancelling
or StreamingUpdateReason.RunCancelled
or StreamingUpdateReason.RunExpired => RunUpdate.DeserializeRunUpdates(e, updateKind, serializationOptions),
StreamingUpdateReason.RunRequiresAction => RequiredActionUpdate.DeserializeRequiredActionUpdates(e),
StreamingUpdateReason.RunStepCreated
or StreamingUpdateReason.RunStepInProgress
or StreamingUpdateReason.RunStepCompleted
or StreamingUpdateReason.RunStepFailed
or StreamingUpdateReason.RunStepCancelled
or StreamingUpdateReason.RunStepExpired => RunStepUpdate.DeserializeRunStepUpdates(e, updateKind, serializationOptions),
StreamingUpdateReason.MessageCreated
or StreamingUpdateReason.MessageInProgress
or StreamingUpdateReason.MessageCompleted
or StreamingUpdateReason.MessageFailed => MessageStatusUpdate.DeserializeMessageStatusUpdates(e, updateKind, serializationOptions),
StreamingUpdateReason.RunStepUpdated => RunStepDetailsUpdate.DeserializeRunStepDetailsUpdates(e, updateKind, serializationOptions),
StreamingUpdateReason.MessageUpdated => MessageContentUpdate.DeserializeMessageContentUpdates(e, updateKind, serializationOptions),
_ => null,
};
}