openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Assistants/Streaming/RunUpdate.cs
28lines · modecode
| 1 | using System.ClientModel.Primitives; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Diagnostics.CodeAnalysis; |
| 4 | using System.Text.Json; |
| 5 | |
| 6 | namespace OpenAI.Assistants; |
| 7 | |
| 8 | /// <summary> |
| 9 | /// The update type presented when the status of a <see cref="ThreadRun"/> has changed. |
| 10 | /// </summary> |
| 11 | [Experimental("OPENAI001")] |
| 12 | public class RunUpdate : StreamingUpdate<ThreadRun> |
| 13 | { |
| 14 | internal RunUpdate(ThreadRun run, StreamingUpdateReason updateKind) : base(run, updateKind) |
| 15 | { } |
| 16 | |
| 17 | internal static IEnumerable<StreamingUpdate<ThreadRun>> DeserializeRunUpdates( |
| 18 | JsonElement element, |
| 19 | StreamingUpdateReason updateKind, |
| 20 | ModelReaderWriterOptions options = null) |
| 21 | { |
| 22 | ThreadRun run = ThreadRun.DeserializeThreadRun(element, options); |
| 23 | return updateKind switch |
| 24 | { |
| 25 | _ => [new RunUpdate(run, updateKind)], |
| 26 | }; |
| 27 | } |
| 28 | } |
| 29 | |