diff --git a/api/OpenAI.net8.0.cs b/api/OpenAI.net8.0.cs index a1c60e02e..b229237fa 100644 --- a/api/OpenAI.net8.0.cs +++ b/api/OpenAI.net8.0.cs @@ -1412,6 +1412,10 @@ public class ChatMessageContent : ObjectModel.Collection public ChatMessageContent(string content); } public class ChatMessageContentPart : IJsonModel, IPersistableModel { + public BinaryData FileBytes { get; } + public string FileBytesMediaType { get; } + public string FileId { get; } + public string Filename { get; } public BinaryData ImageBytes { get; } public string ImageBytesMediaType { get; } public ChatImageDetailLevel? ImageDetailLevel { get; } @@ -1421,6 +1425,8 @@ public class ChatMessageContentPart : IJsonModel, IPersi public ChatMessageContentPartKind Kind { get; } public string Refusal { get; } public string Text { get; } + public static ChatMessageContentPart CreateFilePart(BinaryData fileBytes, string fileBytesMediaType, string filename); + public static ChatMessageContentPart CreateFilePart(string fileId); public static ChatMessageContentPart CreateImagePart(BinaryData imageBytes, string imageBytesMediaType, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateImagePart(Uri imageUri, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateInputAudioPart(BinaryData inputAudioBytes, ChatInputAudioFormat inputAudioFormat); @@ -1434,7 +1440,8 @@ public enum ChatMessageContentPartKind { Text = 0, Refusal = 1, Image = 2, - InputAudio = 3 + InputAudio = 3, + File = 4 } public enum ChatMessageRole { System = 0, @@ -2830,6 +2837,7 @@ public class RealtimeConversationSession : IDisposable { } } namespace OpenAI.Responses { + [Experimental("OPENAICUA001")] public class ComputerCallAction : IJsonModel, IPersistableModel { public Drawing.Point? ClickCoordinates { get; } public ComputerCallActionMouseButton? ClickMouseButton { get; } @@ -2854,6 +2862,7 @@ public class ComputerCallAction : IJsonModel, IPersistableMo public static explicit operator ComputerCallAction(ClientResult result); public static implicit operator BinaryContent(ComputerCallAction computerCallAction); } + [Experimental("OPENAICUA001")] public enum ComputerCallActionKind { Click = 0, DoubleClick = 1, @@ -2865,6 +2874,7 @@ public enum ComputerCallActionKind { Type = 7, Wait = 8 } + [Experimental("OPENAICUA001")] public enum ComputerCallActionMouseButton { Left = 0, Right = 1, @@ -2872,6 +2882,7 @@ public enum ComputerCallActionMouseButton { Back = 3, Forward = 4 } + [Experimental("OPENAICUA001")] public class ComputerCallOutputResponseItem : ResponseItem, IJsonModel, IPersistableModel { public ComputerCallOutputResponseItem(string callId, IEnumerable acknowledgedSafetyChecks, ComputerOutput output); public IList AcknowledgedSafetyChecks { get; } @@ -2881,13 +2892,15 @@ public class ComputerCallOutputResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public ComputerCallResponseItem(string id, string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); + public ComputerCallResponseItem(string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); public ComputerCallAction Action { get; set; } public string CallId { get; set; } public IList PendingSafetyChecks { get; } @@ -2895,6 +2908,7 @@ public class ComputerCallResponseItem : ResponseItem, IJsonModel, IPersistableModel { public ComputerCallSafetyCheck(string id, string code, string message); public string Code { get; set; } @@ -2903,11 +2917,13 @@ public class ComputerCallSafetyCheck : IJsonModel, IPer public static explicit operator ComputerCallSafetyCheck(ClientResult result); public static implicit operator BinaryContent(ComputerCallSafetyCheck computerCallSafetyCheck); } + [Experimental("OPENAICUA001")] public enum ComputerCallStatus { InProgress = 0, Completed = 1, Incomplete = 2 } + [Experimental("OPENAICUA001")] public class ComputerOutput : IJsonModel, IPersistableModel { public static ComputerOutput CreateScreenshotOutput(BinaryData screenshotImageBytes, string screenshotImageBytesMediaType); public static ComputerOutput CreateScreenshotOutput(string screenshotImageFileId); @@ -2915,6 +2931,7 @@ public class ComputerOutput : IJsonModel, IPersistableModel { public ComputerToolEnvironment(string value); public static ComputerToolEnvironment Browser { get; } @@ -2932,7 +2949,7 @@ public class ComputerOutput : IJsonModel, IPersistableModel, IPersistableModel { - public FileSearchCallResponseItem(string id, IEnumerable queries, IEnumerable results); + public FileSearchCallResponseItem(IEnumerable queries, IEnumerable results); public IList Queries { get; } public IList Results { get; set; } public FileSearchCallStatus Status { get; } @@ -2989,7 +3006,7 @@ public enum FunctionCallOutputStatus { Incomplete = 2 } public class FunctionCallResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public FunctionCallResponseItem(string id, string callId, string functionName, BinaryData functionArguments); + public FunctionCallResponseItem(string callId, string functionName, BinaryData functionArguments); public string CallId { get; set; } public BinaryData FunctionArguments { get; set; } public string FunctionName { get; set; } @@ -3003,28 +3020,18 @@ public enum FunctionCallStatus { Incomplete = 2 } public class MessageResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public MessageResponseItem(MessageRole role); public IList Content { get; } public MessageRole Role { get; } public MessageStatus? Status { get; } public new static explicit operator MessageResponseItem(ClientResult result); public static implicit operator BinaryContent(MessageResponseItem messageResponseItem); } - public readonly partial struct MessageRole : IEquatable { - public MessageRole(string value); - public static MessageRole Assistant { get; } - public static MessageRole Developer { get; } - public static MessageRole System { get; } - public static MessageRole User { get; } - public readonly bool Equals(MessageRole other); - [EditorBrowsable(global::EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(global::EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(MessageRole left, MessageRole right); - public static implicit operator MessageRole(string value); - public static bool operator !=(MessageRole left, MessageRole right); - public override readonly string ToString(); + public enum MessageRole { + Unknown = 0, + Assistant = 1, + Developer = 2, + System = 3, + User = 4 } public enum MessageStatus { InProgress = 0, @@ -3032,7 +3039,6 @@ public enum MessageStatus { Incomplete = 2 } public class OpenAIResponse : IJsonModel, IPersistableModel { - public bool AllowParallelToolCalls { get; } public DateTimeOffset CreatedAt { get; } public string EndUserId { get; } public ResponseError Error { get; } @@ -3043,16 +3049,18 @@ public class OpenAIResponse : IJsonModel, IPersistableModel Metadata { get; } public string Model { get; } public IList OutputItems { get; } + public bool ParallelToolCallsEnabled { get; } public string PreviousResponseId { get; } public ResponseReasoningOptions ReasoningOptions { get; } public ResponseStatus? Status { get; } public float Temperature { get; } public ResponseTextOptions TextOptions { get; } - public BinaryData ToolChoice { get; } + public ResponseToolChoice ToolChoice { get; } public IList Tools { get; } public float TopP { get; } public ResponseTruncationMode? TruncationMode { get; } public ResponseTokenUsage Usage { get; } + public string GetOutputText(); public static explicit operator OpenAIResponse(ClientResult result); public static implicit operator BinaryContent(OpenAIResponse openAIResponse); } @@ -3095,7 +3103,7 @@ public class OpenAIResponseClient { public virtual AsyncCollectionResult GetResponseInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options = null); } public class ReasoningResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public ReasoningResponseItem(string id, IEnumerable summaryTextParts); + public ReasoningResponseItem(IEnumerable summaryTextParts); public ReasoningStatus? Status { get; } public IReadOnlyList SummaryTextParts { get; } public new static explicit operator ReasoningResponseItem(ClientResult result); @@ -3132,25 +3140,26 @@ public class ResponseContentPart : IJsonModel, IPersistable public static implicit operator BinaryContent(ResponseContentPart responseContentPart); } public enum ResponseContentPartKind { - InputText = 0, - InputImage = 1, - InputFile = 2, - OutputText = 3, - Refusal = 4 + Unknown = 0, + InputText = 1, + InputImage = 2, + InputFile = 3, + OutputText = 4, + Refusal = 5 } public class ResponseCreationOptions : IJsonModel, IPersistableModel { - public bool? AllowParallelToolCalls { get; set; } public string EndUserId { get; set; } public string Instructions { get; set; } public int? MaxOutputTokenCount { get; set; } public IDictionary Metadata { get; } + public bool? ParallelToolCallsEnabled { get; set; } public string PreviousResponseId { get; set; } public ResponseReasoningOptions ReasoningOptions { get; set; } public bool? StoredOutputEnabled { get; set; } public float? Temperature { get; set; } public ResponseTextOptions TextOptions { get; set; } - public BinaryData ToolChoice { get; set; } - public IList Tools { get; set; } + public ResponseToolChoice ToolChoice { get; set; } + public IList Tools { get; } public float? TopP { get; set; } public ResponseTruncationMode? TruncationMode { get; set; } public static explicit operator ResponseCreationOptions(ClientResult result); @@ -3204,24 +3213,28 @@ public class ResponseIncompleteStatusDetails : IJsonModel, IPersistableModel { public string Id { get; } - public static MessageResponseItem CreateAssistantMessageItem(string id, string content); - public static ResponseItem CreateComputerCallItem(string id, string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); + public static MessageResponseItem CreateAssistantMessageItem(IEnumerable contentParts); + public static MessageResponseItem CreateAssistantMessageItem(string outputTextContent, IEnumerable annotations = null); + [Experimental("OPENAICUA001")] + public static ResponseItem CreateComputerCallItem(string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); [Experimental("OPENAICUA001")] public static ResponseItem CreateComputerCallOutputItem(string callId, IList acknowledgedSafetyChecks, BinaryData screenshotImageBytes, string screenshotImageBytesMediaType); [Experimental("OPENAICUA001")] public static ResponseItem CreateComputerCallOutputItem(string callId, IList acknowledgedSafetyChecks, string screenshotImageFileId); [Experimental("OPENAICUA001")] public static ResponseItem CreateComputerCallOutputItem(string callId, IList acknowledgedSafetyChecks, Uri screenshotImageUri); - public static MessageResponseItem CreateDeveloperMessageItem(string content); - public static FileSearchCallResponseItem CreateFileSearchCallResponseItem(string id, IEnumerable queries, IEnumerable results); - public static FunctionCallResponseItem CreateFunctionCall(string id, string callId, string functionName, BinaryData functionArguments); + public static MessageResponseItem CreateDeveloperMessageItem(IEnumerable contentParts); + public static MessageResponseItem CreateDeveloperMessageItem(string inputTextContent); + public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable queries, IEnumerable results); + public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments); public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput); - public static ReasoningResponseItem CreateReasoningItem(string id, IEnumerable summaryTextParts); + public static ReasoningResponseItem CreateReasoningItem(IEnumerable summaryTextParts); public static ReferenceResponseItem CreateReferenceItem(string id); - public static MessageResponseItem CreateSystemMessageItem(string content); + public static MessageResponseItem CreateSystemMessageItem(IEnumerable contentParts); + public static MessageResponseItem CreateSystemMessageItem(string inputTextContent); public static MessageResponseItem CreateUserMessageItem(IEnumerable contentParts); - public static MessageResponseItem CreateUserMessageItem(string content); - public static WebSearchCallResponseItem CreateWebSearchCallItem(string id); + public static MessageResponseItem CreateUserMessageItem(string inputTextContent); + public static WebSearchCallResponseItem CreateWebSearchCallItem(); public static explicit operator ResponseItem(ClientResult result); public static implicit operator BinaryContent(ResponseItem responseItem); } @@ -3314,14 +3327,21 @@ public enum ResponseStatus { Failed = 3 } public class ResponseTextFormat : IJsonModel, IPersistableModel { + public ResponseTextFormatKind Kind { get; set; } public static ResponseTextFormat CreateJsonObjectFormat(); public static ResponseTextFormat CreateJsonSchemaFormat(string jsonSchemaFormatName, BinaryData jsonSchema, string jsonSchemaFormatDescription = null, bool? jsonSchemaIsStrict = null); public static ResponseTextFormat CreateTextFormat(); public static explicit operator ResponseTextFormat(ClientResult result); public static implicit operator BinaryContent(ResponseTextFormat responseTextFormat); } + public enum ResponseTextFormatKind { + Unknown = 0, + Text = 1, + JsonObject = 2, + JsonSchema = 3 + } public class ResponseTextOptions : IJsonModel, IPersistableModel { - public ResponseTextFormat ResponseFormat { get; set; } + public ResponseTextFormat TextFormat { get; set; } public static explicit operator ResponseTextOptions(ClientResult result); public static implicit operator BinaryContent(ResponseTextOptions responseTextOptions); } @@ -3342,6 +3362,28 @@ public class ResponseTool : IJsonModel, IPersistableModel, IPersistableModel { + public string FunctionName { get; } + public ResponseToolChoiceKind Kind { get; } + public static ResponseToolChoice CreateAutoChoice(); + [Experimental("OPENAICUA001")] + public static ResponseToolChoice CreateComputerChoice(); + public static ResponseToolChoice CreateFileSearchChoice(); + public static ResponseToolChoice CreateFunctionChoice(string functionName); + public static ResponseToolChoice CreateNoneChoice(); + public static ResponseToolChoice CreateRequiredChoice(); + public static ResponseToolChoice CreateWebSearchChoice(); + } + public enum ResponseToolChoiceKind { + Unknown = 0, + Auto = 1, + None = 2, + Required = 3, + Function = 4, + FileSearch = 5, + WebSearch = 6, + Computer = 7 + } public readonly partial struct ResponseTruncationMode : IEquatable { public ResponseTruncationMode(string value); public static ResponseTruncationMode Auto { get; } @@ -3356,13 +3398,31 @@ public class ResponseTool : IJsonModel, IPersistableModel, IPersistableModel { - public int ContentPartIndex { get; } - public string FunctionArguments { get; } + public class StreamingResponseCompletedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseCompletedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseCompletedUpdate streamingResponseCompletedUpdate); + } + public class StreamingResponseContentPartAddedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } public string ItemId { get; } - public int ItemIndex { get; } - public string Refusal { get; } - public string Text { get; } + public int OutputIndex { get; } + public ResponseContentPart Part { get; } + public new static explicit operator StreamingResponseContentPartAddedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseContentPartAddedUpdate streamingResponseContentPartAddedUpdate); + } + public class StreamingResponseContentPartDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public ResponseContentPart Part { get; } + public new static explicit operator StreamingResponseContentPartDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseContentPartDoneUpdate streamingResponseContentPartDoneUpdate); + } + public class StreamingResponseCreatedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseCreatedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseCreatedUpdate streamingResponseCreatedUpdate); } public class StreamingResponseErrorUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { public string Code { get; } @@ -3371,71 +3431,129 @@ public class StreamingResponseErrorUpdate : StreamingResponseUpdate, IJsonModel< public new static explicit operator StreamingResponseErrorUpdate(ClientResult result); public static implicit operator BinaryContent(StreamingResponseErrorUpdate streamingResponseErrorUpdate); } - public class StreamingResponseFileSearchCallUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { - public string OutputItemId { get; } - public int OutputItemIndex { get; } + public class StreamingResponseFailedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseFailedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFailedUpdate streamingResponseFailedUpdate); } - public class StreamingResponseItemUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { - public ResponseItem Item { get; } - public int ItemIndex { get; } + public class StreamingResponseFileSearchCallCompletedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFileSearchCallCompletedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFileSearchCallCompletedUpdate streamingResponseFileSearchCallCompletedUpdate); + } + public class StreamingResponseFileSearchCallInProgressUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFileSearchCallInProgressUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFileSearchCallInProgressUpdate streamingResponseFileSearchCallInProgressUpdate); } - public class StreamingResponseStatusUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public class StreamingResponseFileSearchCallSearchingUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFileSearchCallSearchingUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFileSearchCallSearchingUpdate streamingResponseFileSearchCallSearchingUpdate); + } + public class StreamingResponseFunctionCallArgumentsDeltaUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string Delta { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFunctionCallArgumentsDeltaUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFunctionCallArgumentsDeltaUpdate streamingResponseFunctionCallArgumentsDeltaUpdate); + } + public class StreamingResponseFunctionCallArgumentsDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string Arguments { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFunctionCallArgumentsDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFunctionCallArgumentsDoneUpdate streamingResponseFunctionCallArgumentsDoneUpdate); + } + public class StreamingResponseIncompleteUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseIncompleteUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseIncompleteUpdate streamingResponseIncompleteUpdate); + } + public class StreamingResponseInProgressUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseInProgressUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseInProgressUpdate streamingResponseInProgressUpdate); + } + public class StreamingResponseOutputItemAddedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public ResponseItem Item { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseOutputItemAddedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputItemAddedUpdate streamingResponseOutputItemAddedUpdate); + } + public class StreamingResponseOutputItemDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public ResponseItem Item { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseOutputItemDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputItemDoneUpdate streamingResponseOutputItemDoneUpdate); + } + public class StreamingResponseOutputTextDeltaUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string Delta { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseOutputTextDeltaUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputTextDeltaUpdate streamingResponseOutputTextDeltaUpdate); } - public class StreamingResponseTextAnnotationUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public class StreamingResponseOutputTextDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public string Text { get; } + public new static explicit operator StreamingResponseOutputTextDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputTextDoneUpdate streamingResponseOutputTextDoneUpdate); + } + public class StreamingResponseRefusalDeltaUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string Delta { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseRefusalDeltaUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseRefusalDeltaUpdate streamingResponseRefusalDeltaUpdate); + } + public class StreamingResponseRefusalDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public string Refusal { get; } + public new static explicit operator StreamingResponseRefusalDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseRefusalDoneUpdate streamingResponseRefusalDoneUpdate); + } + public class StreamingResponseTextAnnotationAddedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { public ResponseMessageAnnotation Annotation { get; } public int ContentIndex { get; } public string ItemId { get; } public int OutputIndex { get; } - public new static explicit operator StreamingResponseTextAnnotationUpdate(ClientResult result); - public static implicit operator BinaryContent(StreamingResponseTextAnnotationUpdate streamingResponseTextAnnotationUpdate); + public new static explicit operator StreamingResponseTextAnnotationAddedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseTextAnnotationAddedUpdate streamingResponseTextAnnotationAddedUpdate); } public class StreamingResponseUpdate : IJsonModel, IPersistableModel { - public StreamingResponseUpdateKind Kind { get; } public static explicit operator StreamingResponseUpdate(ClientResult result); public static implicit operator BinaryContent(StreamingResponseUpdate streamingResponseUpdate); } - public readonly partial struct StreamingResponseUpdateKind : IEquatable { - public StreamingResponseUpdateKind(string value); - public static StreamingResponseUpdateKind Error { get; } - public static StreamingResponseUpdateKind ResponseCompleted { get; } - public static StreamingResponseUpdateKind ResponseContentPartAdded { get; } - public static StreamingResponseUpdateKind ResponseContentPartDone { get; } - public static StreamingResponseUpdateKind ResponseCreated { get; } - public static StreamingResponseUpdateKind ResponseFailed { get; } - public static StreamingResponseUpdateKind ResponseFileSearchCallCompleted { get; } - public static StreamingResponseUpdateKind ResponseFileSearchCallInProgress { get; } - public static StreamingResponseUpdateKind ResponseFileSearchCallSearching { get; } - public static StreamingResponseUpdateKind ResponseFunctionCallArgumentsDelta { get; } - public static StreamingResponseUpdateKind ResponseFunctionCallArgumentsDone { get; } - public static StreamingResponseUpdateKind ResponseIncomplete { get; } - public static StreamingResponseUpdateKind ResponseInProgress { get; } - public static StreamingResponseUpdateKind ResponseOutputItemAdded { get; } - public static StreamingResponseUpdateKind ResponseOutputItemDone { get; } - public static StreamingResponseUpdateKind ResponseOutputTextAnnotationAdded { get; } - public static StreamingResponseUpdateKind ResponseOutputTextDelta { get; } - public static StreamingResponseUpdateKind ResponseOutputTextDone { get; } - public static StreamingResponseUpdateKind ResponseRefusalDelta { get; } - public static StreamingResponseUpdateKind ResponseRefusalDone { get; } - public static StreamingResponseUpdateKind ResponseWebSearchCallCompleted { get; } - public static StreamingResponseUpdateKind ResponseWebSearchCallInProgress { get; } - public static StreamingResponseUpdateKind ResponseWebSearchCallSearching { get; } - public readonly bool Equals(StreamingResponseUpdateKind other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(StreamingResponseUpdateKind left, StreamingResponseUpdateKind right); - public static implicit operator StreamingResponseUpdateKind(string value); - public static bool operator !=(StreamingResponseUpdateKind left, StreamingResponseUpdateKind right); - public override readonly string ToString(); + public class StreamingResponseWebSearchCallCompletedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseWebSearchCallCompletedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseWebSearchCallCompletedUpdate streamingResponseWebSearchCallCompletedUpdate); } - public class StreamingResponseWebSearchCallUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { - public string OutputItemId { get; } - public int OutputItemIndex { get; } + public class StreamingResponseWebSearchCallInProgressUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseWebSearchCallInProgressUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseWebSearchCallInProgressUpdate streamingResponseWebSearchCallInProgressUpdate); + } + public class StreamingResponseWebSearchCallSearchingUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseWebSearchCallSearchingUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseWebSearchCallSearchingUpdate streamingResponseWebSearchCallSearchingUpdate); } public class WebSearchCallResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public WebSearchCallResponseItem(string id); + public WebSearchCallResponseItem(); public WebSearchCallStatus Status { get; } public new static explicit operator WebSearchCallResponseItem(ClientResult result); public static implicit operator BinaryContent(WebSearchCallResponseItem webSearchCallResponseItem); diff --git a/api/OpenAI.netstandard2.0.cs b/api/OpenAI.netstandard2.0.cs index d96748af0..596339796 100644 --- a/api/OpenAI.netstandard2.0.cs +++ b/api/OpenAI.netstandard2.0.cs @@ -1323,6 +1323,10 @@ public class ChatMessageContent : ObjectModel.Collection public ChatMessageContent(string content); } public class ChatMessageContentPart : IJsonModel, IPersistableModel { + public BinaryData FileBytes { get; } + public string FileBytesMediaType { get; } + public string FileId { get; } + public string Filename { get; } public BinaryData ImageBytes { get; } public string ImageBytesMediaType { get; } public ChatImageDetailLevel? ImageDetailLevel { get; } @@ -1332,6 +1336,8 @@ public class ChatMessageContentPart : IJsonModel, IPersi public ChatMessageContentPartKind Kind { get; } public string Refusal { get; } public string Text { get; } + public static ChatMessageContentPart CreateFilePart(BinaryData fileBytes, string fileBytesMediaType, string filename); + public static ChatMessageContentPart CreateFilePart(string fileId); public static ChatMessageContentPart CreateImagePart(BinaryData imageBytes, string imageBytesMediaType, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateImagePart(Uri imageUri, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateInputAudioPart(BinaryData inputAudioBytes, ChatInputAudioFormat inputAudioFormat); @@ -1345,7 +1351,8 @@ public enum ChatMessageContentPartKind { Text = 0, Refusal = 1, Image = 2, - InputAudio = 3 + InputAudio = 3, + File = 4 } public enum ChatMessageRole { System = 0, @@ -2734,7 +2741,7 @@ public enum ComputerCallOutputStatus { Incomplete = 2 } public class ComputerCallResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public ComputerCallResponseItem(string id, string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); + public ComputerCallResponseItem(string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); public ComputerCallAction Action { get; set; } public string CallId { get; set; } public IList PendingSafetyChecks { get; } @@ -2779,7 +2786,7 @@ public class ComputerOutput : IJsonModel, IPersistableModel, IPersistableModel { - public FileSearchCallResponseItem(string id, IEnumerable queries, IEnumerable results); + public FileSearchCallResponseItem(IEnumerable queries, IEnumerable results); public IList Queries { get; } public IList Results { get; set; } public FileSearchCallStatus Status { get; } @@ -2836,7 +2843,7 @@ public enum FunctionCallOutputStatus { Incomplete = 2 } public class FunctionCallResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public FunctionCallResponseItem(string id, string callId, string functionName, BinaryData functionArguments); + public FunctionCallResponseItem(string callId, string functionName, BinaryData functionArguments); public string CallId { get; set; } public BinaryData FunctionArguments { get; set; } public string FunctionName { get; set; } @@ -2850,28 +2857,18 @@ public enum FunctionCallStatus { Incomplete = 2 } public class MessageResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public MessageResponseItem(MessageRole role); public IList Content { get; } public MessageRole Role { get; } public MessageStatus? Status { get; } public new static explicit operator MessageResponseItem(ClientResult result); public static implicit operator BinaryContent(MessageResponseItem messageResponseItem); } - public readonly partial struct MessageRole : IEquatable { - public MessageRole(string value); - public static MessageRole Assistant { get; } - public static MessageRole Developer { get; } - public static MessageRole System { get; } - public static MessageRole User { get; } - public readonly bool Equals(MessageRole other); - [EditorBrowsable(global::EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(global::EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(MessageRole left, MessageRole right); - public static implicit operator MessageRole(string value); - public static bool operator !=(MessageRole left, MessageRole right); - public override readonly string ToString(); + public enum MessageRole { + Unknown = 0, + Assistant = 1, + Developer = 2, + System = 3, + User = 4 } public enum MessageStatus { InProgress = 0, @@ -2879,7 +2876,6 @@ public enum MessageStatus { Incomplete = 2 } public class OpenAIResponse : IJsonModel, IPersistableModel { - public bool AllowParallelToolCalls { get; } public DateTimeOffset CreatedAt { get; } public string EndUserId { get; } public ResponseError Error { get; } @@ -2890,16 +2886,18 @@ public class OpenAIResponse : IJsonModel, IPersistableModel Metadata { get; } public string Model { get; } public IList OutputItems { get; } + public bool ParallelToolCallsEnabled { get; } public string PreviousResponseId { get; } public ResponseReasoningOptions ReasoningOptions { get; } public ResponseStatus? Status { get; } public float Temperature { get; } public ResponseTextOptions TextOptions { get; } - public BinaryData ToolChoice { get; } + public ResponseToolChoice ToolChoice { get; } public IList Tools { get; } public float TopP { get; } public ResponseTruncationMode? TruncationMode { get; } public ResponseTokenUsage Usage { get; } + public string GetOutputText(); public static explicit operator OpenAIResponse(ClientResult result); public static implicit operator BinaryContent(OpenAIResponse openAIResponse); } @@ -2942,7 +2940,7 @@ public class OpenAIResponseClient { public virtual AsyncCollectionResult GetResponseInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options = null); } public class ReasoningResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public ReasoningResponseItem(string id, IEnumerable summaryTextParts); + public ReasoningResponseItem(IEnumerable summaryTextParts); public ReasoningStatus? Status { get; } public IReadOnlyList SummaryTextParts { get; } public new static explicit operator ReasoningResponseItem(ClientResult result); @@ -2979,25 +2977,26 @@ public class ResponseContentPart : IJsonModel, IPersistable public static implicit operator BinaryContent(ResponseContentPart responseContentPart); } public enum ResponseContentPartKind { - InputText = 0, - InputImage = 1, - InputFile = 2, - OutputText = 3, - Refusal = 4 + Unknown = 0, + InputText = 1, + InputImage = 2, + InputFile = 3, + OutputText = 4, + Refusal = 5 } public class ResponseCreationOptions : IJsonModel, IPersistableModel { - public bool? AllowParallelToolCalls { get; set; } public string EndUserId { get; set; } public string Instructions { get; set; } public int? MaxOutputTokenCount { get; set; } public IDictionary Metadata { get; } + public bool? ParallelToolCallsEnabled { get; set; } public string PreviousResponseId { get; set; } public ResponseReasoningOptions ReasoningOptions { get; set; } public bool? StoredOutputEnabled { get; set; } public float? Temperature { get; set; } public ResponseTextOptions TextOptions { get; set; } - public BinaryData ToolChoice { get; set; } - public IList Tools { get; set; } + public ResponseToolChoice ToolChoice { get; set; } + public IList Tools { get; } public float? TopP { get; set; } public ResponseTruncationMode? TruncationMode { get; set; } public static explicit operator ResponseCreationOptions(ClientResult result); @@ -3051,21 +3050,24 @@ public class ResponseIncompleteStatusDetails : IJsonModel, IPersistableModel { public string Id { get; } - public static MessageResponseItem CreateAssistantMessageItem(string id, string content); - public static ResponseItem CreateComputerCallItem(string id, string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); + public static MessageResponseItem CreateAssistantMessageItem(IEnumerable contentParts); + public static MessageResponseItem CreateAssistantMessageItem(string outputTextContent, IEnumerable annotations = null); + public static ResponseItem CreateComputerCallItem(string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks); public static ResponseItem CreateComputerCallOutputItem(string callId, IList acknowledgedSafetyChecks, BinaryData screenshotImageBytes, string screenshotImageBytesMediaType); public static ResponseItem CreateComputerCallOutputItem(string callId, IList acknowledgedSafetyChecks, string screenshotImageFileId); public static ResponseItem CreateComputerCallOutputItem(string callId, IList acknowledgedSafetyChecks, Uri screenshotImageUri); - public static MessageResponseItem CreateDeveloperMessageItem(string content); - public static FileSearchCallResponseItem CreateFileSearchCallResponseItem(string id, IEnumerable queries, IEnumerable results); - public static FunctionCallResponseItem CreateFunctionCall(string id, string callId, string functionName, BinaryData functionArguments); + public static MessageResponseItem CreateDeveloperMessageItem(IEnumerable contentParts); + public static MessageResponseItem CreateDeveloperMessageItem(string inputTextContent); + public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable queries, IEnumerable results); + public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments); public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput); - public static ReasoningResponseItem CreateReasoningItem(string id, IEnumerable summaryTextParts); + public static ReasoningResponseItem CreateReasoningItem(IEnumerable summaryTextParts); public static ReferenceResponseItem CreateReferenceItem(string id); - public static MessageResponseItem CreateSystemMessageItem(string content); + public static MessageResponseItem CreateSystemMessageItem(IEnumerable contentParts); + public static MessageResponseItem CreateSystemMessageItem(string inputTextContent); public static MessageResponseItem CreateUserMessageItem(IEnumerable contentParts); - public static MessageResponseItem CreateUserMessageItem(string content); - public static WebSearchCallResponseItem CreateWebSearchCallItem(string id); + public static MessageResponseItem CreateUserMessageItem(string inputTextContent); + public static WebSearchCallResponseItem CreateWebSearchCallItem(); public static explicit operator ResponseItem(ClientResult result); public static implicit operator BinaryContent(ResponseItem responseItem); } @@ -3156,14 +3158,21 @@ public enum ResponseStatus { Failed = 3 } public class ResponseTextFormat : IJsonModel, IPersistableModel { + public ResponseTextFormatKind Kind { get; set; } public static ResponseTextFormat CreateJsonObjectFormat(); public static ResponseTextFormat CreateJsonSchemaFormat(string jsonSchemaFormatName, BinaryData jsonSchema, string jsonSchemaFormatDescription = null, bool? jsonSchemaIsStrict = null); public static ResponseTextFormat CreateTextFormat(); public static explicit operator ResponseTextFormat(ClientResult result); public static implicit operator BinaryContent(ResponseTextFormat responseTextFormat); } + public enum ResponseTextFormatKind { + Unknown = 0, + Text = 1, + JsonObject = 2, + JsonSchema = 3 + } public class ResponseTextOptions : IJsonModel, IPersistableModel { - public ResponseTextFormat ResponseFormat { get; set; } + public ResponseTextFormat TextFormat { get; set; } public static explicit operator ResponseTextOptions(ClientResult result); public static implicit operator BinaryContent(ResponseTextOptions responseTextOptions); } @@ -3183,6 +3192,27 @@ public class ResponseTool : IJsonModel, IPersistableModel, IPersistableModel { + public string FunctionName { get; } + public ResponseToolChoiceKind Kind { get; } + public static ResponseToolChoice CreateAutoChoice(); + public static ResponseToolChoice CreateComputerChoice(); + public static ResponseToolChoice CreateFileSearchChoice(); + public static ResponseToolChoice CreateFunctionChoice(string functionName); + public static ResponseToolChoice CreateNoneChoice(); + public static ResponseToolChoice CreateRequiredChoice(); + public static ResponseToolChoice CreateWebSearchChoice(); + } + public enum ResponseToolChoiceKind { + Unknown = 0, + Auto = 1, + None = 2, + Required = 3, + Function = 4, + FileSearch = 5, + WebSearch = 6, + Computer = 7 + } public readonly partial struct ResponseTruncationMode : IEquatable { public ResponseTruncationMode(string value); public static ResponseTruncationMode Auto { get; } @@ -3197,13 +3227,31 @@ public class ResponseTool : IJsonModel, IPersistableModel, IPersistableModel { - public int ContentPartIndex { get; } - public string FunctionArguments { get; } + public class StreamingResponseCompletedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseCompletedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseCompletedUpdate streamingResponseCompletedUpdate); + } + public class StreamingResponseContentPartAddedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } public string ItemId { get; } - public int ItemIndex { get; } - public string Refusal { get; } - public string Text { get; } + public int OutputIndex { get; } + public ResponseContentPart Part { get; } + public new static explicit operator StreamingResponseContentPartAddedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseContentPartAddedUpdate streamingResponseContentPartAddedUpdate); + } + public class StreamingResponseContentPartDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public ResponseContentPart Part { get; } + public new static explicit operator StreamingResponseContentPartDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseContentPartDoneUpdate streamingResponseContentPartDoneUpdate); + } + public class StreamingResponseCreatedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseCreatedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseCreatedUpdate streamingResponseCreatedUpdate); } public class StreamingResponseErrorUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { public string Code { get; } @@ -3212,71 +3260,129 @@ public class StreamingResponseErrorUpdate : StreamingResponseUpdate, IJsonModel< public new static explicit operator StreamingResponseErrorUpdate(ClientResult result); public static implicit operator BinaryContent(StreamingResponseErrorUpdate streamingResponseErrorUpdate); } - public class StreamingResponseFileSearchCallUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { - public string OutputItemId { get; } - public int OutputItemIndex { get; } + public class StreamingResponseFailedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseFailedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFailedUpdate streamingResponseFailedUpdate); } - public class StreamingResponseItemUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { - public ResponseItem Item { get; } - public int ItemIndex { get; } + public class StreamingResponseFileSearchCallCompletedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFileSearchCallCompletedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFileSearchCallCompletedUpdate streamingResponseFileSearchCallCompletedUpdate); + } + public class StreamingResponseFileSearchCallInProgressUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFileSearchCallInProgressUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFileSearchCallInProgressUpdate streamingResponseFileSearchCallInProgressUpdate); + } + public class StreamingResponseFileSearchCallSearchingUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFileSearchCallSearchingUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFileSearchCallSearchingUpdate streamingResponseFileSearchCallSearchingUpdate); + } + public class StreamingResponseFunctionCallArgumentsDeltaUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string Delta { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFunctionCallArgumentsDeltaUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFunctionCallArgumentsDeltaUpdate streamingResponseFunctionCallArgumentsDeltaUpdate); + } + public class StreamingResponseFunctionCallArgumentsDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string Arguments { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseFunctionCallArgumentsDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseFunctionCallArgumentsDoneUpdate streamingResponseFunctionCallArgumentsDoneUpdate); + } + public class StreamingResponseIncompleteUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseIncompleteUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseIncompleteUpdate streamingResponseIncompleteUpdate); } - public class StreamingResponseStatusUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public class StreamingResponseInProgressUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { public OpenAIResponse Response { get; } + public new static explicit operator StreamingResponseInProgressUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseInProgressUpdate streamingResponseInProgressUpdate); + } + public class StreamingResponseOutputItemAddedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public ResponseItem Item { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseOutputItemAddedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputItemAddedUpdate streamingResponseOutputItemAddedUpdate); + } + public class StreamingResponseOutputItemDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public ResponseItem Item { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseOutputItemDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputItemDoneUpdate streamingResponseOutputItemDoneUpdate); + } + public class StreamingResponseOutputTextDeltaUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string Delta { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseOutputTextDeltaUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputTextDeltaUpdate streamingResponseOutputTextDeltaUpdate); + } + public class StreamingResponseOutputTextDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public string Text { get; } + public new static explicit operator StreamingResponseOutputTextDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseOutputTextDoneUpdate streamingResponseOutputTextDoneUpdate); + } + public class StreamingResponseRefusalDeltaUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string Delta { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseRefusalDeltaUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseRefusalDeltaUpdate streamingResponseRefusalDeltaUpdate); } - public class StreamingResponseTextAnnotationUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public class StreamingResponseRefusalDoneUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public int ContentIndex { get; } + public string ItemId { get; } + public int OutputIndex { get; } + public string Refusal { get; } + public new static explicit operator StreamingResponseRefusalDoneUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseRefusalDoneUpdate streamingResponseRefusalDoneUpdate); + } + public class StreamingResponseTextAnnotationAddedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { public ResponseMessageAnnotation Annotation { get; } public int ContentIndex { get; } public string ItemId { get; } public int OutputIndex { get; } - public new static explicit operator StreamingResponseTextAnnotationUpdate(ClientResult result); - public static implicit operator BinaryContent(StreamingResponseTextAnnotationUpdate streamingResponseTextAnnotationUpdate); + public new static explicit operator StreamingResponseTextAnnotationAddedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseTextAnnotationAddedUpdate streamingResponseTextAnnotationAddedUpdate); } public class StreamingResponseUpdate : IJsonModel, IPersistableModel { - public StreamingResponseUpdateKind Kind { get; } public static explicit operator StreamingResponseUpdate(ClientResult result); public static implicit operator BinaryContent(StreamingResponseUpdate streamingResponseUpdate); } - public readonly partial struct StreamingResponseUpdateKind : IEquatable { - public StreamingResponseUpdateKind(string value); - public static StreamingResponseUpdateKind Error { get; } - public static StreamingResponseUpdateKind ResponseCompleted { get; } - public static StreamingResponseUpdateKind ResponseContentPartAdded { get; } - public static StreamingResponseUpdateKind ResponseContentPartDone { get; } - public static StreamingResponseUpdateKind ResponseCreated { get; } - public static StreamingResponseUpdateKind ResponseFailed { get; } - public static StreamingResponseUpdateKind ResponseFileSearchCallCompleted { get; } - public static StreamingResponseUpdateKind ResponseFileSearchCallInProgress { get; } - public static StreamingResponseUpdateKind ResponseFileSearchCallSearching { get; } - public static StreamingResponseUpdateKind ResponseFunctionCallArgumentsDelta { get; } - public static StreamingResponseUpdateKind ResponseFunctionCallArgumentsDone { get; } - public static StreamingResponseUpdateKind ResponseIncomplete { get; } - public static StreamingResponseUpdateKind ResponseInProgress { get; } - public static StreamingResponseUpdateKind ResponseOutputItemAdded { get; } - public static StreamingResponseUpdateKind ResponseOutputItemDone { get; } - public static StreamingResponseUpdateKind ResponseOutputTextAnnotationAdded { get; } - public static StreamingResponseUpdateKind ResponseOutputTextDelta { get; } - public static StreamingResponseUpdateKind ResponseOutputTextDone { get; } - public static StreamingResponseUpdateKind ResponseRefusalDelta { get; } - public static StreamingResponseUpdateKind ResponseRefusalDone { get; } - public static StreamingResponseUpdateKind ResponseWebSearchCallCompleted { get; } - public static StreamingResponseUpdateKind ResponseWebSearchCallInProgress { get; } - public static StreamingResponseUpdateKind ResponseWebSearchCallSearching { get; } - public readonly bool Equals(StreamingResponseUpdateKind other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(StreamingResponseUpdateKind left, StreamingResponseUpdateKind right); - public static implicit operator StreamingResponseUpdateKind(string value); - public static bool operator !=(StreamingResponseUpdateKind left, StreamingResponseUpdateKind right); - public override readonly string ToString(); + public class StreamingResponseWebSearchCallCompletedUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseWebSearchCallCompletedUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseWebSearchCallCompletedUpdate streamingResponseWebSearchCallCompletedUpdate); } - public class StreamingResponseWebSearchCallUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { - public string OutputItemId { get; } - public int OutputItemIndex { get; } + public class StreamingResponseWebSearchCallInProgressUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseWebSearchCallInProgressUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseWebSearchCallInProgressUpdate streamingResponseWebSearchCallInProgressUpdate); + } + public class StreamingResponseWebSearchCallSearchingUpdate : StreamingResponseUpdate, IJsonModel, IPersistableModel { + public string ItemId { get; } + public int OutputIndex { get; } + public new static explicit operator StreamingResponseWebSearchCallSearchingUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingResponseWebSearchCallSearchingUpdate streamingResponseWebSearchCallSearchingUpdate); } public class WebSearchCallResponseItem : ResponseItem, IJsonModel, IPersistableModel { - public WebSearchCallResponseItem(string id); + public WebSearchCallResponseItem(); public WebSearchCallStatus Status { get; } public new static explicit operator WebSearchCallResponseItem(ClientResult result); public static implicit operator BinaryContent(WebSearchCallResponseItem webSearchCallResponseItem); diff --git a/examples/Responses/Example01_CuaFlow.cs b/examples/Responses/Example01_CuaFlow.cs deleted file mode 100644 index f3e90da28..000000000 --- a/examples/Responses/Example01_CuaFlow.cs +++ /dev/null @@ -1,45 +0,0 @@ -using NUnit.Framework; -using OpenAI.Responses; -using System; -using System.ClientModel; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace OpenAI.Examples; - -#pragma warning disable OPENAICUA001 - -public partial class ResponsesExamples -{ - [Test] - public async Task Example01_CuaFlow() - { - OpenAIResponseClient client = new( - model: "computer-use-preview", - credential: new ApiKeyCredential(Environment.GetEnvironmentVariable("OPENAI_API_KEY"))); - - OpenAIResponse response = await client.CreateResponseAsync( - [ResponseItem.CreateUserMessageItem("Click on the OK button")], - new ResponseCreationOptions() - { - Tools = { ResponseTool.CreateComputerTool(1024, 768, ComputerToolEnvironment.Windows) }, - }); - - if (response.OutputItems.FirstOrDefault() is ComputerCallResponseItem computerCall) - { - if (computerCall.Action.Kind == ComputerCallActionKind.Screenshot) - { - Uri screenshotLink = new("https://uxmovement.com/wp-content/uploads/2011/05/left-to-right-mapping.png"); - - response = await client.CreateResponseAsync( - [ResponseItem.CreateComputerCallOutputItem(computerCall.Id, [], screenshotLink)]); - } - else if (computerCall.Action.Kind == ComputerCallActionKind.Click) - { - Console.WriteLine($"Instruction from model: click"); - } - } - } -} diff --git a/examples/Responses/Example01_HelloWorld.cs b/examples/Responses/Example01_HelloWorld.cs new file mode 100644 index 000000000..2129d9c2a --- /dev/null +++ b/examples/Responses/Example01_HelloWorld.cs @@ -0,0 +1,18 @@ +using NUnit.Framework; +using OpenAI.Responses; +using System; + +namespace OpenAI.Examples; + +public partial class ResponseExamples +{ + [Test] + public void Example01_HelloWorld() + { + OpenAIResponseClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); + + OpenAIResponse response = client.CreateResponse("Say 'this is a test.'"); + + Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}"); + } +} diff --git a/examples/Responses/Example01_HelloWorldAsync.cs b/examples/Responses/Example01_HelloWorldAsync.cs new file mode 100644 index 000000000..bdbf538f8 --- /dev/null +++ b/examples/Responses/Example01_HelloWorldAsync.cs @@ -0,0 +1,19 @@ +using NUnit.Framework; +using OpenAI.Responses; +using System; +using System.Threading.Tasks; + +namespace OpenAI.Examples; + +public partial class ResponseExamples +{ + [Test] + public async Task Example01_HelloWorldAsync() + { + OpenAIResponseClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); + + OpenAIResponse response = await client.CreateResponseAsync("Say 'this is a test.'"); + + Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}"); + } +} diff --git a/examples/Responses/Example02_HelloWorldStreaming.cs b/examples/Responses/Example02_HelloWorldStreaming.cs new file mode 100644 index 000000000..debbfbbf2 --- /dev/null +++ b/examples/Responses/Example02_HelloWorldStreaming.cs @@ -0,0 +1,34 @@ +using NUnit.Framework; +using OpenAI.Responses; +using System; + +namespace OpenAI.Examples; + +public partial class ResponseExamples +{ + [Test] + public void Example02_HelloWorldStreaming() + { + OpenAIResponseClient client = new( + model: "gpt-4o-mini", + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); + + Console.Write($"Streaming text: "); + + foreach (StreamingResponseUpdate update + in client.CreateResponseStreaming("Hello, world!")) + { + if (update is StreamingResponseOutputTextDeltaUpdate outputTextUpdate) + { + // Streamed text will arrive as it's generated via delta events + Console.Write(outputTextUpdate.Delta); + } + else if (update is StreamingResponseCompletedUpdate responseCompletedUpdate) + { + // Item and response completed events have aggregated text available + Console.WriteLine(); + Console.WriteLine($"Final text: {responseCompletedUpdate.Response.GetOutputText()}"); + } + } + } +} diff --git a/examples/Responses/Example02_HelloWorldStreamingAsync.cs b/examples/Responses/Example02_HelloWorldStreamingAsync.cs new file mode 100644 index 000000000..831d3af17 --- /dev/null +++ b/examples/Responses/Example02_HelloWorldStreamingAsync.cs @@ -0,0 +1,35 @@ +using NUnit.Framework; +using OpenAI.Responses; +using System; +using System.Threading.Tasks; + +namespace OpenAI.Examples; + +public partial class ResponseExamples +{ + [Test] + public async Task Example02_HelloWorldStreamingAsync() + { + OpenAIResponseClient client = new( + model: "gpt-4o-mini", + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); + + Console.Write($"Streaming text: "); + + await foreach (StreamingResponseUpdate update + in client.CreateResponseStreamingAsync("Hello, world!")) + { + if (update is StreamingResponseOutputTextDeltaUpdate outputTextUpdate) + { + // Streamed text will arrive as it's generated via delta events + Console.Write(outputTextUpdate.Delta); + } + else if (update is StreamingResponseCompletedUpdate responseCompletedUpdate) + { + // Item and response completed events have aggregated text available + Console.WriteLine(); + Console.WriteLine($"Final text: {responseCompletedUpdate.Response.GetOutputText()}"); + } + } + } +} diff --git a/src/Custom/Chat/ChatMessageContentPart.Serialization.cs b/src/Custom/Chat/ChatMessageContentPart.Serialization.cs index 20faaf3f5..80357b623 100644 --- a/src/Custom/Chat/ChatMessageContentPart.Serialization.cs +++ b/src/Custom/Chat/ChatMessageContentPart.Serialization.cs @@ -38,6 +38,11 @@ internal static void WriteCoreContentPart(ChatMessageContentPart instance, Utf8J writer.WritePropertyName("input_audio"u8); writer.WriteObjectValue(instance._inputAudio, options); } + else if (instance._kind == ChatMessageContentPartKind.File) + { + writer.WritePropertyName("file"u8); + writer.WriteObjectValue(instance._fileFile, options); + } writer.WriteSerializedAdditionalRawData(instance._additionalBinaryDataProperties, options); writer.WriteEndObject(); } @@ -56,6 +61,7 @@ internal static ChatMessageContentPart DeserializeChatMessageContentPart(JsonEle string refusal = default; InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default; InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default; + InternalChatCompletionRequestMessageContentPartFileFile fileFile = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -86,12 +92,18 @@ internal static ChatMessageContentPart DeserializeChatMessageContentPart(JsonEle .DeserializeInternalChatCompletionRequestMessageContentPartAudioInputAudio(property.Value, options); continue; } + if (property.NameEquals("file"u8)) + { + fileFile = InternalChatCompletionRequestMessageContentPartFileFile + .DeserializeInternalChatCompletionRequestMessageContentPartFileFile(property.Value, options); + continue; + } if (true) { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new ChatMessageContentPart(kind, text, imageUri, refusal, inputAudio, serializedAdditionalRawData); + return new ChatMessageContentPart(kind, text, imageUri, refusal, inputAudio, fileFile, serializedAdditionalRawData); } } diff --git a/src/Custom/Chat/ChatMessageContentPart.cs b/src/Custom/Chat/ChatMessageContentPart.cs index e4b009215..d243f56ed 100644 --- a/src/Custom/Chat/ChatMessageContentPart.cs +++ b/src/Custom/Chat/ChatMessageContentPart.cs @@ -33,6 +33,7 @@ public partial class ChatMessageContentPart private readonly string _text; private readonly InternalChatCompletionRequestMessageContentPartImageImageUrl _imageUri; private readonly InternalChatCompletionRequestMessageContentPartAudioInputAudio _inputAudio; + private readonly InternalChatCompletionRequestMessageContentPartFileFile _fileFile; private readonly string _refusal; // CUSTOM: Made internal. @@ -47,6 +48,7 @@ internal ChatMessageContentPart( InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default, + InternalChatCompletionRequestMessageContentPartFileFile fileFile = default, IDictionary serializedAdditionalRawData = default) { _kind = kind; @@ -54,6 +56,7 @@ internal ChatMessageContentPart( _imageUri = imageUri; _refusal = refusal; _inputAudio = inputAudio; + _fileFile = fileFile; _additionalBinaryDataProperties = serializedAdditionalRawData; } @@ -98,6 +101,26 @@ internal ChatMessageContentPart( /// public ChatInputAudioFormat? InputAudioFormat => _inputAudio?.Format; + // CUSTOM: Spread. + /// The ID of the previously uploaded file that the content part represents. + /// Present when is and the content part refers to a previously uploaded file. + public string FileId => _fileFile?.FileId; + + // CUSTOM: Spread. + /// The binary file content of the file content part. + /// Present when is and the content refers to data for a new file. + public BinaryData FileBytes => _fileFile?.FileBytes; + + // CUSTOM: Spread. + /// The MIME type of the file, e.g., application/pdf. + /// Present when is and the content refers to data for a new file. + public string FileBytesMediaType => _fileFile?.FileBytesMediaType; + + // CUSTOM: Spread. + /// The filename for the new file content creation that the content part encapsulates. + /// Present when is and the content refers to data for a new file. + public string Filename => _fileFile?.Filename; + // CUSTOM: Spread. /// /// The level of detail with which the model should process the image and generate its textual understanding of @@ -184,6 +207,40 @@ public static ChatMessageContentPart CreateInputAudioPart(BinaryData inputAudioB inputAudio: new(inputAudioBytes, inputAudioFormat)); } + /// Creates a new that represents a previously uploaded file. + /// is null or empty. + public static ChatMessageContentPart CreateFilePart(string fileId) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + return new ChatMessageContentPart( + kind: ChatMessageContentPartKind.File, + fileFile: new() + { + FileId = fileId, + }); + } + + /// Creates a new that encapsulates new file data to upload. + /// The binary content of the file. + /// The MIME type of the file, e.g., application/pdf. + /// The filename to use for the file that will be created. + /// or is null. + /// or > is an empty string, and was expected to be non-empty. + public static ChatMessageContentPart CreateFilePart(BinaryData fileBytes, string fileBytesMediaType, string filename) + { + Argument.AssertNotNull(fileBytes, nameof(fileBytes)); + Argument.AssertNotNullOrEmpty(fileBytesMediaType, nameof(fileBytesMediaType)); + Argument.AssertNotNullOrEmpty(filename, nameof(filename)); + + return new ChatMessageContentPart( + kind: ChatMessageContentPartKind.File, + fileFile: new(fileBytes, fileBytesMediaType) + { + Filename = filename, + }); + } + /// /// Implicitly instantiates a new from a . As such, /// using a in place of a is equivalent to calling the diff --git a/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs b/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs index eae666c74..5ed2664d3 100644 --- a/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs +++ b/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs @@ -14,6 +14,7 @@ internal static partial class ChatMessageContentPartKindExtensions ChatMessageContentPartKind.Refusal => "refusal", ChatMessageContentPartKind.Image => "image_url", ChatMessageContentPartKind.InputAudio => "input_audio", + ChatMessageContentPartKind.File => "file", _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageContentPartKind value.") }; @@ -23,6 +24,7 @@ public static ChatMessageContentPartKind ToChatMessageContentPartKind(this strin if (StringComparer.OrdinalIgnoreCase.Equals(value, "refusal")) return ChatMessageContentPartKind.Refusal; if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_url")) return ChatMessageContentPartKind.Image; if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_audio")) return ChatMessageContentPartKind.InputAudio; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "file")) return ChatMessageContentPartKind.File; throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageContentPartKind value."); } } diff --git a/src/Custom/Chat/ChatMessageContentPartKind.cs b/src/Custom/Chat/ChatMessageContentPartKind.cs index c371039b4..57c267404 100644 --- a/src/Custom/Chat/ChatMessageContentPartKind.cs +++ b/src/Custom/Chat/ChatMessageContentPartKind.cs @@ -12,4 +12,6 @@ public enum ChatMessageContentPartKind Image, InputAudio, + + File, } \ No newline at end of file diff --git a/src/Custom/Chat/Internal/GeneratorStubs.cs b/src/Custom/Chat/Internal/GeneratorStubs.cs index fd4233785..a54aba1f6 100644 --- a/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -92,7 +92,7 @@ internal readonly partial struct InternalCreateChatCompletionStreamResponseObjec [CodeGenType("CreateChatCompletionStreamResponseServiceTier")] internal readonly partial struct InternalCreateChatCompletionStreamResponseServiceTier { } -[CodeGenType("CreateChatCompletionStreamResponseUsage1")] +[CodeGenType("CreateChatCompletionStreamResponseUsage")] internal partial class InternalCreateChatCompletionStreamResponseUsage { } [CodeGenType("CreateChatCompletionRequestModality")] @@ -122,9 +122,6 @@ internal readonly partial struct InternalChatCompletionResponseMessageAnnotation [CodeGenType("ChatCompletionRequestMessageContentPartFile")] internal partial class InternalChatCompletionRequestMessageContentPartFile { } -[CodeGenType("ChatCompletionRequestMessageContentPartFileFile")] -internal partial class InternalChatCompletionRequestMessageContentPartFileFile { } - [CodeGenType("CreateChatCompletionRequestWebSearchOptionsUserLocation1")] internal partial class InternalCreateChatCompletionRequestWebSearchOptionsUserLocation1 { } diff --git a/src/Custom/Chat/Internal/InternalChatCompletionMessageToolCallFunction.Serialization.cs b/src/Custom/Chat/Internal/InternalChatCompletionMessageToolCallFunction.Serialization.cs index 9c25572e2..2ff9fbd1f 100644 --- a/src/Custom/Chat/Internal/InternalChatCompletionMessageToolCallFunction.Serialization.cs +++ b/src/Custom/Chat/Internal/InternalChatCompletionMessageToolCallFunction.Serialization.cs @@ -13,7 +13,10 @@ internal partial class InternalChatCompletionMessageToolCallFunction : IJsonMode [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SerializeArgumentsValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - writer.WriteStringValue(Arguments.ToString()); + string value = Arguments.ToMemory().IsEmpty + ? string.Empty + : Arguments.ToString(); + writer.WriteStringValue(value); } // CUSTOM: Replaced the call to GetRawText() for a call to GetString() because otherwise the starting and ending diff --git a/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartFileFile.cs b/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartFileFile.cs new file mode 100644 index 000000000..87259c0ab --- /dev/null +++ b/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartFileFile.cs @@ -0,0 +1,32 @@ +using System; +using System.Text.RegularExpressions; + +namespace OpenAI.Chat; + +[CodeGenType("ChatCompletionRequestMessageContentPartFileFile")] +internal partial class InternalChatCompletionRequestMessageContentPartFileFile +{ + private readonly BinaryData _fileBytes; + private readonly string _fileBytesMediaType; + + // CUSTOM: Changed type from Uri to string to be able to support data URIs properly. + /// Either a URL of the image or the base64 encoded image data. + [CodeGenMember("FileData")] + internal string FileData { get; } + + public InternalChatCompletionRequestMessageContentPartFileFile(BinaryData fileBytes, string fileBytesMediaType) + { + Argument.AssertNotNull(fileBytes, nameof(fileBytes)); + Argument.AssertNotNull(fileBytesMediaType, nameof(fileBytesMediaType)); + + _fileBytes = fileBytes; + _fileBytesMediaType = fileBytesMediaType; + + string base64EncodedData = Convert.ToBase64String(_fileBytes.ToArray()); + FileData = $"data:{_fileBytesMediaType};base64,{base64EncodedData}"; + } + + public BinaryData FileBytes => _fileBytes; + + public string FileBytesMediaType => _fileBytesMediaType; +} diff --git a/src/Custom/FineTuning/Internal/GeneratorStubs.cs b/src/Custom/FineTuning/Internal/GeneratorStubs.cs index b04a10520..65e072734 100644 --- a/src/Custom/FineTuning/Internal/GeneratorStubs.cs +++ b/src/Custom/FineTuning/Internal/GeneratorStubs.cs @@ -177,3 +177,7 @@ internal readonly partial struct InternalFineTuneChatCompletionRequestAssistantM [CodeGenType("FineTuneChatCompletionRequestAssistantMessageRole")] internal readonly partial struct InternalFineTuneChatCompletionRequestAssistantMessageRole { } +[CodeGenType("CreateFineTuningCheckpointPermissionRequest")] internal partial class InternalCreateFineTuningCheckpointPermissionRequest { } +[CodeGenType("DeleteFineTuningCheckpointPermissionResponse")] internal partial class InternalDeleteFineTuningCheckpointPermissionResponse { } +[CodeGenType("FineTuningCheckpointPermission")] internal partial class InternalFineTuningCheckpointPermission { } +[CodeGenType("ListFineTuningCheckpointPermissionResponse")] internal partial class InternalListFineTuningCheckpointPermissionResponse { } diff --git a/src/Custom/Responses/Internal/GeneratorStubs.cs b/src/Custom/Responses/Internal/GeneratorStubs.cs index bdfc4b11e..67f0a6699 100644 --- a/src/Custom/Responses/Internal/GeneratorStubs.cs +++ b/src/Custom/Responses/Internal/GeneratorStubs.cs @@ -1,45 +1,65 @@ namespace OpenAI.Responses; +[CodeGenType("ComparisonFilter")] internal partial class InternalComparisonFilter { } +[CodeGenType("ComparisonFilterEquals")] internal partial class InternalComparisonFilterEquals { } +[CodeGenType("ComparisonFilterGreaterThan")] internal partial class InternalComparisonFilterGreaterThan { } +[CodeGenType("ComparisonFilterGreaterThanOrEquals")] internal partial class InternalComparisonFilterGreaterThanOrEquals { } +[CodeGenType("ComparisonFilterLessThan")] internal partial class InternalComparisonFilterLessThan { } +[CodeGenType("ComparisonFilterLessThanOrEquals")] internal partial class InternalComparisonFilterLessThanOrEquals { } +[CodeGenType("ComparisonFilterNotEquals")] internal partial class InternalComparisonFilterNotEquals { } +[CodeGenType("ComparisonFilterType")] internal readonly partial struct InternalComparisonFilterType { } +[CodeGenType("CompoundFilter")] internal partial class InternalCompoundFilter { } +[CodeGenType("CompoundFilterAnd")] internal partial class InternalCompoundFilterAnd { } +[CodeGenType("CompoundFilterOr")] internal partial class InternalCompoundFilterOr { } +[CodeGenType("CompoundFilterType")] internal readonly partial struct InternalCompoundFilterType { } [CodeGenType("CreateResponsesRequestModel")] internal readonly partial struct InternalCreateResponsesRequestModel { } +[CodeGenType("DeleteResponseResponseObject")] internal readonly partial struct InternalDeleteResponseResponseObject { } [CodeGenType("ResponsesComputerCallClickAction")] internal partial class InternalResponsesComputerCallClickAction { } [CodeGenType("ResponsesComputerCallDoubleClickAction")] internal partial class InternalResponsesComputerCallDoubleClickAction { } [CodeGenType("ResponsesComputerCallDragAction")] internal partial class InternalResponsesComputerCallDragAction { } +[CodeGenType("ResponsesComputerCallDragActionPath")] internal partial class InternalResponsesComputerCallDragActionPath { } [CodeGenType("ResponsesComputerCallKeyPressAction")] internal partial class InternalResponsesComputerCallKeyPressAction { } [CodeGenType("ResponsesComputerCallMoveAction")] internal partial class InternalResponsesComputerCallMoveAction { } +[CodeGenType("ResponsesComputerCallOutputItemOutputType")] internal readonly partial struct InternalResponsesComputerCallOutputItemOutputType { } +[CodeGenType("ResponsesComputerCallOutputItemScreenshot")] internal partial class InternalResponsesComputerCallOutputItemScreenshot { } [CodeGenType("ResponsesComputerCallScreenshotAction")] internal partial class InternalResponsesComputerCallScreenshotAction { } [CodeGenType("ResponsesComputerCallScrollAction")] internal partial class InternalResponsesComputerCallScrollAction { } [CodeGenType("ResponsesComputerCallTypeAction")] internal partial class InternalResponsesComputerCallTypeAction { } [CodeGenType("ResponsesComputerCallWaitAction")] internal partial class InternalResponsesComputerCallWaitAction { } [CodeGenType("ResponsesComputerTool")] internal partial class InternalResponsesComputerTool { } +[CodeGenType("ResponsesContentType")] internal readonly partial struct InternalResponsesContentType { } [CodeGenType("ResponsesErrorResponse")] internal partial class InternalResponsesErrorResponse { } [CodeGenType("ResponsesFileSearchTool")] internal partial class InternalResponsesFileSearchTool { } [CodeGenType("ResponsesFunctionTool")] internal partial class InternalResponsesFunctionTool { } [CodeGenType("ResponsesInputItemList")] internal partial class InternalResponsesInputItemList { } [CodeGenType("ResponsesInputItemListObject")] internal readonly partial struct InternalResponsesInputItemListObject { } [CodeGenType("ResponsesItemType")] internal readonly partial struct InternalResponsesItemType { } +[CodeGenType("ResponsesMessageRole")] internal readonly partial struct InternalResponsesMessageRole { } +[CodeGenType("ResponsesReasoningItemSummaryElement")] internal partial class InternalResponsesReasoningItemSummaryElement { } +[CodeGenType("ResponsesReasoningItemSummaryElementSummaryText")] internal partial class InternalResponsesReasoningItemSummaryElementSummaryText { } +[CodeGenType("ResponsesReasoningItemSummaryType")] internal readonly partial struct InternalResponsesReasoningItemSummaryType { } [CodeGenType("ResponsesResponseObject")] internal readonly partial struct InternalCreateResponsesResponseObject { } +[CodeGenType("ResponsesResponseStreamEventType")] internal readonly partial struct InternalResponsesResponseStreamEventType { } +[CodeGenType("ResponsesTextFormatJsonObject")] internal partial class InternalResponsesTextFormatJsonObject { } +[CodeGenType("ResponsesTextFormatJsonSchema")] internal partial class InternalResponsesTextFormatJsonSchema { } +[CodeGenType("ResponsesTextFormatText")] internal partial class InternalResponsesTextFormatText { } +[CodeGenType("ResponsesTextFormatType")] internal readonly partial struct InternalResponsesTextFormatType { } +[CodeGenType("ResponsesToolChoiceObjectComputer")] internal partial class InternalResponsesToolChoiceObjectComputer { } +[CodeGenType("ResponsesToolChoiceObjectFileSearch")] internal partial class InternalResponsesToolChoiceObjectFileSearch { } +[CodeGenType("ResponsesToolChoiceObjectFunction")] internal partial class InternalResponsesToolChoiceObjectFunction { } +[CodeGenType("ResponsesToolChoiceObjectType")] internal readonly partial struct InternalResponsesToolChoiceObjectType { } +[CodeGenType("ResponsesToolChoiceObjectWebSearch")] internal partial class InternalResponsesToolChoiceObjectWebSearch { } [CodeGenType("ResponsesToolType")] internal readonly partial struct InternalResponsesToolType { } +[CodeGenType("ResponsesWebSearchApproximateLocation")] internal partial class InternalResponsesWebSearchApproximateLocation { } [CodeGenType("ResponsesWebSearchTool")] internal partial class InternalResponsesWebSearchTool { } +[CodeGenType("UnknownComparisonFilter")] internal partial class InternalUnknownComparisonFilter { } +[CodeGenType("UnknownCompoundFilter")] internal partial class InternalUnknownCompoundFilter { } [CodeGenType("UnknownResponsesComputerCallItemAction")] internal partial class UnknownResponsesComputerCallItemAction { } [CodeGenType("UnknownResponsesComputerCallOutputItemOutput")] internal partial class UnknownResponsesComputerCallOutputItemOutput { } [CodeGenType("UnknownResponsesItem")] internal partial class InternalUnknownResponsesItem { } [CodeGenType("UnknownResponsesMessage")] internal partial class InternalUnknownResponsesMessage { } -[CodeGenType("ResponsesTextFormatType")] internal readonly partial struct InternalResponsesTextFormatType { } -[CodeGenType("ResponsesToolChoiceOption")] internal readonly partial struct InternalResponsesToolChoiceOption { } -[CodeGenType("ResponsesToolChoiceObjectType")] internal readonly partial struct InternalResponsesToolChoiceObjectType { } -[CodeGenType("ResponsesTextFormatText")] internal partial class InternalResponsesTextFormatText { } -[CodeGenType("ResponsesTextFormatJsonObject")] internal partial class InternalResponsesTextFormatJsonObject { } -[CodeGenType("ResponsesTextFormatJsonSchema")] internal partial class InternalResponsesTextFormatJsonSchema { } -[CodeGenType("ResponsesToolChoiceObject")] internal partial class InternalResponsesToolChoiceObject { } -[CodeGenType("ResponsesToolChoiceObjectFileSearch")] internal partial class InternalResponsesToolChoiceObjectFileSearch { } -[CodeGenType("ResponsesToolChoiceObjectWebSearch")] internal partial class InternalResponsesToolChoiceObjectWebSearch { } -[CodeGenType("ResponsesToolChoiceObjectFunction")] internal partial class InternalResponsesToolChoiceObjectFunction { } -[CodeGenType("ResponsesToolChoiceObjectComputer")] internal partial class InternalResponsesToolChoiceObjectComputer { } -[CodeGenType("ResponsesComputerCallOutputItemOutputType")] internal readonly partial struct InternalResponsesComputerCallOutputItemOutputType { } -[CodeGenType("ResponsesComputerCallDragActionPath")] internal partial class InternalResponsesComputerCallDragActionPath { } -[CodeGenType("ResponsesComputerCallOutputItemScreenshot")] internal partial class InternalResponsesComputerCallOutputItemScreenshot { } -[CodeGenType("DeleteResponseResponseObject")] internal readonly partial struct InternalDeleteResponseResponseObject { } -[CodeGenType("ResponsesWebSearchApproximateLocation")] internal partial class InternalResponsesWebSearchApproximateLocation { } -[CodeGenType("ResponsesReasoningItemSummaryElement")] internal partial class InternalResponsesReasoningItemSummaryElement { } -[CodeGenType("ResponsesReasoningItemSummaryType")] internal readonly partial struct InternalResponsesReasoningItemSummaryType { } -[CodeGenType("ResponsesReasoningItemSummaryElementSummaryText")] internal partial class InternalResponsesReasoningItemSummaryElementSummaryText { } +[CodeGenType("UnknownResponsesOutputTextAnnotation")] internal partial class InternalUnknownResponsesOutputTextAnnotation { } +[CodeGenType("UnknownResponsesReasoningItemSummaryElement")] internal partial class InternalUnknownResponsesReasoningItemSummaryElement { } +[CodeGenType("UnknownResponsesResponseStreamEvent")] internal partial class UnknownResponsesResponseStreamEvent { } +[CodeGenType("UnknownResponsesToolChoiceObject")] internal partial class InternalUnknownResponsesToolChoiceObject { } +[CodeGenType("UnknownResponsesWebSearchLocation")] internal partial class InternalUnknownResponsesWebSearchLocation { } diff --git a/src/Custom/Responses/Internal/InternalUnknownResponsesContent.cs b/src/Custom/Responses/Internal/InternalUnknownResponsesContent.cs new file mode 100644 index 000000000..1e5effa37 --- /dev/null +++ b/src/Custom/Responses/Internal/InternalUnknownResponsesContent.cs @@ -0,0 +1,6 @@ +namespace OpenAI.Responses; + +[CodeGenType("UnknownResponsesContent")] +internal partial class InternalUnknownResponsesContent +{ +} diff --git a/src/Custom/Responses/Items/ComputerCallAction.cs b/src/Custom/Responses/Items/ComputerCallAction.cs index 2ea96b08b..4ca105b01 100644 --- a/src/Custom/Responses/Items/ComputerCallAction.cs +++ b/src/Custom/Responses/Items/ComputerCallAction.cs @@ -1,11 +1,12 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Drawing; -using System.IO; using System.Linq; namespace OpenAI.Responses; [CodeGenType("ResponsesComputerCallItemAction")] +[Experimental("OPENAICUA001")] public partial class ComputerCallAction { // CUSTOM: diff --git a/src/Custom/Responses/Items/ComputerCallActionKind.cs b/src/Custom/Responses/Items/ComputerCallActionKind.cs index 256b057c9..182654ad4 100644 --- a/src/Custom/Responses/Items/ComputerCallActionKind.cs +++ b/src/Custom/Responses/Items/ComputerCallActionKind.cs @@ -1,6 +1,9 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Responses; [CodeGenType("ResponsesComputerCallActionType")] +[Experimental("OPENAICUA001")] public enum ComputerCallActionKind { Click, diff --git a/src/Custom/Responses/Items/ComputerCallActionMouseButton.cs b/src/Custom/Responses/Items/ComputerCallActionMouseButton.cs index f0f62e2e9..8adf14b84 100644 --- a/src/Custom/Responses/Items/ComputerCallActionMouseButton.cs +++ b/src/Custom/Responses/Items/ComputerCallActionMouseButton.cs @@ -1,6 +1,9 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Responses; [CodeGenType("ResponsesComputerCallClickButtonType")] +[Experimental("OPENAICUA001")] public enum ComputerCallActionMouseButton { Left, diff --git a/src/Custom/Responses/Items/ComputerCallOutputResponseItem.cs b/src/Custom/Responses/Items/ComputerCallOutputResponseItem.cs index 7bca786ca..4004eb9b9 100644 --- a/src/Custom/Responses/Items/ComputerCallOutputResponseItem.cs +++ b/src/Custom/Responses/Items/ComputerCallOutputResponseItem.cs @@ -1,6 +1,9 @@ -namespace OpenAI.Responses; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Responses; [CodeGenType("ResponsesComputerCallOutputItem")] +[Experimental("OPENAICUA001")] public partial class ComputerCallOutputResponseItem { } diff --git a/src/Custom/Responses/Items/ComputerCallOutputStatus.cs b/src/Custom/Responses/Items/ComputerCallOutputStatus.cs index 2ddf8715b..ec8817cf8 100644 --- a/src/Custom/Responses/Items/ComputerCallOutputStatus.cs +++ b/src/Custom/Responses/Items/ComputerCallOutputStatus.cs @@ -1,7 +1,10 @@ -namespace OpenAI.Responses; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Responses; // CUSTOM: Renamed. [CodeGenType("ResponsesComputerCallOutputItemStatus")] +[Experimental("OPENAICUA001")] public enum ComputerCallOutputStatus { InProgress, diff --git a/src/Custom/Responses/Items/ComputerCallResponseItem.cs b/src/Custom/Responses/Items/ComputerCallResponseItem.cs index bb60b2109..d6cd5c21b 100644 --- a/src/Custom/Responses/Items/ComputerCallResponseItem.cs +++ b/src/Custom/Responses/Items/ComputerCallResponseItem.cs @@ -1,24 +1,13 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; namespace OpenAI.Responses; // CUSTOM: // - Renamed. -// - Suppressed constructor in favor of custom constructor with required `id` parameter. [CodeGenType("ResponsesComputerCallItem")] -[CodeGenSuppress(nameof(ComputerCallResponseItem), typeof(string), typeof(ComputerCallAction), typeof(IEnumerable))] +[Experimental("OPENAICUA001")] public partial class ComputerCallResponseItem { - public ComputerCallResponseItem(string id, string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks) : base(InternalResponsesItemType.ComputerCall, id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(callId, nameof(callId)); - Argument.AssertNotNull(action, nameof(action)); - Argument.AssertNotNull(pendingSafetyChecks, nameof(pendingSafetyChecks)); - - CallId = callId; - Action = action; - PendingSafetyChecks = pendingSafetyChecks.ToList(); - } } diff --git a/src/Custom/Responses/Items/ComputerCallSafetyCheck.cs b/src/Custom/Responses/Items/ComputerCallSafetyCheck.cs index 69bc886d3..8ba01157c 100644 --- a/src/Custom/Responses/Items/ComputerCallSafetyCheck.cs +++ b/src/Custom/Responses/Items/ComputerCallSafetyCheck.cs @@ -1,6 +1,9 @@ -namespace OpenAI.Responses; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Responses; [CodeGenType("ResponsesComputerCallItemSafetyCheck")] +[Experimental("OPENAICUA001")] public partial class ComputerCallSafetyCheck { } diff --git a/src/Custom/Responses/Items/ComputerCallStatus.cs b/src/Custom/Responses/Items/ComputerCallStatus.cs index 6271fa5de..9f6f47f88 100644 --- a/src/Custom/Responses/Items/ComputerCallStatus.cs +++ b/src/Custom/Responses/Items/ComputerCallStatus.cs @@ -1,7 +1,10 @@ -namespace OpenAI.Responses; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Responses; // CUSTOM: Renamed. [CodeGenType("ResponsesComputerCallItemStatus")] +[Experimental("OPENAICUA001")] public enum ComputerCallStatus { InProgress, diff --git a/src/Custom/Responses/Items/ComputerOutput.cs b/src/Custom/Responses/Items/ComputerOutput.cs index 3d1d43d32..bfee17306 100644 --- a/src/Custom/Responses/Items/ComputerOutput.cs +++ b/src/Custom/Responses/Items/ComputerOutput.cs @@ -1,8 +1,10 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Responses; [CodeGenType("ResponsesComputerCallOutputItemOutput")] +[Experimental("OPENAICUA001")] public partial class ComputerOutput { public static ComputerOutput CreateScreenshotOutput(Uri screenshotImageUri) diff --git a/src/Custom/Responses/Items/FileSearchCallResponseItem.cs b/src/Custom/Responses/Items/FileSearchCallResponseItem.cs index dc2420b69..3ff0b1181 100644 --- a/src/Custom/Responses/Items/FileSearchCallResponseItem.cs +++ b/src/Custom/Responses/Items/FileSearchCallResponseItem.cs @@ -1,21 +1,8 @@ -using System.Collections.Generic; -using System.Linq; - -namespace OpenAI.Responses; +namespace OpenAI.Responses; // CUSTOM: // - Renamed. -// - Suppressed constructor in favor of custom constructor with required `id` parameter. [CodeGenType("ResponsesFileSearchCallItem")] -[CodeGenSuppress(nameof(FileSearchCallResponseItem), typeof(IEnumerable), typeof(IEnumerable))] public partial class FileSearchCallResponseItem { - public FileSearchCallResponseItem(string id, IEnumerable queries, IEnumerable results) : base(InternalResponsesItemType.FileSearchCall, id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(queries, nameof(queries)); - - Queries = queries.ToList(); - Results = results?.ToList(); - } } \ No newline at end of file diff --git a/src/Custom/Responses/Items/FunctionCallResponseItem.Serialization.cs b/src/Custom/Responses/Items/FunctionCallResponseItem.Serialization.cs new file mode 100644 index 000000000..346b9c448 --- /dev/null +++ b/src/Custom/Responses/Items/FunctionCallResponseItem.Serialization.cs @@ -0,0 +1,28 @@ +using System; +using System.ClientModel.Primitives; +using System.Runtime.CompilerServices; +using System.Text.Json; + +namespace OpenAI.Responses; + +public partial class FunctionCallResponseItem : IJsonModel +{ + // CUSTOM: The REST API serializes this as a string. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void SerializeFunctionArgumentsValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string value = FunctionArguments.ToMemory().IsEmpty + ? string.Empty + : FunctionArguments.ToString(); + writer.WriteStringValue(value); + } + + // CUSTOM: Replaced the call to GetRawText() for a call to GetString() because otherwise the starting and ending + // quotes of the string are included in the BinaryData. While this is actually a string in the REST API, we want to + // handle it as JSON binary data instead. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void DeserializeFunctionArgumentsValue(JsonProperty property, ref BinaryData functionArguments, ModelReaderWriterOptions options = null) + { + functionArguments = BinaryData.FromString(property.Value.GetString()); + } +} \ No newline at end of file diff --git a/src/Custom/Responses/Items/FunctionCallResponseItem.cs b/src/Custom/Responses/Items/FunctionCallResponseItem.cs index e0e7fd662..5a5ace3b0 100644 --- a/src/Custom/Responses/Items/FunctionCallResponseItem.cs +++ b/src/Custom/Responses/Items/FunctionCallResponseItem.cs @@ -4,23 +4,11 @@ namespace OpenAI.Responses; // CUSTOM: // - Renamed. -// - Suppressed constructor in favor of custom constructor with required `id` parameter. +// - Customized serialization of the BinaryData-as-string FunctionArguments [CodeGenType("ResponsesFunctionCallItem")] -[CodeGenSuppress(nameof(FunctionCallResponseItem), typeof(string), typeof(string), typeof(BinaryData))] +[CodeGenSerialization(nameof(FunctionArguments), SerializationValueHook = nameof(SerializeFunctionArgumentsValue), DeserializationValueHook = nameof(DeserializeFunctionArgumentsValue))] public partial class FunctionCallResponseItem { - public FunctionCallResponseItem(string id, string callId, string functionName, BinaryData functionArguments) : base(InternalResponsesItemType.FunctionCall, id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(callId, nameof(callId)); - Argument.AssertNotNull(functionName, nameof(functionName)); - Argument.AssertNotNull(functionArguments, nameof(functionArguments)); - - CallId = callId; - FunctionName = functionName; - FunctionArguments = functionArguments; - } - // CUSTOM: Renamed. [CodeGenMember("Name")] public string FunctionName { get; set; } diff --git a/src/Custom/Responses/Items/Internal/InternalResponsesAssistantMessage.cs b/src/Custom/Responses/Items/Internal/InternalResponsesAssistantMessage.cs index a45fe9f88..0d0c72bf7 100644 --- a/src/Custom/Responses/Items/Internal/InternalResponsesAssistantMessage.cs +++ b/src/Custom/Responses/Items/Internal/InternalResponsesAssistantMessage.cs @@ -1,19 +1,11 @@ using System.Collections.Generic; -using System.Linq; namespace OpenAI.Responses; [CodeGenType("ResponsesAssistantMessage")] -[CodeGenSuppress(nameof(InternalResponsesAssistantMessage), typeof(IEnumerable))] internal partial class InternalResponsesAssistantMessage { // CUSTOM: Use generalized content type. [CodeGenMember("Content")] public IList InternalContent { get; } - - public InternalResponsesAssistantMessage(IEnumerable internalContent) : base(MessageRole.Assistant) - { - Argument.AssertNotNull(internalContent, nameof(internalContent)); - InternalContent = internalContent.ToList(); - } } \ No newline at end of file diff --git a/src/Custom/Responses/Items/Internal/InternalResponsesDeveloperMessage.cs b/src/Custom/Responses/Items/Internal/InternalResponsesDeveloperMessage.cs index 0f54a5b28..48a76b004 100644 --- a/src/Custom/Responses/Items/Internal/InternalResponsesDeveloperMessage.cs +++ b/src/Custom/Responses/Items/Internal/InternalResponsesDeveloperMessage.cs @@ -1,19 +1,11 @@ using System.Collections.Generic; -using System.Linq; namespace OpenAI.Responses; [CodeGenType("ResponsesDeveloperMessage")] -[CodeGenSuppress(nameof(InternalResponsesDeveloperMessage), typeof(IEnumerable))] internal partial class InternalResponsesDeveloperMessage { // CUSTOM: Use generalized content type. [CodeGenMember("Content")] public IList InternalContent { get; } - - public InternalResponsesDeveloperMessage(IEnumerable internalContent) : base(MessageRole.Developer) - { - Argument.AssertNotNull(internalContent, nameof(internalContent)); - InternalContent = internalContent.ToList(); - } } \ No newline at end of file diff --git a/src/Custom/Responses/Items/Internal/InternalResponsesSystemMessage.cs b/src/Custom/Responses/Items/Internal/InternalResponsesSystemMessage.cs index ae3eba5cb..0fcf06844 100644 --- a/src/Custom/Responses/Items/Internal/InternalResponsesSystemMessage.cs +++ b/src/Custom/Responses/Items/Internal/InternalResponsesSystemMessage.cs @@ -1,19 +1,11 @@ using System.Collections.Generic; -using System.Linq; namespace OpenAI.Responses; [CodeGenType("ResponsesSystemMessage")] -[CodeGenSuppress(nameof(InternalResponsesSystemMessage), typeof(IEnumerable))] internal partial class InternalResponsesSystemMessage { // CUSTOM: Use generalized content type. [CodeGenMember("Content")] public IList InternalContent { get; } - - public InternalResponsesSystemMessage(IEnumerable internalContent) : base(MessageRole.System) - { - Argument.AssertNotNull(internalContent, nameof(internalContent)); - InternalContent = internalContent.ToList(); - } } \ No newline at end of file diff --git a/src/Custom/Responses/Items/Internal/InternalResponsesUserMessage.cs b/src/Custom/Responses/Items/Internal/InternalResponsesUserMessage.cs index f3e2a4516..2d56c009f 100644 --- a/src/Custom/Responses/Items/Internal/InternalResponsesUserMessage.cs +++ b/src/Custom/Responses/Items/Internal/InternalResponsesUserMessage.cs @@ -1,20 +1,11 @@ using System.Collections.Generic; -using System.Linq; namespace OpenAI.Responses; [CodeGenType("ResponsesUserMessage")] -[CodeGenSuppress(nameof(InternalResponsesUserMessage), typeof(IEnumerable))] internal partial class InternalResponsesUserMessage { // CUSTOM: Use generalized content type. [CodeGenMember("Content")] public IList InternalContent { get; } - - public InternalResponsesUserMessage(IEnumerable internalContent) : base(MessageRole.User) - { - Argument.AssertNotNull(internalContent, nameof(internalContent)); - InternalContent = internalContent.ToList(); - } - } \ No newline at end of file diff --git a/src/Custom/Responses/Items/MessageResponseItem.cs b/src/Custom/Responses/Items/MessageResponseItem.cs index 62c4e9a6b..dc12560e4 100644 --- a/src/Custom/Responses/Items/MessageResponseItem.cs +++ b/src/Custom/Responses/Items/MessageResponseItem.cs @@ -1,18 +1,35 @@ using System.Collections.Generic; +using System.Text; namespace OpenAI.Responses; [CodeGenType("ResponsesMessage")] -[CodeGenSuppress("ResponsesMessage", typeof(MessageRole))] +[CodeGenSuppress(nameof(MessageResponseItem), typeof(InternalResponsesMessageRole))] public partial class MessageResponseItem { - // CUSTOM: Made public. + // CUSTOM: Expose public enum type with 'Unknown' using internal extensible role. [CodeGenMember("Role")] - public MessageRole Role { get; } + internal InternalResponsesMessageRole InternalRole { get; set; } + public MessageRole Role + { + get => InternalRole.ToString().ToMessageRole(); + private set => InternalRole = value.ToSerialString(); + } // CUSTOM: Recombined content from derived types. public IList Content => (this as InternalResponsesUserMessage)?.InternalContent ?? (this as InternalResponsesDeveloperMessage)?.InternalContent ?? (this as InternalResponsesSystemMessage)?.InternalContent - ?? (this as InternalResponsesAssistantMessage)?.InternalContent; + ?? (this as InternalResponsesAssistantMessage)?.InternalContent + ?? []; + + internal MessageResponseItem(MessageRole role) : base(InternalResponsesItemType.Message) + { + Role = role; + } + + internal MessageResponseItem(InternalResponsesMessageRole internalRole) : base(InternalResponsesItemType.Message) + { + InternalRole = internalRole; + } } diff --git a/src/Custom/Responses/Items/MessageRole.Serialization.cs b/src/Custom/Responses/Items/MessageRole.Serialization.cs new file mode 100644 index 000000000..e18816cc0 --- /dev/null +++ b/src/Custom/Responses/Items/MessageRole.Serialization.cs @@ -0,0 +1,36 @@ +using System; + +namespace OpenAI.Responses; + +internal static partial class MessageRoleExtensions +{ + public static string ToSerialString(this MessageRole value) => value switch + { + MessageRole.Assistant => InternalResponsesMessageRole.Assistant.ToString(), + MessageRole.Developer => InternalResponsesMessageRole.Developer.ToString(), + MessageRole.System => InternalResponsesMessageRole.System.ToString(), + MessageRole.User => InternalResponsesMessageRole.User.ToString(), + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MessageRole value."), + }; + + public static MessageRole ToMessageRole(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesMessageRole.Assistant.ToString())) + { + return MessageRole.Assistant; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesMessageRole.Developer.ToString())) + { + return MessageRole.Developer; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesMessageRole.System.ToString())) + { + return MessageRole.System; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesMessageRole.User.ToString())) + { + return MessageRole.User; + } + return MessageRole.Unknown; + } +} diff --git a/src/Custom/Responses/Items/MessageRole.cs b/src/Custom/Responses/Items/MessageRole.cs index d23375db0..e468a6911 100644 --- a/src/Custom/Responses/Items/MessageRole.cs +++ b/src/Custom/Responses/Items/MessageRole.cs @@ -1,6 +1,11 @@ namespace OpenAI.Responses; -[CodeGenType("ResponsesMessageRole")] -public readonly partial struct MessageRole +// CUSTOM: Plain enum type, with Unknown, to convert from an underlying extensible enum +public enum MessageRole { -} + Unknown = 0, + Assistant = 1, + Developer = 2, + System = 3, + User = 4, +} \ No newline at end of file diff --git a/src/Custom/Responses/Items/ReasoningResponseItem.cs b/src/Custom/Responses/Items/ReasoningResponseItem.cs index 07921b9b4..cdeb0c696 100644 --- a/src/Custom/Responses/Items/ReasoningResponseItem.cs +++ b/src/Custom/Responses/Items/ReasoningResponseItem.cs @@ -5,14 +5,12 @@ namespace OpenAI.Responses; // CUSTOM: // - Renamed. -// - Suppressed constructor in favor of custom constructor with required `id` parameter. [CodeGenType("ResponsesReasoningItem")] -[CodeGenSuppress(nameof(ReasoningResponseItem), typeof(IEnumerable))] public partial class ReasoningResponseItem { - public ReasoningResponseItem(string id, IEnumerable summaryTextParts) : base(InternalResponsesItemType.Reasoning, id) + // CUSTOM: Convert simple text input into typed wire input + public ReasoningResponseItem(IEnumerable summaryTextParts) : base(InternalResponsesItemType.Reasoning) { - Argument.AssertNotNull(id, nameof(id)); Argument.AssertNotNull(summaryTextParts, nameof(summaryTextParts)); Summary ??= []; diff --git a/src/Custom/Responses/Items/ReferenceResponseItem.cs b/src/Custom/Responses/Items/ReferenceResponseItem.cs index fa891500f..b734697d9 100644 --- a/src/Custom/Responses/Items/ReferenceResponseItem.cs +++ b/src/Custom/Responses/Items/ReferenceResponseItem.cs @@ -2,12 +2,18 @@ // CUSTOM: // - Renamed. -// - Suppressed constructor in favor of custom constructor with required `id` parameter. [CodeGenType("ResponsesItemReferenceItem")] -[CodeGenSuppress(nameof(ReferenceResponseItem))] public partial class ReferenceResponseItem { - public ReferenceResponseItem(string id) : base(InternalResponsesItemType.ItemReference, id) + public ReferenceResponseItem(string id) + : base( + InternalResponsesItemType.ItemReference, + id, + additionalBinaryDataProperties: null) { } + + // CUSTOM: Supply an internal default constructor for serialization and mocking. + internal ReferenceResponseItem() + { } } diff --git a/src/Custom/Responses/Items/ResponseItem.cs b/src/Custom/Responses/Items/ResponseItem.cs index bffac68e3..6a001a8f6 100644 --- a/src/Custom/Responses/Items/ResponseItem.cs +++ b/src/Custom/Responses/Items/ResponseItem.cs @@ -1,93 +1,75 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Text; namespace OpenAI.Responses; [CodeGenType("ResponsesItem")] public partial class ResponseItem { - // CUSTOM: Added custom constructor to be able to set the ID for those items where it is required. - private protected ResponseItem(InternalResponsesItemType @type, string id) + public static MessageResponseItem CreateUserMessageItem(IEnumerable contentParts) { - Type = @type; - Id = id; + Argument.AssertNotNullOrEmpty(contentParts, nameof(contentParts)); + return new InternalResponsesUserMessage(contentParts); } - public static MessageResponseItem CreateUserMessageItem(string content) + public static MessageResponseItem CreateUserMessageItem(string inputTextContent) { - Argument.AssertNotNull(content, nameof(content)); - - return new InternalResponsesSystemMessage( - type: InternalResponsesItemType.Message, - id: null, - additionalBinaryDataProperties: null, - status: null, - MessageRole.User, - internalContent: [ResponseContentPart.CreateInputTextPart(content)]); + Argument.AssertNotNull(inputTextContent, nameof(inputTextContent)); + return new InternalResponsesUserMessage( + internalContent: [ResponseContentPart.CreateInputTextPart(inputTextContent)]); } - public static MessageResponseItem CreateUserMessageItem(IEnumerable contentParts) + public static MessageResponseItem CreateDeveloperMessageItem(IEnumerable contentParts) { - Argument.AssertNotNullOrEmpty(contentParts, nameof(contentParts)); - - return new InternalResponsesSystemMessage( - type: InternalResponsesItemType.Message, - id: null, - additionalBinaryDataProperties: null, - status: null, - MessageRole.User, - internalContent: [.. contentParts]); + Argument.AssertNotNull(contentParts, nameof(contentParts)); + return new InternalResponsesDeveloperMessage(contentParts); } - public static MessageResponseItem CreateDeveloperMessageItem(string content) + public static MessageResponseItem CreateDeveloperMessageItem(string inputTextContent) { - Argument.AssertNotNull(content, nameof(content)); - - return new InternalResponsesSystemMessage( - type: InternalResponsesItemType.Message, - id: null, - additionalBinaryDataProperties: null, - status: null, - MessageRole.Developer, - internalContent: [ResponseContentPart.CreateInputTextPart(content)]); + Argument.AssertNotNull(inputTextContent, nameof(inputTextContent)); + return new InternalResponsesDeveloperMessage( + internalContent: [ResponseContentPart.CreateInputTextPart(inputTextContent)]); } - public static MessageResponseItem CreateSystemMessageItem(string content) + public static MessageResponseItem CreateSystemMessageItem(IEnumerable contentParts) { - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(contentParts, nameof(contentParts)); + return new InternalResponsesSystemMessage(contentParts); + } + public static MessageResponseItem CreateSystemMessageItem(string inputTextContent) + { + Argument.AssertNotNull(inputTextContent, nameof(inputTextContent)); return new InternalResponsesSystemMessage( - type: InternalResponsesItemType.Message, - id: null, - additionalBinaryDataProperties: null, - status: null, - MessageRole.System, - internalContent: [ResponseContentPart.CreateInputTextPart(content)]); + internalContent: [ResponseContentPart.CreateInputTextPart(inputTextContent)]); } - public static MessageResponseItem CreateAssistantMessageItem(string id, string content) + public static MessageResponseItem CreateAssistantMessageItem( + IEnumerable contentParts) { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(content, nameof(content)); - - return new InternalResponsesAssistantMessage( - type: InternalResponsesItemType.Message, - id: id, - additionalBinaryDataProperties: null, - status: null, - MessageRole.Assistant, - internalContent: [ResponseContentPart.CreateInputTextPart(content)]); + Argument.AssertNotNull(contentParts, nameof(contentParts)); + return new InternalResponsesAssistantMessage(contentParts); } - public static FileSearchCallResponseItem CreateFileSearchCallResponseItem(string id, IEnumerable queries, IEnumerable results) + public static MessageResponseItem CreateAssistantMessageItem( + string outputTextContent, + IEnumerable annotations = null) { - return new FileSearchCallResponseItem(id, queries, results); + Argument.AssertNotNull(outputTextContent, nameof(outputTextContent)); + return new InternalResponsesAssistantMessage( + internalContent: + [ + new InternalResponsesOutputTextContentPart(annotations ?? [], outputTextContent), + ]); } - public static ResponseItem CreateComputerCallItem(string id, string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks) + [Experimental("OPENAICUA001")] + public static ResponseItem CreateComputerCallItem(string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks) { - return new ComputerCallResponseItem(id, callId, action, pendingSafetyChecks); + return new ComputerCallResponseItem(callId, action, pendingSafetyChecks); } [Experimental("OPENAICUA001")] @@ -117,14 +99,21 @@ public static ResponseItem CreateComputerCallOutputItem(string callId, IList queries, + IEnumerable results) { - return new WebSearchCallResponseItem(id); + return new FileSearchCallResponseItem(queries, results); } - public static FunctionCallResponseItem CreateFunctionCall(string id, string callId, string functionName, BinaryData functionArguments) + public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments) { - return new FunctionCallResponseItem(id, callId, functionName, functionArguments); + return new FunctionCallResponseItem(callId, functionName, functionArguments); } public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput) @@ -132,9 +121,9 @@ public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string return new FunctionCallOutputResponseItem(callId, functionOutput); } - public static ReasoningResponseItem CreateReasoningItem(string id, IEnumerable summaryTextParts) + public static ReasoningResponseItem CreateReasoningItem(IEnumerable summaryTextParts) { - return new ReasoningResponseItem(id, summaryTextParts); + return new ReasoningResponseItem(summaryTextParts); } public static ReferenceResponseItem CreateReferenceItem(string id) diff --git a/src/Custom/Responses/Items/WebSearchCallResponseItem.cs b/src/Custom/Responses/Items/WebSearchCallResponseItem.cs index f1a53ab76..e2741b2e7 100644 --- a/src/Custom/Responses/Items/WebSearchCallResponseItem.cs +++ b/src/Custom/Responses/Items/WebSearchCallResponseItem.cs @@ -2,13 +2,7 @@ // CUSTOM: // - Renamed. -// - Suppressed constructor in favor of custom constructor with required `id` parameter. [CodeGenType("ResponsesWebSearchCallItem")] -[CodeGenSuppress(nameof(WebSearchCallResponseItem))] public partial class WebSearchCallResponseItem { - public WebSearchCallResponseItem(string id) : base(InternalResponsesItemType.WebSearchCall, id) - { - Argument.AssertNotNull(id, nameof(id)); - } } diff --git a/src/Custom/Responses/OpenAIResponse.cs b/src/Custom/Responses/OpenAIResponse.cs index c55ebc240..49f3dd8e6 100644 --- a/src/Custom/Responses/OpenAIResponse.cs +++ b/src/Custom/Responses/OpenAIResponse.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Linq; +using System.Text; namespace OpenAI.Responses; @@ -40,5 +42,18 @@ public partial class OpenAIResponse // CUSTOM: Renamed. [CodeGenMember("ParallelToolCalls")] - public bool AllowParallelToolCalls { get; } + public bool ParallelToolCallsEnabled { get; } + + // CUSTOM: Using convenience type. + [CodeGenMember("ToolChoice")] + public ResponseToolChoice ToolChoice { get; } + + public string GetOutputText() + { + IEnumerable outputTextSegments = OutputItems.Where(item => item is MessageResponseItem) + .Select(item => item as MessageResponseItem) + .SelectMany(message => message.Content.Where(contentPart => contentPart.Kind == ResponseContentPartKind.OutputText) + .Select(outputTextPart => outputTextPart.Text)); + return outputTextSegments.Any() ? string.Join(string.Empty, outputTextSegments) : null; + } } diff --git a/src/Custom/Responses/OpenAIResponseClient.cs b/src/Custom/Responses/OpenAIResponseClient.cs index 809d749d8..ae2e19589 100644 --- a/src/Custom/Responses/OpenAIResponseClient.cs +++ b/src/Custom/Responses/OpenAIResponseClient.cs @@ -135,7 +135,7 @@ public virtual AsyncCollectionResult CreateResponseStre using BinaryContent content = CreatePerCallOptions(options, inputItems, stream: true); return new AsyncSseUpdateCollection( async () => await CreateResponseAsync(content, cancellationToken.ToRequestOptions(streaming: true)).ConfigureAwait(false), - StreamingResponseUpdate.DeserializeUpdateWithWrappers, + StreamingResponseUpdate.DeserializeStreamingResponseUpdate, cancellationToken); } @@ -146,7 +146,7 @@ public virtual CollectionResult CreateResponseStreaming using BinaryContent content = CreatePerCallOptions(options, inputItems, stream: true); return new SseUpdateCollection( () => CreateResponse(content, cancellationToken.ToRequestOptions(streaming: true)), - StreamingResponseUpdate.DeserializeUpdateWithWrappers, + StreamingResponseUpdate.DeserializeStreamingResponseUpdate, cancellationToken); } @@ -239,9 +239,6 @@ internal virtual ResponseCreationOptions CreatePerCallOptions(ResponseCreationOp : userOptions.GetClone(); copiedOptions.Input = inputItems.ToList(); copiedOptions.Model = _model; - // Note: as of 2025-03-03, some models *require* that "truncation": "auto" is explicitly provided; unless - // otherwise specified, ensure that value is set here. - copiedOptions.TruncationMode ??= ResponseTruncationMode.Auto; if (stream) { copiedOptions.Stream = true; diff --git a/src/Custom/Responses/ResponseContentPart.cs b/src/Custom/Responses/ResponseContentPart.cs index 6d9a8358f..e7189fb6a 100644 --- a/src/Custom/Responses/ResponseContentPart.cs +++ b/src/Custom/Responses/ResponseContentPart.cs @@ -7,8 +7,13 @@ namespace OpenAI.Responses; [CodeGenType("ResponsesContent")] public partial class ResponseContentPart { + public ResponseContentPartKind Kind + { + get => InternalType.ToString().ToResponseContentPartKind(); + private set => InternalType = Kind.ToSerialString(); + } [CodeGenMember("Type")] - public ResponseContentPartKind Kind { get; } + internal InternalResponsesContentType InternalType { get; set; } // CUSTOM: Exposed input text properties. public string Text diff --git a/src/Custom/Responses/ResponseContentPartKind.Serialization.cs b/src/Custom/Responses/ResponseContentPartKind.Serialization.cs new file mode 100644 index 000000000..be1e276a6 --- /dev/null +++ b/src/Custom/Responses/ResponseContentPartKind.Serialization.cs @@ -0,0 +1,41 @@ +using System; + +namespace OpenAI.Responses; + +internal static partial class ResponseContentPartKindExtensions +{ + public static string ToSerialString(this ResponseContentPartKind value) => value switch + { + ResponseContentPartKind.InputText => InternalResponsesContentType.InputText.ToString(), + ResponseContentPartKind.InputImage => InternalResponsesContentType.InputImage.ToString(), + ResponseContentPartKind.InputFile => InternalResponsesContentType.InputFile.ToString(), + ResponseContentPartKind.OutputText => InternalResponsesContentType.OutputText.ToString(), + ResponseContentPartKind.Refusal => InternalResponsesContentType.Refusal.ToString(), + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseContentPartKind value.") + }; + + public static ResponseContentPartKind ToResponseContentPartKind(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesContentType.InputText.ToString())) + { + return ResponseContentPartKind.InputText; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesContentType.InputImage.ToString())) + { + return ResponseContentPartKind.InputImage; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesContentType.InputFile.ToString())) + { + return ResponseContentPartKind.InputFile; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesContentType.OutputText.ToString())) + { + return ResponseContentPartKind.OutputText; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesContentType.Refusal.ToString())) + { + return ResponseContentPartKind.Refusal; + } + return ResponseContentPartKind.Unknown; + } +} diff --git a/src/Custom/Responses/ResponseContentPartKind.cs b/src/Custom/Responses/ResponseContentPartKind.cs index 1135bf00e..fd5e65203 100644 --- a/src/Custom/Responses/ResponseContentPartKind.cs +++ b/src/Custom/Responses/ResponseContentPartKind.cs @@ -1,8 +1,9 @@ namespace OpenAI.Responses; -[CodeGenType("ResponsesContentType")] +// CUSTOM: Plain enum type, with Unknown, to convert from an underlying extensible enum public enum ResponseContentPartKind { + Unknown, InputText, InputImage, InputFile, diff --git a/src/Custom/Responses/ResponseCreationOptions.cs b/src/Custom/Responses/ResponseCreationOptions.cs index 872a71abf..44a95e872 100644 --- a/src/Custom/Responses/ResponseCreationOptions.cs +++ b/src/Custom/Responses/ResponseCreationOptions.cs @@ -24,7 +24,7 @@ public partial class ResponseCreationOptions // - Made internal. This value comes from a parameter on the client method. // - Added setter. [CodeGenMember("Input")] - internal IList Input { get; set; } = new ChangeTrackingList(); + internal IList Input { get; set; } // CUSTOM: Made internal. This value comes from a parameter on the client method. internal bool? Stream { get; set; } @@ -60,12 +60,20 @@ public ResponseCreationOptions() // CUSTOM: Renamed. [CodeGenMember("ParallelToolCalls")] - public bool? AllowParallelToolCalls { get; set; } + public bool? ParallelToolCallsEnabled { get; set; } // CUSTOM: Renamed. [CodeGenMember("Store")] public bool? StoredOutputEnabled { get; set; } + // CUSTOM: Using convenience type. + [CodeGenMember("ToolChoice")] + public ResponseToolChoice ToolChoice { get; set; } + + // CUSTOM: Apply get-only collection pattern + [CodeGenMember("Tools")] + public IList Tools { get; } + internal ResponseCreationOptions GetClone() { ResponseCreationOptions copiedOptions = (ResponseCreationOptions)this.MemberwiseClone(); diff --git a/src/Custom/Responses/ResponseMessageAnnotation.cs b/src/Custom/Responses/ResponseMessageAnnotation.cs index c4c0ef7cc..58c5ef55d 100644 --- a/src/Custom/Responses/ResponseMessageAnnotation.cs +++ b/src/Custom/Responses/ResponseMessageAnnotation.cs @@ -15,7 +15,7 @@ public partial class ResponseMessageAnnotation public int? FileCitationIndex => (this as InternalResponsesMessageAnnotationFileCitation)?.Index; // CUSTOM: Exposed URL citation properties. - public string UriCitationUri => (this as InternalResponsesMessageAnnotationUrlCitation).Url; + public string UriCitationUri => (this as InternalResponsesMessageAnnotationUrlCitation)?.Url; public string UriCitationTitle => (this as InternalResponsesMessageAnnotationUrlCitation)?.Title; public int? UriCitationStartIndex => (this as InternalResponsesMessageAnnotationUrlCitation)?.StartIndex; public int? UriCitationEndIndex => (this as InternalResponsesMessageAnnotationUrlCitation)?.EndIndex; diff --git a/src/Custom/Responses/ResponseTextFormat.cs b/src/Custom/Responses/ResponseTextFormat.cs index 1796428c4..9547140e6 100644 --- a/src/Custom/Responses/ResponseTextFormat.cs +++ b/src/Custom/Responses/ResponseTextFormat.cs @@ -5,6 +5,15 @@ namespace OpenAI.Responses; [CodeGenType("ResponsesTextFormat")] public partial class ResponseTextFormat { + // CUSTOM: Renamed to "Kind" and converted to public enum from internal extensible type. + [CodeGenMember("Type")] + internal InternalResponsesTextFormatType InternalType { get; set; } + public ResponseTextFormatKind Kind + { + get => InternalType.ToString().ToResponseTextFormatKind(); + set => InternalType = value.ToSerialString(); + } + public static ResponseTextFormat CreateTextFormat() => new InternalResponsesTextFormatText(); public static ResponseTextFormat CreateJsonObjectFormat() => new InternalResponsesTextFormatJsonObject(); diff --git a/src/Custom/Responses/ResponseTextFormatKind.Serialization.cs b/src/Custom/Responses/ResponseTextFormatKind.Serialization.cs new file mode 100644 index 000000000..3b0bec8e7 --- /dev/null +++ b/src/Custom/Responses/ResponseTextFormatKind.Serialization.cs @@ -0,0 +1,31 @@ +using System; + +namespace OpenAI.Responses; + +internal static partial class ResponseTextFormatKindExtensions +{ + public static string ToSerialString(this ResponseTextFormatKind value) => value switch + { + ResponseTextFormatKind.Text => InternalResponsesTextFormatType.Text.ToString(), + ResponseTextFormatKind.JsonObject => InternalResponsesTextFormatType.JsonObject.ToString(), + ResponseTextFormatKind.JsonSchema => InternalResponsesTextFormatType.JsonSchema.ToString(), + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseTextFormatKind value."), + }; + + public static ResponseTextFormatKind ToResponseTextFormatKind(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesTextFormatType.Text.ToString())) + { + return ResponseTextFormatKind.Text; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesTextFormatType.JsonObject.ToString())) + { + return ResponseTextFormatKind.JsonObject; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, InternalResponsesTextFormatType.JsonSchema.ToString())) + { + return ResponseTextFormatKind.JsonSchema; + } + return ResponseTextFormatKind.Unknown; + } +} diff --git a/src/Custom/Responses/ResponseTextFormatKind.cs b/src/Custom/Responses/ResponseTextFormatKind.cs new file mode 100644 index 000000000..ea06eabf1 --- /dev/null +++ b/src/Custom/Responses/ResponseTextFormatKind.cs @@ -0,0 +1,10 @@ +namespace OpenAI.Responses; + +// CUSTOM: Plain enum type, with Unknown, to convert from an underlying extensible enum +public enum ResponseTextFormatKind +{ + Unknown = 0, + Text = 1, + JsonObject = 2, + JsonSchema = 3, +} \ No newline at end of file diff --git a/src/Custom/Responses/ResponseTextOptions.cs b/src/Custom/Responses/ResponseTextOptions.cs index 9c203d3d8..540005116 100644 --- a/src/Custom/Responses/ResponseTextOptions.cs +++ b/src/Custom/Responses/ResponseTextOptions.cs @@ -5,5 +5,5 @@ public partial class ResponseTextOptions { // CUSTOM: Renamed. [CodeGenMember("Format")] - public ResponseTextFormat ResponseFormat { get; set; } + public ResponseTextFormat TextFormat { get; set; } } \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/Internal/GeneratorStubs.cs b/src/Custom/Responses/Streaming/Internal/GeneratorStubs.cs deleted file mode 100644 index c60ff1430..000000000 --- a/src/Custom/Responses/Streaming/Internal/GeneratorStubs.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace OpenAI.Responses; - -[CodeGenType("ResponsesResponseStreamEventResponseFileSearchCallInProgress")] internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallInProgress { } -[CodeGenType("ResponsesResponseStreamEventResponseFileSearchCallSearching")] internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallSearching { } -[CodeGenType("ResponsesResponseStreamEventResponseFileSearchCallCompleted")] internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallCompleted { } -[CodeGenType("ResponsesResponseStreamEventResponseFunctionCallArgumentsDelta")] internal partial class InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta { } -[CodeGenType("ResponsesResponseStreamEventResponseFunctionCallArgumentsDone")] internal partial class InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone { } -[CodeGenType("ResponsesResponseStreamEventResponseOutputItemAdded")] internal partial class InternalResponsesResponseStreamEventResponseOutputItemAdded { } -[CodeGenType("ResponsesResponseStreamEventResponseOutputItemDone")] internal partial class InternalResponsesResponseStreamEventResponseOutputItemDone { } -[CodeGenType("ResponsesResponseStreamEventResponseOutputTextDelta")] internal partial class InternalResponsesResponseStreamEventResponseOutputTextDelta { } -[CodeGenType("ResponsesResponseStreamEventResponseOutputTextDone")] internal partial class InternalResponsesResponseStreamEventResponseOutputTextDone { } -[CodeGenType("ResponsesResponseStreamEventResponseRefusalDelta")] internal partial class InternalResponsesResponseStreamEventResponseRefusalDelta { } -[CodeGenType("ResponsesResponseStreamEventResponseRefusalDone")] internal partial class InternalResponsesResponseStreamEventResponseRefusalDone { } -[CodeGenType("UnknownResponsesResponseStreamEvent")] internal partial class UnknownResponsesResponseStreamEvent { } -[CodeGenType("ResponsesResponseStreamEventResponseFailed")] internal partial class InternalResponsesResponseStreamEventResponseFailed { } -[CodeGenType("ResponsesResponseStreamEventResponseIncomplete")] internal partial class InternalResponsesResponseStreamEventResponseIncomplete { } -[CodeGenType("ResponsesResponseStreamEventResponseCompleted")] internal partial class InternalResponsesResponseStreamEventResponseCompleted { } -[CodeGenType("ResponsesResponseStreamEventResponseCreated")] internal partial class InternalResponsesResponseStreamEventResponseCreated { } -[CodeGenType("ResponsesResponseStreamEventResponseInProgress")] internal partial class InternalResponsesResponseStreamEventResponseInProgress { } -[CodeGenType("ResponsesResponseStreamEventResponseWebSearchCallCompleted")] internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallCompleted { } -[CodeGenType("ResponsesResponseStreamEventResponseWebSearchCallInProgress")] internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallInProgress { } -[CodeGenType("ResponsesResponseStreamEventResponseWebSearchCallSearching")] internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallSearching { } diff --git a/src/Custom/Responses/Streaming/StreamingResponseCompletedUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseCompletedUpdate.cs new file mode 100644 index 000000000..99c1f4b22 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseCompletedUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseCompleted")] +public partial class StreamingResponseCompletedUpdate +{ } diff --git a/src/Custom/Responses/Streaming/Internal/InternalResponsesResponseStreamEventResponseContentPartAdded.cs b/src/Custom/Responses/Streaming/StreamingResponseContentPartAddedUpdate.cs similarity index 72% rename from src/Custom/Responses/Streaming/Internal/InternalResponsesResponseStreamEventResponseContentPartAdded.cs rename to src/Custom/Responses/Streaming/StreamingResponseContentPartAddedUpdate.cs index 0430e01b3..014f5931e 100644 --- a/src/Custom/Responses/Streaming/Internal/InternalResponsesResponseStreamEventResponseContentPartAdded.cs +++ b/src/Custom/Responses/Streaming/StreamingResponseContentPartAddedUpdate.cs @@ -1,7 +1,7 @@ namespace OpenAI.Responses; [CodeGenType("ResponsesResponseStreamEventResponseContentPartAdded")] -internal partial class InternalResponsesResponseStreamEventResponseContentPartAdded +public partial class StreamingResponseContentPartAddedUpdate { // CUSTOM: Apply generalized content type. [CodeGenMember("Part")] diff --git a/src/Custom/Responses/Streaming/StreamingResponseContentPartDeltaUpdate.Serialization.cs b/src/Custom/Responses/Streaming/StreamingResponseContentPartDeltaUpdate.Serialization.cs deleted file mode 100644 index 7e24067f7..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseContentPartDeltaUpdate.Serialization.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace OpenAI.Responses; - -public partial class StreamingResponseContentPartDeltaUpdate : IJsonModel -{ - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, SerializeStreamingResponseContentPartDeltaUpdate, writer, options); - - StreamingResponseContentPartDeltaUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponsesItemStreamingPartDeltaUpdate, ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, options); - - StreamingResponseContentPartDeltaUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponsesItemStreamingPartDeltaUpdate, data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - internal static void SerializeStreamingResponseContentPartDeltaUpdate( - StreamingResponseContentPartDeltaUpdate instance, - Utf8JsonWriter writer, - ModelReaderWriterOptions options) - => writer.WriteFirstObject( - options, - instance._contentPartAdded, - instance._outputTextDelta, - instance._functionArgumentsDelta, - instance._refusalDelta); - - internal static StreamingResponseContentPartDeltaUpdate DeserializeResponsesItemStreamingPartDeltaUpdate(JsonElement element, ModelReaderWriterOptions options = null) - => DeserializeUpdateWithWrappers(element, options) as StreamingResponseContentPartDeltaUpdate; -} diff --git a/src/Custom/Responses/Streaming/StreamingResponseContentPartDeltaUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseContentPartDeltaUpdate.cs deleted file mode 100644 index 0676d1451..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseContentPartDeltaUpdate.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Responses; - -/// -/// -/// -/// This type is a shared representation of the following response event types: -/// -/// response.content_part.added -/// response.output_text.delta -/// response.function_call_arguments.delta -/// -/// -public partial class StreamingResponseContentPartDeltaUpdate : StreamingResponseUpdate -{ - public string ItemId - => _contentPartAdded?.ItemId - ?? _outputTextDelta?.ItemId - ?? _functionArgumentsDelta?.ItemId; - - public int ItemIndex - => _contentPartAdded?.OutputIndex - ?? _outputTextDelta?.OutputIndex - ?? _functionArgumentsDelta?.OutputIndex - ?? 0; - - public int ContentPartIndex - => _contentPartAdded?.ContentIndex - ?? _outputTextDelta?.ContentIndex - ?? 0; - - public string Text - => _outputTextDelta?.Delta - ?? _contentPartAdded?.Part?.Text; - - public string FunctionArguments - => _functionArgumentsDelta?.Delta; - - public string Refusal - => _refusalDelta?.Delta; - - private readonly InternalResponsesResponseStreamEventResponseContentPartAdded _contentPartAdded; - private readonly InternalResponsesResponseStreamEventResponseOutputTextDelta _outputTextDelta; - private readonly InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta _functionArgumentsDelta; - private readonly InternalResponsesResponseStreamEventResponseRefusalDelta _refusalDelta; - - internal StreamingResponseContentPartDeltaUpdate(StreamingResponseUpdate baseUpdate) - : base(baseUpdate.Kind) - { - _contentPartAdded = baseUpdate as InternalResponsesResponseStreamEventResponseContentPartAdded; - _outputTextDelta = baseUpdate as InternalResponsesResponseStreamEventResponseOutputTextDelta; - _functionArgumentsDelta = baseUpdate as InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta; - _refusalDelta = baseUpdate as InternalResponsesResponseStreamEventResponseRefusalDelta; - } - - internal StreamingResponseContentPartDeltaUpdate() - { - } -} diff --git a/src/Custom/Responses/Streaming/Internal/InternalResponsesResponseStreamEventResponseContentPartDone.cs b/src/Custom/Responses/Streaming/StreamingResponseContentPartDoneUpdate.cs similarity index 72% rename from src/Custom/Responses/Streaming/Internal/InternalResponsesResponseStreamEventResponseContentPartDone.cs rename to src/Custom/Responses/Streaming/StreamingResponseContentPartDoneUpdate.cs index 93acfccfd..be2fbd8fe 100644 --- a/src/Custom/Responses/Streaming/Internal/InternalResponsesResponseStreamEventResponseContentPartDone.cs +++ b/src/Custom/Responses/Streaming/StreamingResponseContentPartDoneUpdate.cs @@ -1,7 +1,7 @@ namespace OpenAI.Responses; [CodeGenType("ResponsesResponseStreamEventResponseContentPartDone")] -internal partial class InternalResponsesResponseStreamEventResponseContentPartDone +public partial class StreamingResponseContentPartDoneUpdate { // CUSTOM: Apply generalized content type. [CodeGenMember("Part")] diff --git a/src/Custom/Responses/Streaming/StreamingResponseCreatedUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseCreatedUpdate.cs new file mode 100644 index 000000000..712eb8971 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseCreatedUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseCreated")] +public partial class StreamingResponseCreatedUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseErrorUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseErrorUpdate.cs index 59e05d04c..b58d462d9 100644 --- a/src/Custom/Responses/Streaming/StreamingResponseErrorUpdate.cs +++ b/src/Custom/Responses/Streaming/StreamingResponseErrorUpdate.cs @@ -2,5 +2,4 @@ namespace OpenAI.Responses; [CodeGenType("ResponsesResponseStreamEventError")] public partial class StreamingResponseErrorUpdate -{ -} \ No newline at end of file +{ } \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseFailedUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseFailedUpdate.cs new file mode 100644 index 000000000..123c5d289 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseFailedUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseFailed")] +public partial class StreamingResponseFailedUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallCompletedUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallCompletedUpdate.cs new file mode 100644 index 000000000..fb42940d6 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallCompletedUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseFileSearchCallCompleted")] +public partial class StreamingResponseFileSearchCallCompletedUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallInProgressUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallInProgressUpdate.cs new file mode 100644 index 000000000..ee2e4a7e3 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallInProgressUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseFileSearchCallInProgress")] +public partial class StreamingResponseFileSearchCallInProgressUpdate +{ } \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallSearchingUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallSearchingUpdate.cs new file mode 100644 index 000000000..e5f5bd5c3 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallSearchingUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseFileSearchCallSearching")] +public partial class StreamingResponseFileSearchCallSearchingUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallUpdate.Serialization.cs b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallUpdate.Serialization.cs deleted file mode 100644 index eacf9ce70..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallUpdate.Serialization.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace OpenAI.Responses; - -public partial class StreamingResponseFileSearchCallUpdate : IJsonModel -{ - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, SerializeStreamingResponseFileSearchCallUpdate, writer, options); - - StreamingResponseFileSearchCallUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponsesItemStreamingPartDeltaUpdate, ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, options); - - StreamingResponseFileSearchCallUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponsesItemStreamingPartDeltaUpdate, data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - internal static void SerializeStreamingResponseFileSearchCallUpdate( - StreamingResponseFileSearchCallUpdate instance, - Utf8JsonWriter writer, - ModelReaderWriterOptions options) - => writer.WriteFirstObject( - options, - instance._fileSearchCallCompleted, - instance._fileSearchCallInProgress, - instance._fileSearchCallSearching); - - internal static StreamingResponseFileSearchCallUpdate DeserializeResponsesItemStreamingPartDeltaUpdate(JsonElement element, ModelReaderWriterOptions options = null) - => DeserializeUpdateWithWrappers(element, options) as StreamingResponseFileSearchCallUpdate; -} diff --git a/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallUpdate.cs deleted file mode 100644 index df6a46271..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseFileSearchCallUpdate.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace OpenAI.Responses; - -public partial class StreamingResponseFileSearchCallUpdate : StreamingResponseUpdate -{ - public string OutputItemId - => _fileSearchCallCompleted?.ItemId - ?? _fileSearchCallInProgress?.ItemId - ?? _fileSearchCallSearching?.ItemId; - - public int OutputItemIndex - => _fileSearchCallCompleted?.OutputIndex - ?? _fileSearchCallInProgress?.OutputIndex - ?? _fileSearchCallSearching?.OutputIndex - ?? 0; - - private readonly InternalResponsesResponseStreamEventResponseFileSearchCallCompleted _fileSearchCallCompleted; - private readonly InternalResponsesResponseStreamEventResponseFileSearchCallInProgress _fileSearchCallInProgress; - private readonly InternalResponsesResponseStreamEventResponseFileSearchCallSearching _fileSearchCallSearching; - - internal StreamingResponseFileSearchCallUpdate(StreamingResponseUpdate baseUpdate) - : base(baseUpdate.Kind) - { - _fileSearchCallCompleted = baseUpdate as InternalResponsesResponseStreamEventResponseFileSearchCallCompleted; - _fileSearchCallInProgress = baseUpdate as InternalResponsesResponseStreamEventResponseFileSearchCallInProgress; - _fileSearchCallSearching = baseUpdate as InternalResponsesResponseStreamEventResponseFileSearchCallSearching; - } - - internal StreamingResponseFileSearchCallUpdate() - { } -} \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseFunctionCallArgumentsDeltaUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseFunctionCallArgumentsDeltaUpdate.cs new file mode 100644 index 000000000..f04e67b40 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseFunctionCallArgumentsDeltaUpdate.cs @@ -0,0 +1,7 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseFunctionCallArgumentsDelta")] + +public partial class StreamingResponseFunctionCallArgumentsDeltaUpdate : StreamingResponseUpdate +{ +} diff --git a/src/Custom/Responses/Streaming/StreamingResponseFunctionCallArgumentsDoneUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseFunctionCallArgumentsDoneUpdate.cs new file mode 100644 index 000000000..b37337a27 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseFunctionCallArgumentsDoneUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseFunctionCallArgumentsDone")] +public partial class StreamingResponseFunctionCallArgumentsDoneUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseInProgressUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseInProgressUpdate.cs new file mode 100644 index 000000000..51c64bd3b --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseInProgressUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseInProgress")] +public partial class StreamingResponseInProgressUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseIncompleteUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseIncompleteUpdate.cs new file mode 100644 index 000000000..db45641f1 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseIncompleteUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseIncomplete")] +public partial class StreamingResponseIncompleteUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseItemUpdate.Serialization.cs b/src/Custom/Responses/Streaming/StreamingResponseItemUpdate.Serialization.cs deleted file mode 100644 index 42a2d0c26..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseItemUpdate.Serialization.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace OpenAI.Responses; - -public partial class StreamingResponseItemUpdate : IJsonModel -{ - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, SerializeStreamingResponseItemUpdate, writer, options); - - StreamingResponseItemUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeStreamingResponseItemUpdate, ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, options); - - StreamingResponseItemUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeStreamingResponseItemUpdate, data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - internal static void SerializeStreamingResponseItemUpdate( - StreamingResponseItemUpdate instance, - Utf8JsonWriter writer, - ModelReaderWriterOptions options) - => writer.WriteFirstObject( - options, - instance._outputItemAdded, - instance._outputItemDone); - - internal static StreamingResponseItemUpdate DeserializeStreamingResponseItemUpdate( - JsonElement element, - ModelReaderWriterOptions options) - => DeserializeUpdateWithWrappers(element, options) as StreamingResponseItemUpdate; -} diff --git a/src/Custom/Responses/Streaming/StreamingResponseItemUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseItemUpdate.cs deleted file mode 100644 index 7310272c0..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseItemUpdate.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses; - -public partial class StreamingResponseItemUpdate : StreamingResponseUpdate -{ - public ResponseItem Item - => _outputItemAdded?.Item - ?? _outputItemDone?.Item; - - public int ItemIndex - => _outputItemAdded?.OutputIndex - ?? _outputItemDone?.OutputIndex - ?? 0; - - private readonly InternalResponsesResponseStreamEventResponseOutputItemAdded _outputItemAdded; - private readonly InternalResponsesResponseStreamEventResponseOutputItemDone _outputItemDone; - - internal StreamingResponseItemUpdate(StreamingResponseUpdate baseUpdate) - : base(baseUpdate.Kind) - { - _outputItemAdded = baseUpdate as InternalResponsesResponseStreamEventResponseOutputItemAdded; - _outputItemDone = baseUpdate as InternalResponsesResponseStreamEventResponseOutputItemDone; - } - - internal StreamingResponseItemUpdate() - { } -} \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseOutputItemAddedUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseOutputItemAddedUpdate.cs new file mode 100644 index 000000000..2ef241389 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseOutputItemAddedUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; +[CodeGenType("ResponsesResponseStreamEventResponseOutputItemAdded")] + +public partial class StreamingResponseOutputItemAddedUpdate : StreamingResponseUpdate +{ } \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseOutputItemDoneUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseOutputItemDoneUpdate.cs new file mode 100644 index 000000000..dbba411b2 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseOutputItemDoneUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseOutputItemDone")] +public partial class StreamingResponseOutputItemDoneUpdate : StreamingResponseUpdate +{ } \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseOutputTextDeltaUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseOutputTextDeltaUpdate.cs new file mode 100644 index 000000000..c2b2fe268 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseOutputTextDeltaUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseOutputTextDelta")] +public partial class StreamingResponseOutputTextDeltaUpdate : StreamingResponseUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseOutputTextDoneUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseOutputTextDoneUpdate.cs new file mode 100644 index 000000000..f47396d04 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseOutputTextDoneUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseOutputTextDone")] +public partial class StreamingResponseOutputTextDoneUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseRefusalDeltaUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseRefusalDeltaUpdate.cs new file mode 100644 index 000000000..535d4544a --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseRefusalDeltaUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseRefusalDelta")] +public partial class StreamingResponseRefusalDeltaUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseRefusalDoneUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseRefusalDoneUpdate.cs new file mode 100644 index 000000000..cea674497 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseRefusalDoneUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseRefusalDone")] +public partial class StreamingResponseRefusalDoneUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseStatusUpdate.Serialization.cs b/src/Custom/Responses/Streaming/StreamingResponseStatusUpdate.Serialization.cs deleted file mode 100644 index 79499ca80..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseStatusUpdate.Serialization.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace OpenAI.Responses; - -public partial class StreamingResponseStatusUpdate : IJsonModel -{ - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, SerializeStreamingResponseStatusUpdate, writer, options); - - StreamingResponseStatusUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeStreamingResponseStatusUpdate, ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, options); - - StreamingResponseStatusUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeStreamingResponseStatusUpdate, data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - internal static void SerializeStreamingResponseStatusUpdate( - StreamingResponseStatusUpdate instance, - Utf8JsonWriter writer, - ModelReaderWriterOptions options) - => writer.WriteFirstObject( - options, - instance._responseCompleted, - instance._responseIncomplete, - instance._responseInProgress, - instance._responseFailed, - instance._responseCreated); - - internal static StreamingResponseStatusUpdate DeserializeStreamingResponseStatusUpdate( - JsonElement element, - ModelReaderWriterOptions options) - => DeserializeUpdateWithWrappers(element, options) as StreamingResponseStatusUpdate; -} diff --git a/src/Custom/Responses/Streaming/StreamingResponseStatusUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseStatusUpdate.cs deleted file mode 100644 index 75f731bb2..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseStatusUpdate.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace OpenAI.Responses; - -public partial class StreamingResponseStatusUpdate : StreamingResponseUpdate -{ - public OpenAIResponse Response - => _responseCreated?.Response - ?? _responseInProgress?.Response - ?? _responseCompleted?.Response - ?? _responseFailed?.Response - ?? _responseIncomplete?.Response; - - private readonly InternalResponsesResponseStreamEventResponseCreated _responseCreated; - private readonly InternalResponsesResponseStreamEventResponseInProgress _responseInProgress; - private readonly InternalResponsesResponseStreamEventResponseCompleted _responseCompleted; - private readonly InternalResponsesResponseStreamEventResponseFailed _responseFailed; - private readonly InternalResponsesResponseStreamEventResponseIncomplete _responseIncomplete; - - internal StreamingResponseStatusUpdate(StreamingResponseUpdate baseUpdate) - : base(baseUpdate.Kind) - { - _responseCreated = baseUpdate as InternalResponsesResponseStreamEventResponseCreated; - _responseInProgress = baseUpdate as InternalResponsesResponseStreamEventResponseInProgress; - _responseCompleted = baseUpdate as InternalResponsesResponseStreamEventResponseCompleted; - _responseFailed = baseUpdate as InternalResponsesResponseStreamEventResponseFailed; - _responseIncomplete = baseUpdate as InternalResponsesResponseStreamEventResponseIncomplete; - } - - internal StreamingResponseStatusUpdate() - { } -} \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseTextAnnotationUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseTextAnnotationAddedUpdate.cs similarity index 63% rename from src/Custom/Responses/Streaming/StreamingResponseTextAnnotationUpdate.cs rename to src/Custom/Responses/Streaming/StreamingResponseTextAnnotationAddedUpdate.cs index a334e99a8..ee8cedc29 100644 --- a/src/Custom/Responses/Streaming/StreamingResponseTextAnnotationUpdate.cs +++ b/src/Custom/Responses/Streaming/StreamingResponseTextAnnotationAddedUpdate.cs @@ -1,5 +1,5 @@ namespace OpenAI.Responses; [CodeGenType("ResponsesResponseStreamEventResponseOutputTextAnnotationAdded")] -public partial class StreamingResponseTextAnnotationUpdate +public partial class StreamingResponseTextAnnotationAddedUpdate { } \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseUpdate.Serialization.cs b/src/Custom/Responses/Streaming/StreamingResponseUpdate.Serialization.cs deleted file mode 100644 index ede956825..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseUpdate.Serialization.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace OpenAI.Responses; - -public partial class StreamingResponseUpdate -{ - internal static StreamingResponseUpdate DeserializeUpdateWithWrappers(JsonElement element, ModelReaderWriterOptions options) - { - StreamingResponseUpdate directlyDeserializedUpdate - = DeserializeStreamingResponseUpdate(element, options); - return directlyDeserializedUpdate switch - { - InternalResponsesResponseStreamEventResponseContentPartAdded - or InternalResponsesResponseStreamEventResponseOutputTextDelta - or InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta - or InternalResponsesResponseStreamEventResponseRefusalDelta - => new StreamingResponseContentPartDeltaUpdate(directlyDeserializedUpdate), - InternalResponsesResponseStreamEventResponseOutputItemAdded - or InternalResponsesResponseStreamEventResponseOutputItemDone - => new StreamingResponseItemUpdate(directlyDeserializedUpdate), - InternalResponsesResponseStreamEventResponseCreated - or InternalResponsesResponseStreamEventResponseInProgress - or InternalResponsesResponseStreamEventResponseCompleted - or InternalResponsesResponseStreamEventResponseFailed - or InternalResponsesResponseStreamEventResponseIncomplete - => new StreamingResponseStatusUpdate(directlyDeserializedUpdate), - InternalResponsesResponseStreamEventResponseFileSearchCallCompleted - or InternalResponsesResponseStreamEventResponseFileSearchCallInProgress - or InternalResponsesResponseStreamEventResponseFileSearchCallSearching - => new StreamingResponseFileSearchCallUpdate(directlyDeserializedUpdate), - InternalResponsesResponseStreamEventResponseWebSearchCallCompleted - or InternalResponsesResponseStreamEventResponseWebSearchCallInProgress - or InternalResponsesResponseStreamEventResponseWebSearchCallSearching - => new StreamingResponseWebSearchCallUpdate(directlyDeserializedUpdate), - _ => directlyDeserializedUpdate, - }; - } -} \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseUpdate.cs index 08ff93514..123e26dee 100644 --- a/src/Custom/Responses/Streaming/StreamingResponseUpdate.cs +++ b/src/Custom/Responses/Streaming/StreamingResponseUpdate.cs @@ -2,8 +2,4 @@ namespace OpenAI.Responses; [CodeGenType("ResponsesResponseStreamEvent")] public partial class StreamingResponseUpdate -{ - // CUSTOM: Made public and renamed to "Kind." - [CodeGenMember("Type")] - public StreamingResponseUpdateKind Kind { get; } -} \ No newline at end of file +{ } \ No newline at end of file diff --git a/src/Custom/Responses/Streaming/StreamingResponseUpdateKind.cs b/src/Custom/Responses/Streaming/StreamingResponseUpdateKind.cs deleted file mode 100644 index 433ce4575..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseUpdateKind.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace OpenAI.Responses; - -[CodeGenType("ResponsesResponseStreamEventType")] -public readonly partial struct StreamingResponseUpdateKind -{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallCompletedUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallCompletedUpdate.cs new file mode 100644 index 000000000..26ef16140 --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallCompletedUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseWebSearchCallCompleted")] +public partial class StreamingResponseWebSearchCallCompletedUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallInProgressUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallInProgressUpdate.cs new file mode 100644 index 000000000..e2264424b --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallInProgressUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseWebSearchCallInProgress")] +public partial class StreamingResponseWebSearchCallInProgressUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallSearchingUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallSearchingUpdate.cs new file mode 100644 index 000000000..1790f67eb --- /dev/null +++ b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallSearchingUpdate.cs @@ -0,0 +1,5 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesResponseStreamEventResponseWebSearchCallSearching")] +public partial class StreamingResponseWebSearchCallSearchingUpdate +{ } diff --git a/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallUpdate.Serialization.cs b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallUpdate.Serialization.cs deleted file mode 100644 index 29ee834ca..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallUpdate.Serialization.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace OpenAI.Responses; - -public partial class StreamingResponseWebSearchCallUpdate : IJsonModel -{ - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, SerializeStreamingResponseWebSearchCallUpdate, writer, options); - - StreamingResponseWebSearchCallUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponsesItemStreamingPartDeltaUpdate, ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, options); - - StreamingResponseWebSearchCallUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponsesItemStreamingPartDeltaUpdate, data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - internal static void SerializeStreamingResponseWebSearchCallUpdate( - StreamingResponseWebSearchCallUpdate instance, - Utf8JsonWriter writer, - ModelReaderWriterOptions options) - => writer.WriteFirstObject( - options, - instance._webSearchCallCompleted, - instance._webSearchCallInProgress, - instance._webSearchCallSearching); - - internal static StreamingResponseWebSearchCallUpdate DeserializeResponsesItemStreamingPartDeltaUpdate(JsonElement element, ModelReaderWriterOptions options = null) - => DeserializeUpdateWithWrappers(element, options) as StreamingResponseWebSearchCallUpdate; -} diff --git a/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallUpdate.cs b/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallUpdate.cs deleted file mode 100644 index 34b68d5b5..000000000 --- a/src/Custom/Responses/Streaming/StreamingResponseWebSearchCallUpdate.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace OpenAI.Responses; - -public partial class StreamingResponseWebSearchCallUpdate : StreamingResponseUpdate -{ - public string OutputItemId - => _webSearchCallCompleted?.ItemId - ?? _webSearchCallInProgress?.ItemId - ?? _webSearchCallSearching?.ItemId; - - public int OutputItemIndex - => _webSearchCallCompleted?.OutputIndex - ?? _webSearchCallInProgress?.OutputIndex - ?? _webSearchCallSearching?.OutputIndex - ?? 0; - - private readonly InternalResponsesResponseStreamEventResponseWebSearchCallCompleted _webSearchCallCompleted; - private readonly InternalResponsesResponseStreamEventResponseWebSearchCallInProgress _webSearchCallInProgress; - private readonly InternalResponsesResponseStreamEventResponseWebSearchCallSearching _webSearchCallSearching; - - internal StreamingResponseWebSearchCallUpdate(StreamingResponseUpdate baseUpdate) - : base(baseUpdate.Kind) - { - _webSearchCallCompleted = baseUpdate as InternalResponsesResponseStreamEventResponseWebSearchCallCompleted; - _webSearchCallInProgress = baseUpdate as InternalResponsesResponseStreamEventResponseWebSearchCallInProgress; - _webSearchCallSearching = baseUpdate as InternalResponsesResponseStreamEventResponseWebSearchCallSearching; - } - - internal StreamingResponseWebSearchCallUpdate() - { } -} \ No newline at end of file diff --git a/src/Custom/Responses/Tools/ComputerToolEnvironment.cs b/src/Custom/Responses/Tools/ComputerToolEnvironment.cs index 31c220a07..4724a8e5f 100644 --- a/src/Custom/Responses/Tools/ComputerToolEnvironment.cs +++ b/src/Custom/Responses/Tools/ComputerToolEnvironment.cs @@ -1,6 +1,9 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Responses; [CodeGenType("ResponsesComputerToolEnvironment")] +[Experimental("OPENAICUA001")] public readonly partial struct ComputerToolEnvironment { } diff --git a/src/Custom/Responses/Tools/Internal/InternalResponsesToolChoiceObject.cs b/src/Custom/Responses/Tools/Internal/InternalResponsesToolChoiceObject.cs new file mode 100644 index 000000000..5c70b7b66 --- /dev/null +++ b/src/Custom/Responses/Tools/Internal/InternalResponsesToolChoiceObject.cs @@ -0,0 +1,15 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesToolChoiceObject")] +internal partial class InternalResponsesToolChoiceObject +{ + public ResponseToolChoiceKind Kind => this switch + { + InternalResponsesToolChoiceObjectComputer => ResponseToolChoiceKind.Computer, + InternalResponsesToolChoiceObjectFileSearch => ResponseToolChoiceKind.FileSearch, + InternalResponsesToolChoiceObjectFunction => ResponseToolChoiceKind.Function, + InternalResponsesToolChoiceObjectWebSearch => ResponseToolChoiceKind.WebSearch, + _ => ResponseToolChoiceKind.Unknown, + }; +} + diff --git a/src/Custom/Responses/Tools/Internal/InternalResponsesToolChoiceOption.cs b/src/Custom/Responses/Tools/Internal/InternalResponsesToolChoiceOption.cs new file mode 100644 index 000000000..9dc6f7beb --- /dev/null +++ b/src/Custom/Responses/Tools/Internal/InternalResponsesToolChoiceOption.cs @@ -0,0 +1,13 @@ +namespace OpenAI.Responses; + +[CodeGenType("ResponsesToolChoiceOption")] +internal readonly partial struct InternalResponsesToolChoiceOption +{ + public ResponseToolChoiceKind Kind => _value switch + { + AutoValue => ResponseToolChoiceKind.Auto, + NoneValue => ResponseToolChoiceKind.None, + RequiredValue => ResponseToolChoiceKind.Required, + _ => ResponseToolChoiceKind.Unknown, + }; +} diff --git a/src/Custom/Responses/Tools/ResponseToolChoice.Serialization.cs b/src/Custom/Responses/Tools/ResponseToolChoice.Serialization.cs new file mode 100644 index 000000000..a233ae4ef --- /dev/null +++ b/src/Custom/Responses/Tools/ResponseToolChoice.Serialization.cs @@ -0,0 +1,58 @@ + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace OpenAI.Responses; + +public partial class ResponseToolChoice : IJsonModel +{ + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + => CustomSerializationHelpers.SerializeInstance(this, SerializeResponseToolChoice, writer, options); + + ResponseToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponseToolChoice, ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + => CustomSerializationHelpers.SerializeInstance(this, options); + + ResponseToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeResponseToolChoice, data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static void SerializeResponseToolChoice( + ResponseToolChoice instance, + Utf8JsonWriter writer, + ModelReaderWriterOptions options) + { + if (instance._toolChoiceOption is not null) + { + writer.WriteStringValue(instance._toolChoiceOption.ToString()); + } + else if (instance._toolChoiceObject is not null) + { + writer.WriteObjectValue(instance._toolChoiceObject, options); + } + } + + internal static ResponseToolChoice DeserializeResponseToolChoice( + JsonElement element, + ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.String) + { + return new ResponseToolChoice( + new InternalResponsesToolChoiceOption(element.GetString())); + } + else if (element.ValueKind == JsonValueKind.Object) + { + return new ResponseToolChoice( + InternalResponsesToolChoiceObject + .DeserializeInternalResponsesToolChoiceObject( + element, + options)); + } + return null; + } +} diff --git a/src/Custom/Responses/Tools/ResponseToolChoice.cs b/src/Custom/Responses/Tools/ResponseToolChoice.cs index 6541382dd..f4263264e 100644 --- a/src/Custom/Responses/Tools/ResponseToolChoice.cs +++ b/src/Custom/Responses/Tools/ResponseToolChoice.cs @@ -1,27 +1,59 @@ -//namespace OpenAI.Responses; +using OpenAI.Assistants; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; -//public partial class ResponseToolChoice -//{ -// //internal BinaryData AsBinaryData { get; set; } +namespace OpenAI.Responses; -// //public static ResponsesToolChoice CreateAutoToolChoice() -// // => new(ModelReaderWriter.Write(InternalResponsesToolChoiceEnum.Auto)); +public partial class ResponseToolChoice +{ + public ResponseToolChoiceKind Kind + => _toolChoiceObject?.Kind + ?? _toolChoiceOption?.Kind + ?? ResponseToolChoiceKind.Unknown; -// //public static ResponsesToolChoice CreateNoneToolChoice() -// // => new(ModelReaderWriter.Write(InternalResponsesToolChoiceEnum.None)); + public string FunctionName + => (_toolChoiceObject as InternalResponsesToolChoiceObjectFunction)?.Name; -// //public static ResponsesToolChoice CreateRequiredToolChoice() -// // => new(ModelReaderWriter.Write(InternalResponsesToolChoiceEnum.Required)); + private readonly InternalResponsesToolChoiceObject _toolChoiceObject; + private readonly InternalResponsesToolChoiceOption? _toolChoiceOption; -// //public static ResponsesToolChoice CreateFunctionToolChoice(string functionName) -// // => new( -// // ModelReaderWriter.Write( -// // new InternalResponsesFunctionToolChoice( -// // new InternalResponsesFunctionToolChoiceFunction(functionName)))); + public static ResponseToolChoice CreateFunctionChoice(string functionName) + => new(new InternalResponsesToolChoiceObjectFunction(functionName)); -// //internal ResponsesToolChoice(BinaryData binaryDataToolChoice) -// //{ -// // AsBinaryData = binaryDataToolChoice; -// //} -//} + public static ResponseToolChoice CreateFileSearchChoice() + => new(new InternalResponsesToolChoiceObjectFileSearch()); + + public static ResponseToolChoice CreateWebSearchChoice() + => new(new InternalResponsesToolChoiceObjectWebSearch()); + + [Experimental("OPENAICUA001")] + public static ResponseToolChoice CreateComputerChoice() + => new(new InternalResponsesToolChoiceObjectComputer()); + + public static ResponseToolChoice CreateAutoChoice() + => new(InternalResponsesToolChoiceOption.Auto); + + public static ResponseToolChoice CreateNoneChoice() + => new(InternalResponsesToolChoiceOption.None); + + public static ResponseToolChoice CreateRequiredChoice() + => new(InternalResponsesToolChoiceOption.Required); + + internal ResponseToolChoice(InternalResponsesToolChoiceObject toolChoiceObject) + { + _toolChoiceObject = toolChoiceObject; + } + + internal ResponseToolChoice(InternalResponsesToolChoiceOption toolChoiceOption) + { + _toolChoiceOption = toolChoiceOption; + } + + // CUSTOM: Supply an internal default constructor for serialization and mocking. + internal ResponseToolChoice() + { } + +} diff --git a/src/Custom/Responses/Tools/ResponseToolChoiceKind.cs b/src/Custom/Responses/Tools/ResponseToolChoiceKind.cs new file mode 100644 index 000000000..9ee173be9 --- /dev/null +++ b/src/Custom/Responses/Tools/ResponseToolChoiceKind.cs @@ -0,0 +1,13 @@ +namespace OpenAI.Responses; + +public enum ResponseToolChoiceKind +{ + Unknown = 0, + Auto = 1, + None = 2, + Required = 3, + Function = 4, + FileSearch = 5, + WebSearch = 6, + Computer = 7, +} diff --git a/src/Generated/Models/ComputerCallResponseItem.cs b/src/Generated/Models/ComputerCallResponseItem.cs index 412735e83..a05d55f3f 100644 --- a/src/Generated/Models/ComputerCallResponseItem.cs +++ b/src/Generated/Models/ComputerCallResponseItem.cs @@ -4,11 +4,24 @@ using System; using System.Collections.Generic; +using System.Linq; +using OpenAI; namespace OpenAI.Responses { public partial class ComputerCallResponseItem : ResponseItem { + public ComputerCallResponseItem(string callId, ComputerCallAction action, IEnumerable pendingSafetyChecks) : base(InternalResponsesItemType.ComputerCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(action, nameof(action)); + Argument.AssertNotNull(pendingSafetyChecks, nameof(pendingSafetyChecks)); + + CallId = callId; + Action = action; + PendingSafetyChecks = pendingSafetyChecks.ToList(); + } + internal ComputerCallResponseItem(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, string callId, ComputerCallAction action, IList pendingSafetyChecks, ComputerCallStatus status) : base(@type, id, additionalBinaryDataProperties) { CallId = callId; diff --git a/src/Generated/Models/FileSearchCallResponseItem.cs b/src/Generated/Models/FileSearchCallResponseItem.cs index 5bac893bb..c47b7468f 100644 --- a/src/Generated/Models/FileSearchCallResponseItem.cs +++ b/src/Generated/Models/FileSearchCallResponseItem.cs @@ -4,11 +4,21 @@ using System; using System.Collections.Generic; +using System.Linq; +using OpenAI; namespace OpenAI.Responses { public partial class FileSearchCallResponseItem : ResponseItem { + public FileSearchCallResponseItem(IEnumerable queries, IEnumerable results) : base(InternalResponsesItemType.FileSearchCall) + { + Argument.AssertNotNull(queries, nameof(queries)); + + Queries = queries.ToList(); + Results = results?.ToList(); + } + internal FileSearchCallResponseItem(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, FileSearchCallStatus status, IList queries, IList results) : base(@type, id, additionalBinaryDataProperties) { Status = status; diff --git a/src/Generated/Models/FunctionCallResponseItem.Serialization.cs b/src/Generated/Models/FunctionCallResponseItem.Serialization.cs index c9429aa2e..5ea8af3b7 100644 --- a/src/Generated/Models/FunctionCallResponseItem.Serialization.cs +++ b/src/Generated/Models/FunctionCallResponseItem.Serialization.cs @@ -50,14 +50,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (_additionalBinaryDataProperties?.ContainsKey("arguments") != true) { writer.WritePropertyName("arguments"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(FunctionArguments); -#else - using (JsonDocument document = JsonDocument.Parse(FunctionArguments)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + SerializeFunctionArgumentsValue(writer, options); } } @@ -120,7 +113,7 @@ internal static FunctionCallResponseItem DeserializeFunctionCallResponseItem(Jso } if (prop.NameEquals("arguments"u8)) { - functionArguments = BinaryData.FromString(prop.Value.GetRawText()); + DeserializeFunctionArgumentsValue(prop, ref functionArguments); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); diff --git a/src/Generated/Models/FunctionCallResponseItem.cs b/src/Generated/Models/FunctionCallResponseItem.cs index e92b76032..0341e604a 100644 --- a/src/Generated/Models/FunctionCallResponseItem.cs +++ b/src/Generated/Models/FunctionCallResponseItem.cs @@ -4,11 +4,23 @@ using System; using System.Collections.Generic; +using OpenAI; namespace OpenAI.Responses { public partial class FunctionCallResponseItem : ResponseItem { + public FunctionCallResponseItem(string callId, string functionName, BinaryData functionArguments) : base(InternalResponsesItemType.FunctionCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(functionName, nameof(functionName)); + Argument.AssertNotNull(functionArguments, nameof(functionArguments)); + + CallId = callId; + FunctionName = functionName; + FunctionArguments = functionArguments; + } + internal FunctionCallResponseItem(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, FunctionCallStatus? status, string callId, string functionName, BinaryData functionArguments) : base(@type, id, additionalBinaryDataProperties) { Status = status; diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.Serialization.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.Serialization.cs index 13a130c5e..4bdc69847 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.Serialization.cs @@ -27,21 +27,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartFileFile)} does not support writing '{format}' format."); } - if (Optional.IsDefined(FileName) && _additionalBinaryDataProperties?.ContainsKey("file_name") != true) + if (Optional.IsDefined(Filename) && _additionalBinaryDataProperties?.ContainsKey("filename") != true) { - writer.WritePropertyName("file_name"u8); - writer.WriteStringValue(FileName); - } - if (Optional.IsDefined(FileData) && _additionalBinaryDataProperties?.ContainsKey("file_data") != true) - { - writer.WritePropertyName("file_data"u8); - writer.WriteStringValue(FileData); + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); } if (Optional.IsDefined(FileId) && _additionalBinaryDataProperties?.ContainsKey("file_id") != true) { writer.WritePropertyName("file_id"u8); writer.WriteStringValue(FileId); } + if (Optional.IsDefined(FileData) && _additionalBinaryDataProperties?.ContainsKey("file_data") != true) + { + writer.WritePropertyName("file_data"u8); + writer.WriteStringValue(FileData); + } if (_additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -82,30 +82,30 @@ internal static InternalChatCompletionRequestMessageContentPartFileFile Deserial { return null; } - string fileName = default; - string fileData = default; + string filename = default; string fileId = default; + string fileData = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("file_name"u8)) + if (prop.NameEquals("filename"u8)) { - fileName = prop.Value.GetString(); + filename = prop.Value.GetString(); continue; } - if (prop.NameEquals("file_data"u8)) + if (prop.NameEquals("file_id"u8)) { - fileData = prop.Value.GetString(); + fileId = prop.Value.GetString(); continue; } - if (prop.NameEquals("file_id"u8)) + if (prop.NameEquals("file_data"u8)) { - fileId = prop.Value.GetString(); + fileData = prop.Value.GetString(); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalChatCompletionRequestMessageContentPartFileFile(fileName, fileData, fileId, additionalBinaryDataProperties); + return new InternalChatCompletionRequestMessageContentPartFileFile(filename, fileId, fileData, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.cs index 12b56addf..1d2e317f4 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartFileFile.cs @@ -15,17 +15,15 @@ public InternalChatCompletionRequestMessageContentPartFileFile() { } - internal InternalChatCompletionRequestMessageContentPartFileFile(string fileName, string fileData, string fileId, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionRequestMessageContentPartFileFile(string filename, string fileId, string fileData, IDictionary additionalBinaryDataProperties) { - FileName = fileName; - FileData = fileData; + Filename = filename; FileId = fileId; + FileData = fileData; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public string FileName { get; set; } - - public string FileData { get; set; } + public string Filename { get; set; } public string FileId { get; set; } diff --git a/src/Generated/Models/InternalComparisonFilter.Serialization.cs b/src/Generated/Models/InternalComparisonFilter.Serialization.cs new file mode 100644 index 000000000..18a0ac1ba --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilter.Serialization.cs @@ -0,0 +1,166 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + [PersistableModelProxy(typeof(InternalUnknownComparisonFilter))] + internal abstract partial class InternalComparisonFilter : IJsonModel + { + internal InternalComparisonFilter() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (_additionalBinaryDataProperties?.ContainsKey("key") != true) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (_additionalBinaryDataProperties?.ContainsKey("value") != true) + { + writer.WritePropertyName("value"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Value); +#else + using (JsonDocument document = JsonDocument.Parse(Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (_additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalComparisonFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + + internal static InternalComparisonFilter DeserializeInternalComparisonFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "eq": + return InternalComparisonFilterEquals.DeserializeInternalComparisonFilterEquals(element, options); + case "ne": + return InternalComparisonFilterNotEquals.DeserializeInternalComparisonFilterNotEquals(element, options); + case "gt": + return InternalComparisonFilterGreaterThan.DeserializeInternalComparisonFilterGreaterThan(element, options); + case "gte": + return InternalComparisonFilterGreaterThanOrEquals.DeserializeInternalComparisonFilterGreaterThanOrEquals(element, options); + case "lt": + return InternalComparisonFilterLessThan.DeserializeInternalComparisonFilterLessThan(element, options); + case "lte": + return InternalComparisonFilterLessThanOrEquals.DeserializeInternalComparisonFilterLessThanOrEquals(element, options); + } + } + return InternalUnknownComparisonFilter.DeserializeInternalUnknownComparisonFilter(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalComparisonFilter internalComparisonFilter) + { + if (internalComparisonFilter == null) + { + return null; + } + return BinaryContent.Create(internalComparisonFilter, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalComparisonFilter(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalComparisonFilter(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilter.cs b/src/Generated/Models/InternalComparisonFilter.cs new file mode 100644 index 000000000..b208d40a8 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilter.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal abstract partial class InternalComparisonFilter + { + private protected IDictionary _additionalBinaryDataProperties; + + private protected InternalComparisonFilter(InternalComparisonFilterType @type, string key, BinaryData value) + { + Type = @type; + Key = key; + Value = value; + } + + internal InternalComparisonFilter(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Key = key; + Value = value; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal InternalComparisonFilterType Type { get; set; } + + public string Key { get; set; } + + public BinaryData Value { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterEquals.Serialization.cs b/src/Generated/Models/InternalComparisonFilterEquals.Serialization.cs new file mode 100644 index 000000000..fa03d4333 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterEquals.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterEquals : IJsonModel + { + internal InternalComparisonFilterEquals() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterEquals)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalComparisonFilterEquals IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComparisonFilterEquals)JsonModelCreateCore(ref reader, options); + + protected override InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterEquals)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilterEquals(document.RootElement, options); + } + + internal static InternalComparisonFilterEquals DeserializeInternalComparisonFilterEquals(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalComparisonFilterEquals(@type, key, value, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterEquals)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilterEquals IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComparisonFilterEquals)PersistableModelCreateCore(data, options); + + protected override InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilterEquals(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterEquals)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalComparisonFilterEquals internalComparisonFilterEquals) + { + if (internalComparisonFilterEquals == null) + { + return null; + } + return BinaryContent.Create(internalComparisonFilterEquals, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalComparisonFilterEquals(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalComparisonFilterEquals(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterEquals.cs b/src/Generated/Models/InternalComparisonFilterEquals.cs new file mode 100644 index 000000000..74b847e18 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterEquals.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterEquals : InternalComparisonFilter + { + public InternalComparisonFilterEquals(string key, BinaryData value) : base(InternalComparisonFilterType.Eq, key, value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + } + + internal InternalComparisonFilterEquals(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) : base(@type, key, value, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterGreaterThan.Serialization.cs b/src/Generated/Models/InternalComparisonFilterGreaterThan.Serialization.cs new file mode 100644 index 000000000..bafe42e86 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterGreaterThan.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterGreaterThan : IJsonModel + { + internal InternalComparisonFilterGreaterThan() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThan)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalComparisonFilterGreaterThan IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComparisonFilterGreaterThan)JsonModelCreateCore(ref reader, options); + + protected override InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThan)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilterGreaterThan(document.RootElement, options); + } + + internal static InternalComparisonFilterGreaterThan DeserializeInternalComparisonFilterGreaterThan(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalComparisonFilterGreaterThan(@type, key, value, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThan)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilterGreaterThan IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComparisonFilterGreaterThan)PersistableModelCreateCore(data, options); + + protected override InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilterGreaterThan(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThan)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalComparisonFilterGreaterThan internalComparisonFilterGreaterThan) + { + if (internalComparisonFilterGreaterThan == null) + { + return null; + } + return BinaryContent.Create(internalComparisonFilterGreaterThan, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalComparisonFilterGreaterThan(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalComparisonFilterGreaterThan(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterGreaterThan.cs b/src/Generated/Models/InternalComparisonFilterGreaterThan.cs new file mode 100644 index 000000000..8714f22cb --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterGreaterThan.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterGreaterThan : InternalComparisonFilter + { + public InternalComparisonFilterGreaterThan(string key, BinaryData value) : base(InternalComparisonFilterType.Gt, key, value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + } + + internal InternalComparisonFilterGreaterThan(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) : base(@type, key, value, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterGreaterThanOrEquals.Serialization.cs b/src/Generated/Models/InternalComparisonFilterGreaterThanOrEquals.Serialization.cs new file mode 100644 index 000000000..80b02a4ba --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterGreaterThanOrEquals.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterGreaterThanOrEquals : IJsonModel + { + internal InternalComparisonFilterGreaterThanOrEquals() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThanOrEquals)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalComparisonFilterGreaterThanOrEquals IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComparisonFilterGreaterThanOrEquals)JsonModelCreateCore(ref reader, options); + + protected override InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThanOrEquals)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilterGreaterThanOrEquals(document.RootElement, options); + } + + internal static InternalComparisonFilterGreaterThanOrEquals DeserializeInternalComparisonFilterGreaterThanOrEquals(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalComparisonFilterGreaterThanOrEquals(@type, key, value, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThanOrEquals)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilterGreaterThanOrEquals IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComparisonFilterGreaterThanOrEquals)PersistableModelCreateCore(data, options); + + protected override InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilterGreaterThanOrEquals(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterGreaterThanOrEquals)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalComparisonFilterGreaterThanOrEquals internalComparisonFilterGreaterThanOrEquals) + { + if (internalComparisonFilterGreaterThanOrEquals == null) + { + return null; + } + return BinaryContent.Create(internalComparisonFilterGreaterThanOrEquals, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalComparisonFilterGreaterThanOrEquals(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalComparisonFilterGreaterThanOrEquals(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterGreaterThanOrEquals.cs b/src/Generated/Models/InternalComparisonFilterGreaterThanOrEquals.cs new file mode 100644 index 000000000..9e563488e --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterGreaterThanOrEquals.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterGreaterThanOrEquals : InternalComparisonFilter + { + public InternalComparisonFilterGreaterThanOrEquals(string key, BinaryData value) : base(InternalComparisonFilterType.Gte, key, value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + } + + internal InternalComparisonFilterGreaterThanOrEquals(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) : base(@type, key, value, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterLessThan.Serialization.cs b/src/Generated/Models/InternalComparisonFilterLessThan.Serialization.cs new file mode 100644 index 000000000..b2690c982 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterLessThan.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterLessThan : IJsonModel + { + internal InternalComparisonFilterLessThan() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThan)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalComparisonFilterLessThan IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComparisonFilterLessThan)JsonModelCreateCore(ref reader, options); + + protected override InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThan)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilterLessThan(document.RootElement, options); + } + + internal static InternalComparisonFilterLessThan DeserializeInternalComparisonFilterLessThan(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalComparisonFilterLessThan(@type, key, value, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThan)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilterLessThan IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComparisonFilterLessThan)PersistableModelCreateCore(data, options); + + protected override InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilterLessThan(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThan)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalComparisonFilterLessThan internalComparisonFilterLessThan) + { + if (internalComparisonFilterLessThan == null) + { + return null; + } + return BinaryContent.Create(internalComparisonFilterLessThan, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalComparisonFilterLessThan(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalComparisonFilterLessThan(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterLessThan.cs b/src/Generated/Models/InternalComparisonFilterLessThan.cs new file mode 100644 index 000000000..ef4f5a471 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterLessThan.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterLessThan : InternalComparisonFilter + { + public InternalComparisonFilterLessThan(string key, BinaryData value) : base(InternalComparisonFilterType.Lt, key, value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + } + + internal InternalComparisonFilterLessThan(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) : base(@type, key, value, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterLessThanOrEquals.Serialization.cs b/src/Generated/Models/InternalComparisonFilterLessThanOrEquals.Serialization.cs new file mode 100644 index 000000000..1883f8dc0 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterLessThanOrEquals.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterLessThanOrEquals : IJsonModel + { + internal InternalComparisonFilterLessThanOrEquals() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThanOrEquals)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalComparisonFilterLessThanOrEquals IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComparisonFilterLessThanOrEquals)JsonModelCreateCore(ref reader, options); + + protected override InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThanOrEquals)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilterLessThanOrEquals(document.RootElement, options); + } + + internal static InternalComparisonFilterLessThanOrEquals DeserializeInternalComparisonFilterLessThanOrEquals(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalComparisonFilterLessThanOrEquals(@type, key, value, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThanOrEquals)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilterLessThanOrEquals IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComparisonFilterLessThanOrEquals)PersistableModelCreateCore(data, options); + + protected override InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilterLessThanOrEquals(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterLessThanOrEquals)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalComparisonFilterLessThanOrEquals internalComparisonFilterLessThanOrEquals) + { + if (internalComparisonFilterLessThanOrEquals == null) + { + return null; + } + return BinaryContent.Create(internalComparisonFilterLessThanOrEquals, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalComparisonFilterLessThanOrEquals(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalComparisonFilterLessThanOrEquals(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterLessThanOrEquals.cs b/src/Generated/Models/InternalComparisonFilterLessThanOrEquals.cs new file mode 100644 index 000000000..48d44d03b --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterLessThanOrEquals.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterLessThanOrEquals : InternalComparisonFilter + { + public InternalComparisonFilterLessThanOrEquals(string key, BinaryData value) : base(InternalComparisonFilterType.Lte, key, value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + } + + internal InternalComparisonFilterLessThanOrEquals(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) : base(@type, key, value, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterNotEquals.Serialization.cs b/src/Generated/Models/InternalComparisonFilterNotEquals.Serialization.cs new file mode 100644 index 000000000..cb7532531 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterNotEquals.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterNotEquals : IJsonModel + { + internal InternalComparisonFilterNotEquals() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterNotEquals)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalComparisonFilterNotEquals IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComparisonFilterNotEquals)JsonModelCreateCore(ref reader, options); + + protected override InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilterNotEquals)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilterNotEquals(document.RootElement, options); + } + + internal static InternalComparisonFilterNotEquals DeserializeInternalComparisonFilterNotEquals(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalComparisonFilterNotEquals(@type, key, value, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterNotEquals)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilterNotEquals IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComparisonFilterNotEquals)PersistableModelCreateCore(data, options); + + protected override InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilterNotEquals(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilterNotEquals)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalComparisonFilterNotEquals internalComparisonFilterNotEquals) + { + if (internalComparisonFilterNotEquals == null) + { + return null; + } + return BinaryContent.Create(internalComparisonFilterNotEquals, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalComparisonFilterNotEquals(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalComparisonFilterNotEquals(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterNotEquals.cs b/src/Generated/Models/InternalComparisonFilterNotEquals.cs new file mode 100644 index 000000000..bc7057b2f --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterNotEquals.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalComparisonFilterNotEquals : InternalComparisonFilter + { + public InternalComparisonFilterNotEquals(string key, BinaryData value) : base(InternalComparisonFilterType.Ne, key, value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + } + + internal InternalComparisonFilterNotEquals(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) : base(@type, key, value, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalComparisonFilterType.cs b/src/Generated/Models/InternalComparisonFilterType.cs new file mode 100644 index 000000000..208e1fab3 --- /dev/null +++ b/src/Generated/Models/InternalComparisonFilterType.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Responses +{ + internal readonly partial struct InternalComparisonFilterType : IEquatable + { + private readonly string _value; + private const string EqValue = "eq"; + private const string NeValue = "ne"; + private const string GtValue = "gt"; + private const string GteValue = "gte"; + private const string LtValue = "lt"; + private const string LteValue = "lte"; + + public InternalComparisonFilterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalComparisonFilterType Eq { get; } = new InternalComparisonFilterType(EqValue); + + public static InternalComparisonFilterType Ne { get; } = new InternalComparisonFilterType(NeValue); + + public static InternalComparisonFilterType Gt { get; } = new InternalComparisonFilterType(GtValue); + + public static InternalComparisonFilterType Gte { get; } = new InternalComparisonFilterType(GteValue); + + public static InternalComparisonFilterType Lt { get; } = new InternalComparisonFilterType(LtValue); + + public static InternalComparisonFilterType Lte { get; } = new InternalComparisonFilterType(LteValue); + + public static bool operator ==(InternalComparisonFilterType left, InternalComparisonFilterType right) => left.Equals(right); + + public static bool operator !=(InternalComparisonFilterType left, InternalComparisonFilterType right) => !left.Equals(right); + + public static implicit operator InternalComparisonFilterType(string value) => new InternalComparisonFilterType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalComparisonFilterType other && Equals(other); + + public bool Equals(InternalComparisonFilterType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/src/Generated/Models/InternalCompoundFilter.Serialization.cs b/src/Generated/Models/InternalCompoundFilter.Serialization.cs new file mode 100644 index 000000000..41926adb3 --- /dev/null +++ b/src/Generated/Models/InternalCompoundFilter.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + [PersistableModelProxy(typeof(InternalUnknownCompoundFilter))] + internal abstract partial class InternalCompoundFilter : IJsonModel + { + internal InternalCompoundFilter() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (_additionalBinaryDataProperties?.ContainsKey("filters") != true) + { + writer.WritePropertyName("filters"u8); + writer.WriteStartArray(); + foreach (BinaryData item in Filters) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndArray(); + } + if (_additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalCompoundFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalCompoundFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + + internal static InternalCompoundFilter DeserializeInternalCompoundFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "and": + return InternalCompoundFilterAnd.DeserializeInternalCompoundFilterAnd(element, options); + case "or": + return InternalCompoundFilterOr.DeserializeInternalCompoundFilterOr(element, options); + } + } + return InternalUnknownCompoundFilter.DeserializeInternalUnknownCompoundFilter(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{options.Format}' format."); + } + } + + InternalCompoundFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalCompoundFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalCompoundFilter internalCompoundFilter) + { + if (internalCompoundFilter == null) + { + return null; + } + return BinaryContent.Create(internalCompoundFilter, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalCompoundFilter(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalCompoundFilter(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalCompoundFilter.cs b/src/Generated/Models/InternalCompoundFilter.cs new file mode 100644 index 000000000..49e11f8c0 --- /dev/null +++ b/src/Generated/Models/InternalCompoundFilter.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace OpenAI.Responses +{ + internal abstract partial class InternalCompoundFilter + { + private protected IDictionary _additionalBinaryDataProperties; + + private protected InternalCompoundFilter(InternalCompoundFilterType @type, IEnumerable filters) + { + Type = @type; + Filters = filters.ToList(); + } + + internal InternalCompoundFilter(InternalCompoundFilterType @type, IList filters, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Filters = filters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal InternalCompoundFilterType Type { get; set; } + + public IList Filters { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/src/Generated/Models/InternalCompoundFilterAnd.Serialization.cs b/src/Generated/Models/InternalCompoundFilterAnd.Serialization.cs new file mode 100644 index 000000000..f41787054 --- /dev/null +++ b/src/Generated/Models/InternalCompoundFilterAnd.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalCompoundFilterAnd : IJsonModel + { + internal InternalCompoundFilterAnd() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilterAnd)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalCompoundFilterAnd IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCompoundFilterAnd)JsonModelCreateCore(ref reader, options); + + protected override InternalCompoundFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilterAnd)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCompoundFilterAnd(document.RootElement, options); + } + + internal static InternalCompoundFilterAnd DeserializeInternalCompoundFilterAnd(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCompoundFilterType @type = default; + IList filters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalCompoundFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("filters"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + filters = array; + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalCompoundFilterAnd(@type, filters, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCompoundFilterAnd)} does not support writing '{options.Format}' format."); + } + } + + InternalCompoundFilterAnd IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCompoundFilterAnd)PersistableModelCreateCore(data, options); + + protected override InternalCompoundFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalCompoundFilterAnd(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCompoundFilterAnd)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalCompoundFilterAnd internalCompoundFilterAnd) + { + if (internalCompoundFilterAnd == null) + { + return null; + } + return BinaryContent.Create(internalCompoundFilterAnd, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalCompoundFilterAnd(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalCompoundFilterAnd(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalCompoundFilterAnd.cs b/src/Generated/Models/InternalCompoundFilterAnd.cs new file mode 100644 index 000000000..02c8da221 --- /dev/null +++ b/src/Generated/Models/InternalCompoundFilterAnd.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalCompoundFilterAnd : InternalCompoundFilter + { + public InternalCompoundFilterAnd(IEnumerable filters) : base(InternalCompoundFilterType.And, filters) + { + Argument.AssertNotNull(filters, nameof(filters)); + + } + + internal InternalCompoundFilterAnd(InternalCompoundFilterType @type, IList filters, IDictionary additionalBinaryDataProperties) : base(@type, filters, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalCompoundFilterOr.Serialization.cs b/src/Generated/Models/InternalCompoundFilterOr.Serialization.cs new file mode 100644 index 000000000..e2b55bd0a --- /dev/null +++ b/src/Generated/Models/InternalCompoundFilterOr.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalCompoundFilterOr : IJsonModel + { + internal InternalCompoundFilterOr() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilterOr)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalCompoundFilterOr IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCompoundFilterOr)JsonModelCreateCore(ref reader, options); + + protected override InternalCompoundFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilterOr)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCompoundFilterOr(document.RootElement, options); + } + + internal static InternalCompoundFilterOr DeserializeInternalCompoundFilterOr(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCompoundFilterType @type = default; + IList filters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalCompoundFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("filters"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + filters = array; + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalCompoundFilterOr(@type, filters, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCompoundFilterOr)} does not support writing '{options.Format}' format."); + } + } + + InternalCompoundFilterOr IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCompoundFilterOr)PersistableModelCreateCore(data, options); + + protected override InternalCompoundFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalCompoundFilterOr(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCompoundFilterOr)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalCompoundFilterOr internalCompoundFilterOr) + { + if (internalCompoundFilterOr == null) + { + return null; + } + return BinaryContent.Create(internalCompoundFilterOr, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalCompoundFilterOr(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalCompoundFilterOr(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalCompoundFilterOr.cs b/src/Generated/Models/InternalCompoundFilterOr.cs new file mode 100644 index 000000000..6f085b2ec --- /dev/null +++ b/src/Generated/Models/InternalCompoundFilterOr.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalCompoundFilterOr : InternalCompoundFilter + { + public InternalCompoundFilterOr(IEnumerable filters) : base(InternalCompoundFilterType.Or, filters) + { + Argument.AssertNotNull(filters, nameof(filters)); + + } + + internal InternalCompoundFilterOr(InternalCompoundFilterType @type, IList filters, IDictionary additionalBinaryDataProperties) : base(@type, filters, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalCompoundFilterType.cs b/src/Generated/Models/InternalCompoundFilterType.cs new file mode 100644 index 000000000..155c5233b --- /dev/null +++ b/src/Generated/Models/InternalCompoundFilterType.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Responses +{ + internal readonly partial struct InternalCompoundFilterType : IEquatable + { + private readonly string _value; + private const string AndValue = "and"; + private const string OrValue = "or"; + + public InternalCompoundFilterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalCompoundFilterType And { get; } = new InternalCompoundFilterType(AndValue); + + public static InternalCompoundFilterType Or { get; } = new InternalCompoundFilterType(OrValue); + + public static bool operator ==(InternalCompoundFilterType left, InternalCompoundFilterType right) => left.Equals(right); + + public static bool operator !=(InternalCompoundFilterType left, InternalCompoundFilterType right) => !left.Equals(right); + + public static implicit operator InternalCompoundFilterType(string value) => new InternalCompoundFilterType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCompoundFilterType other && Equals(other); + + public bool Equals(InternalCompoundFilterType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs index 51f28dbe1..0cb813d6a 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs @@ -46,6 +46,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("total_tokens"u8); writer.WriteNumberValue(TotalTokens); } + if (Optional.IsDefined(CompletionTokensDetails) && _additionalBinaryDataProperties?.ContainsKey("completion_tokens_details") != true) + { + writer.WritePropertyName("completion_tokens_details"u8); + writer.WriteObjectValue(CompletionTokensDetails, options); + } + if (Optional.IsDefined(PromptTokensDetails) && _additionalBinaryDataProperties?.ContainsKey("prompt_tokens_details") != true) + { + writer.WritePropertyName("prompt_tokens_details"u8); + writer.WriteObjectValue(PromptTokensDetails, options); + } if (_additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -89,6 +99,8 @@ internal static InternalCreateChatCompletionStreamResponseUsage DeserializeInter int completionTokens = default; int promptTokens = default; int totalTokens = default; + ChatOutputTokenUsageDetails completionTokensDetails = default; + ChatInputTokenUsageDetails promptTokensDetails = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -107,9 +119,33 @@ internal static InternalCreateChatCompletionStreamResponseUsage DeserializeInter totalTokens = prop.Value.GetInt32(); continue; } + if (prop.NameEquals("completion_tokens_details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completionTokensDetails = ChatOutputTokenUsageDetails.DeserializeChatOutputTokenUsageDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("prompt_tokens_details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + promptTokensDetails = ChatInputTokenUsageDetails.DeserializeChatInputTokenUsageDetails(prop.Value, options); + continue; + } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalCreateChatCompletionStreamResponseUsage(completionTokens, promptTokens, totalTokens, additionalBinaryDataProperties); + return new InternalCreateChatCompletionStreamResponseUsage( + completionTokens, + promptTokens, + totalTokens, + completionTokensDetails, + promptTokensDetails, + additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs index 3618fba02..181381ab7 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs @@ -18,11 +18,13 @@ internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, i TotalTokens = totalTokens; } - internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, int promptTokens, int totalTokens, IDictionary additionalBinaryDataProperties) + internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, int promptTokens, int totalTokens, ChatOutputTokenUsageDetails completionTokensDetails, ChatInputTokenUsageDetails promptTokensDetails, IDictionary additionalBinaryDataProperties) { CompletionTokens = completionTokens; PromptTokens = promptTokens; TotalTokens = totalTokens; + CompletionTokensDetails = completionTokensDetails; + PromptTokensDetails = promptTokensDetails; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -32,6 +34,10 @@ internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, i public int TotalTokens { get; } + public ChatOutputTokenUsageDetails CompletionTokensDetails { get; } + + public ChatInputTokenUsageDetails PromptTokensDetails { get; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/src/Generated/Models/InternalResponsesAssistantMessage.Serialization.cs b/src/Generated/Models/InternalResponsesAssistantMessage.Serialization.cs index ec332ed45..776fd1e3e 100644 --- a/src/Generated/Models/InternalResponsesAssistantMessage.Serialization.cs +++ b/src/Generated/Models/InternalResponsesAssistantMessage.Serialization.cs @@ -67,7 +67,7 @@ internal static InternalResponsesAssistantMessage DeserializeInternalResponsesAs string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); MessageStatus? status = default; - MessageRole role = default; + InternalResponsesMessageRole internalRole = default; IList internalContent = default; foreach (var prop in element.EnumerateObject()) { @@ -92,7 +92,7 @@ internal static InternalResponsesAssistantMessage DeserializeInternalResponsesAs } if (prop.NameEquals("role"u8)) { - role = new MessageRole(prop.Value.GetString()); + internalRole = new InternalResponsesMessageRole(prop.Value.GetString()); continue; } if (prop.NameEquals("content"u8)) @@ -112,7 +112,7 @@ internal static InternalResponsesAssistantMessage DeserializeInternalResponsesAs id, additionalBinaryDataProperties, status, - role, + internalRole, internalContent); } diff --git a/src/Generated/Models/InternalResponsesAssistantMessage.cs b/src/Generated/Models/InternalResponsesAssistantMessage.cs index cbf583dc4..cbb61bb09 100644 --- a/src/Generated/Models/InternalResponsesAssistantMessage.cs +++ b/src/Generated/Models/InternalResponsesAssistantMessage.cs @@ -4,13 +4,21 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenAI; namespace OpenAI.Responses { internal partial class InternalResponsesAssistantMessage : MessageResponseItem { - internal InternalResponsesAssistantMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, MessageRole role, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, role) + public InternalResponsesAssistantMessage(IEnumerable internalContent) : base(InternalResponsesMessageRole.Assistant) + { + Argument.AssertNotNull(internalContent, nameof(internalContent)); + + InternalContent = internalContent.ToList(); + } + + internal InternalResponsesAssistantMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, InternalResponsesMessageRole internalRole, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, internalRole) { // Plugin customization: ensure initialization of collection InternalContent = internalContent ?? new ChangeTrackingList(); diff --git a/src/Generated/Models/InternalResponsesComputerTool.Serialization.cs b/src/Generated/Models/InternalResponsesComputerTool.Serialization.cs index 00df27015..b76009a0e 100644 --- a/src/Generated/Models/InternalResponsesComputerTool.Serialization.cs +++ b/src/Generated/Models/InternalResponsesComputerTool.Serialization.cs @@ -70,8 +70,8 @@ internal static InternalResponsesComputerTool DeserializeInternalResponsesComput } InternalResponsesToolType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - float displayWidth = default; - float displayHeight = default; + int displayWidth = default; + int displayHeight = default; ComputerToolEnvironment environment = default; foreach (var prop in element.EnumerateObject()) { @@ -82,12 +82,12 @@ internal static InternalResponsesComputerTool DeserializeInternalResponsesComput } if (prop.NameEquals("display_width"u8)) { - displayWidth = prop.Value.GetSingle(); + displayWidth = prop.Value.GetInt32(); continue; } if (prop.NameEquals("display_height"u8)) { - displayHeight = prop.Value.GetSingle(); + displayHeight = prop.Value.GetInt32(); continue; } if (prop.NameEquals("environment"u8)) diff --git a/src/Generated/Models/InternalResponsesComputerTool.cs b/src/Generated/Models/InternalResponsesComputerTool.cs index fc1390bbb..727fd9885 100644 --- a/src/Generated/Models/InternalResponsesComputerTool.cs +++ b/src/Generated/Models/InternalResponsesComputerTool.cs @@ -9,23 +9,23 @@ namespace OpenAI.Responses { internal partial class InternalResponsesComputerTool : ResponseTool { - public InternalResponsesComputerTool(float displayWidth, float displayHeight, ComputerToolEnvironment environment) : base(InternalResponsesToolType.Computer) + public InternalResponsesComputerTool(int displayWidth, int displayHeight, ComputerToolEnvironment environment) : base(InternalResponsesToolType.Computer) { DisplayWidth = displayWidth; DisplayHeight = displayHeight; Environment = environment; } - internal InternalResponsesComputerTool(InternalResponsesToolType @type, IDictionary additionalBinaryDataProperties, float displayWidth, float displayHeight, ComputerToolEnvironment environment) : base(@type, additionalBinaryDataProperties) + internal InternalResponsesComputerTool(InternalResponsesToolType @type, IDictionary additionalBinaryDataProperties, int displayWidth, int displayHeight, ComputerToolEnvironment environment) : base(@type, additionalBinaryDataProperties) { DisplayWidth = displayWidth; DisplayHeight = displayHeight; Environment = environment; } - public float DisplayWidth { get; set; } + public int DisplayWidth { get; set; } - public float DisplayHeight { get; set; } + public int DisplayHeight { get; set; } public ComputerToolEnvironment Environment { get; set; } } diff --git a/src/Generated/Models/InternalResponsesContentType.cs b/src/Generated/Models/InternalResponsesContentType.cs new file mode 100644 index 000000000..9b39059ae --- /dev/null +++ b/src/Generated/Models/InternalResponsesContentType.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Responses +{ + internal readonly partial struct InternalResponsesContentType : IEquatable + { + private readonly string _value; + private const string InputTextValue = "input_text"; + private const string InputImageValue = "input_image"; + private const string InputFileValue = "input_file"; + private const string OutputTextValue = "output_text"; + private const string RefusalValue = "refusal"; + + public InternalResponsesContentType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalResponsesContentType InputText { get; } = new InternalResponsesContentType(InputTextValue); + + public static InternalResponsesContentType InputImage { get; } = new InternalResponsesContentType(InputImageValue); + + public static InternalResponsesContentType InputFile { get; } = new InternalResponsesContentType(InputFileValue); + + public static InternalResponsesContentType OutputText { get; } = new InternalResponsesContentType(OutputTextValue); + + public static InternalResponsesContentType Refusal { get; } = new InternalResponsesContentType(RefusalValue); + + public static bool operator ==(InternalResponsesContentType left, InternalResponsesContentType right) => left.Equals(right); + + public static bool operator !=(InternalResponsesContentType left, InternalResponsesContentType right) => !left.Equals(right); + + public static implicit operator InternalResponsesContentType(string value) => new InternalResponsesContentType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalResponsesContentType other && Equals(other); + + public bool Equals(InternalResponsesContentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/src/Generated/Models/InternalResponsesDeveloperMessage.Serialization.cs b/src/Generated/Models/InternalResponsesDeveloperMessage.Serialization.cs index f7b01d354..21b94cabb 100644 --- a/src/Generated/Models/InternalResponsesDeveloperMessage.Serialization.cs +++ b/src/Generated/Models/InternalResponsesDeveloperMessage.Serialization.cs @@ -67,7 +67,7 @@ internal static InternalResponsesDeveloperMessage DeserializeInternalResponsesDe string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); MessageStatus? status = default; - MessageRole role = default; + InternalResponsesMessageRole internalRole = default; IList internalContent = default; foreach (var prop in element.EnumerateObject()) { @@ -92,7 +92,7 @@ internal static InternalResponsesDeveloperMessage DeserializeInternalResponsesDe } if (prop.NameEquals("role"u8)) { - role = new MessageRole(prop.Value.GetString()); + internalRole = new InternalResponsesMessageRole(prop.Value.GetString()); continue; } if (prop.NameEquals("content"u8)) @@ -112,7 +112,7 @@ internal static InternalResponsesDeveloperMessage DeserializeInternalResponsesDe id, additionalBinaryDataProperties, status, - role, + internalRole, internalContent); } diff --git a/src/Generated/Models/InternalResponsesDeveloperMessage.cs b/src/Generated/Models/InternalResponsesDeveloperMessage.cs index cacf90f51..315ec9a08 100644 --- a/src/Generated/Models/InternalResponsesDeveloperMessage.cs +++ b/src/Generated/Models/InternalResponsesDeveloperMessage.cs @@ -4,13 +4,21 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenAI; namespace OpenAI.Responses { internal partial class InternalResponsesDeveloperMessage : MessageResponseItem { - internal InternalResponsesDeveloperMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, MessageRole role, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, role) + public InternalResponsesDeveloperMessage(IEnumerable internalContent) : base(InternalResponsesMessageRole.Developer) + { + Argument.AssertNotNull(internalContent, nameof(internalContent)); + + InternalContent = internalContent.ToList(); + } + + internal InternalResponsesDeveloperMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, InternalResponsesMessageRole internalRole, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, internalRole) { // Plugin customization: ensure initialization of collection InternalContent = internalContent ?? new ChangeTrackingList(); diff --git a/src/Generated/Models/InternalResponsesInputFileContentPart.Serialization.cs b/src/Generated/Models/InternalResponsesInputFileContentPart.Serialization.cs index 19a58652c..9feb1e1ba 100644 --- a/src/Generated/Models/InternalResponsesInputFileContentPart.Serialization.cs +++ b/src/Generated/Models/InternalResponsesInputFileContentPart.Serialization.cs @@ -71,7 +71,7 @@ internal static InternalResponsesInputFileContentPart DeserializeInternalRespons { return null; } - ResponseContentPartKind kind = default; + InternalResponsesContentType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string fileId = default; string filename = default; @@ -80,7 +80,7 @@ internal static InternalResponsesInputFileContentPart DeserializeInternalRespons { if (prop.NameEquals("type"u8)) { - kind = prop.Value.GetString().ToResponseContentPartKind(); + internalType = new InternalResponsesContentType(prop.Value.GetString()); continue; } if (prop.NameEquals("file_id"u8)) @@ -104,7 +104,7 @@ internal static InternalResponsesInputFileContentPart DeserializeInternalRespons } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesInputFileContentPart(kind, additionalBinaryDataProperties, fileId, filename, fileBytes); + return new InternalResponsesInputFileContentPart(internalType, additionalBinaryDataProperties, fileId, filename, fileBytes); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesInputFileContentPart.cs b/src/Generated/Models/InternalResponsesInputFileContentPart.cs index 42bb1b4f9..37dd1cffb 100644 --- a/src/Generated/Models/InternalResponsesInputFileContentPart.cs +++ b/src/Generated/Models/InternalResponsesInputFileContentPart.cs @@ -9,11 +9,11 @@ namespace OpenAI.Responses { internal partial class InternalResponsesInputFileContentPart : ResponseContentPart { - public InternalResponsesInputFileContentPart() : base(ResponseContentPartKind.InputFile) + public InternalResponsesInputFileContentPart() : base(InternalResponsesContentType.InputFile) { } - internal InternalResponsesInputFileContentPart(ResponseContentPartKind kind, IDictionary additionalBinaryDataProperties, string fileId, string filename, BinaryData fileBytes) : base(kind, additionalBinaryDataProperties) + internal InternalResponsesInputFileContentPart(InternalResponsesContentType internalType, IDictionary additionalBinaryDataProperties, string fileId, string filename, BinaryData fileBytes) : base(internalType, additionalBinaryDataProperties) { FileId = fileId; Filename = filename; diff --git a/src/Generated/Models/InternalResponsesInputImageContentPart.Serialization.cs b/src/Generated/Models/InternalResponsesInputImageContentPart.Serialization.cs index f8f9cd320..4ba3fe67d 100644 --- a/src/Generated/Models/InternalResponsesInputImageContentPart.Serialization.cs +++ b/src/Generated/Models/InternalResponsesInputImageContentPart.Serialization.cs @@ -64,7 +64,7 @@ internal static InternalResponsesInputImageContentPart DeserializeInternalRespon { return null; } - ResponseContentPartKind kind = default; + InternalResponsesContentType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string imageUrl = default; string fileId = default; @@ -73,7 +73,7 @@ internal static InternalResponsesInputImageContentPart DeserializeInternalRespon { if (prop.NameEquals("type"u8)) { - kind = prop.Value.GetString().ToResponseContentPartKind(); + internalType = new InternalResponsesContentType(prop.Value.GetString()); continue; } if (prop.NameEquals("image_url"u8)) @@ -97,7 +97,7 @@ internal static InternalResponsesInputImageContentPart DeserializeInternalRespon } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesInputImageContentPart(kind, additionalBinaryDataProperties, imageUrl, fileId, detail); + return new InternalResponsesInputImageContentPart(internalType, additionalBinaryDataProperties, imageUrl, fileId, detail); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesInputImageContentPart.cs b/src/Generated/Models/InternalResponsesInputImageContentPart.cs index aa8395f82..1eda9fbe7 100644 --- a/src/Generated/Models/InternalResponsesInputImageContentPart.cs +++ b/src/Generated/Models/InternalResponsesInputImageContentPart.cs @@ -9,11 +9,11 @@ namespace OpenAI.Responses { internal partial class InternalResponsesInputImageContentPart : ResponseContentPart { - public InternalResponsesInputImageContentPart() : base(ResponseContentPartKind.InputImage) + public InternalResponsesInputImageContentPart() : base(InternalResponsesContentType.InputImage) { } - internal InternalResponsesInputImageContentPart(ResponseContentPartKind kind, IDictionary additionalBinaryDataProperties, string imageUrl, string fileId, ResponseImageDetailLevel? detail) : base(kind, additionalBinaryDataProperties) + internal InternalResponsesInputImageContentPart(InternalResponsesContentType internalType, IDictionary additionalBinaryDataProperties, string imageUrl, string fileId, ResponseImageDetailLevel? detail) : base(internalType, additionalBinaryDataProperties) { ImageUrl = imageUrl; FileId = fileId; diff --git a/src/Generated/Models/InternalResponsesInputTextContentPart.Serialization.cs b/src/Generated/Models/InternalResponsesInputTextContentPart.Serialization.cs index 9d1081c9d..0ebd37284 100644 --- a/src/Generated/Models/InternalResponsesInputTextContentPart.Serialization.cs +++ b/src/Generated/Models/InternalResponsesInputTextContentPart.Serialization.cs @@ -58,14 +58,14 @@ internal static InternalResponsesInputTextContentPart DeserializeInternalRespons { return null; } - ResponseContentPartKind kind = default; + InternalResponsesContentType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string internalText = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - kind = prop.Value.GetString().ToResponseContentPartKind(); + internalType = new InternalResponsesContentType(prop.Value.GetString()); continue; } if (prop.NameEquals("text"u8)) @@ -75,7 +75,7 @@ internal static InternalResponsesInputTextContentPart DeserializeInternalRespons } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesInputTextContentPart(kind, additionalBinaryDataProperties, internalText); + return new InternalResponsesInputTextContentPart(internalType, additionalBinaryDataProperties, internalText); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesInputTextContentPart.cs b/src/Generated/Models/InternalResponsesInputTextContentPart.cs index c480d3d50..ab859f92c 100644 --- a/src/Generated/Models/InternalResponsesInputTextContentPart.cs +++ b/src/Generated/Models/InternalResponsesInputTextContentPart.cs @@ -10,14 +10,14 @@ namespace OpenAI.Responses { internal partial class InternalResponsesInputTextContentPart : ResponseContentPart { - public InternalResponsesInputTextContentPart(string internalText) : base(ResponseContentPartKind.InputText) + public InternalResponsesInputTextContentPart(string internalText) : base(InternalResponsesContentType.InputText) { Argument.AssertNotNull(internalText, nameof(internalText)); InternalText = internalText; } - internal InternalResponsesInputTextContentPart(ResponseContentPartKind kind, IDictionary additionalBinaryDataProperties, string internalText) : base(kind, additionalBinaryDataProperties) + internal InternalResponsesInputTextContentPart(InternalResponsesContentType internalType, IDictionary additionalBinaryDataProperties, string internalText) : base(internalType, additionalBinaryDataProperties) { InternalText = internalText; } diff --git a/src/Generated/Models/InternalResponsesMessageRole.cs b/src/Generated/Models/InternalResponsesMessageRole.cs new file mode 100644 index 000000000..6f565078f --- /dev/null +++ b/src/Generated/Models/InternalResponsesMessageRole.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Responses +{ + internal readonly partial struct InternalResponsesMessageRole : IEquatable + { + private readonly string _value; + private const string SystemValue = "system"; + private const string DeveloperValue = "developer"; + private const string UserValue = "user"; + private const string AssistantValue = "assistant"; + + public InternalResponsesMessageRole(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalResponsesMessageRole System { get; } = new InternalResponsesMessageRole(SystemValue); + + public static InternalResponsesMessageRole Developer { get; } = new InternalResponsesMessageRole(DeveloperValue); + + public static InternalResponsesMessageRole User { get; } = new InternalResponsesMessageRole(UserValue); + + public static InternalResponsesMessageRole Assistant { get; } = new InternalResponsesMessageRole(AssistantValue); + + public static bool operator ==(InternalResponsesMessageRole left, InternalResponsesMessageRole right) => left.Equals(right); + + public static bool operator !=(InternalResponsesMessageRole left, InternalResponsesMessageRole right) => !left.Equals(right); + + public static implicit operator InternalResponsesMessageRole(string value) => new InternalResponsesMessageRole(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalResponsesMessageRole other && Equals(other); + + public bool Equals(InternalResponsesMessageRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/src/Generated/Models/InternalResponsesOutputRefusalContentPart.Serialization.cs b/src/Generated/Models/InternalResponsesOutputRefusalContentPart.Serialization.cs index 1561515c5..734deb694 100644 --- a/src/Generated/Models/InternalResponsesOutputRefusalContentPart.Serialization.cs +++ b/src/Generated/Models/InternalResponsesOutputRefusalContentPart.Serialization.cs @@ -58,14 +58,14 @@ internal static InternalResponsesOutputRefusalContentPart DeserializeInternalRes { return null; } - ResponseContentPartKind kind = default; + InternalResponsesContentType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string internalRefusal = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - kind = prop.Value.GetString().ToResponseContentPartKind(); + internalType = new InternalResponsesContentType(prop.Value.GetString()); continue; } if (prop.NameEquals("refusal"u8)) @@ -75,7 +75,7 @@ internal static InternalResponsesOutputRefusalContentPart DeserializeInternalRes } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesOutputRefusalContentPart(kind, additionalBinaryDataProperties, internalRefusal); + return new InternalResponsesOutputRefusalContentPart(internalType, additionalBinaryDataProperties, internalRefusal); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesOutputRefusalContentPart.cs b/src/Generated/Models/InternalResponsesOutputRefusalContentPart.cs index 7107b7b06..2d6fa38da 100644 --- a/src/Generated/Models/InternalResponsesOutputRefusalContentPart.cs +++ b/src/Generated/Models/InternalResponsesOutputRefusalContentPart.cs @@ -10,14 +10,14 @@ namespace OpenAI.Responses { internal partial class InternalResponsesOutputRefusalContentPart : ResponseContentPart { - public InternalResponsesOutputRefusalContentPart(string internalRefusal) : base(ResponseContentPartKind.Refusal) + public InternalResponsesOutputRefusalContentPart(string internalRefusal) : base(InternalResponsesContentType.Refusal) { Argument.AssertNotNull(internalRefusal, nameof(internalRefusal)); InternalRefusal = internalRefusal; } - internal InternalResponsesOutputRefusalContentPart(ResponseContentPartKind kind, IDictionary additionalBinaryDataProperties, string internalRefusal) : base(kind, additionalBinaryDataProperties) + internal InternalResponsesOutputRefusalContentPart(InternalResponsesContentType internalType, IDictionary additionalBinaryDataProperties, string internalRefusal) : base(internalType, additionalBinaryDataProperties) { InternalRefusal = internalRefusal; } diff --git a/src/Generated/Models/InternalResponsesOutputTextContentPart.Serialization.cs b/src/Generated/Models/InternalResponsesOutputTextContentPart.Serialization.cs index d30c8743d..4568e7062 100644 --- a/src/Generated/Models/InternalResponsesOutputTextContentPart.Serialization.cs +++ b/src/Generated/Models/InternalResponsesOutputTextContentPart.Serialization.cs @@ -68,7 +68,7 @@ internal static InternalResponsesOutputTextContentPart DeserializeInternalRespon { return null; } - ResponseContentPartKind kind = default; + InternalResponsesContentType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); IList annotations = default; string internalText = default; @@ -76,7 +76,7 @@ internal static InternalResponsesOutputTextContentPart DeserializeInternalRespon { if (prop.NameEquals("type"u8)) { - kind = prop.Value.GetString().ToResponseContentPartKind(); + internalType = new InternalResponsesContentType(prop.Value.GetString()); continue; } if (prop.NameEquals("annotations"u8)) @@ -96,7 +96,7 @@ internal static InternalResponsesOutputTextContentPart DeserializeInternalRespon } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesOutputTextContentPart(kind, additionalBinaryDataProperties, annotations, internalText); + return new InternalResponsesOutputTextContentPart(internalType, additionalBinaryDataProperties, annotations, internalText); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesOutputTextContentPart.cs b/src/Generated/Models/InternalResponsesOutputTextContentPart.cs index 2af6df912..c7974eee3 100644 --- a/src/Generated/Models/InternalResponsesOutputTextContentPart.cs +++ b/src/Generated/Models/InternalResponsesOutputTextContentPart.cs @@ -11,7 +11,7 @@ namespace OpenAI.Responses { internal partial class InternalResponsesOutputTextContentPart : ResponseContentPart { - public InternalResponsesOutputTextContentPart(IEnumerable annotations, string internalText) : base(ResponseContentPartKind.OutputText) + public InternalResponsesOutputTextContentPart(IEnumerable annotations, string internalText) : base(InternalResponsesContentType.OutputText) { Argument.AssertNotNull(annotations, nameof(annotations)); Argument.AssertNotNull(internalText, nameof(internalText)); @@ -20,7 +20,7 @@ public InternalResponsesOutputTextContentPart(IEnumerable additionalBinaryDataProperties, IList annotations, string internalText) : base(kind, additionalBinaryDataProperties) + internal InternalResponsesOutputTextContentPart(InternalResponsesContentType internalType, IDictionary additionalBinaryDataProperties, IList annotations, string internalText) : base(internalType, additionalBinaryDataProperties) { Annotations = annotations; InternalText = internalText; diff --git a/src/Generated/Models/InternalResponsesReasoningItemSummaryElement.Serialization.cs b/src/Generated/Models/InternalResponsesReasoningItemSummaryElement.Serialization.cs index d5d841c52..cee749eb7 100644 --- a/src/Generated/Models/InternalResponsesReasoningItemSummaryElement.Serialization.cs +++ b/src/Generated/Models/InternalResponsesReasoningItemSummaryElement.Serialization.cs @@ -10,7 +10,7 @@ namespace OpenAI.Responses { - [PersistableModelProxy(typeof(UnknownResponsesReasoningItemSummaryElement))] + [PersistableModelProxy(typeof(InternalUnknownResponsesReasoningItemSummaryElement))] internal abstract partial class InternalResponsesReasoningItemSummaryElement : IJsonModel { internal InternalResponsesReasoningItemSummaryElement() @@ -84,7 +84,7 @@ internal static InternalResponsesReasoningItemSummaryElement DeserializeInternal return InternalResponsesReasoningItemSummaryElementSummaryText.DeserializeInternalResponsesReasoningItemSummaryElementSummaryText(element, options); } } - return UnknownResponsesReasoningItemSummaryElement.DeserializeUnknownResponsesReasoningItemSummaryElement(element, options); + return InternalUnknownResponsesReasoningItemSummaryElement.DeserializeInternalUnknownResponsesReasoningItemSummaryElement(element, options); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCompleted.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseCompleted.Serialization.cs deleted file mode 100644 index 738ca4a0f..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCompleted.Serialization.cs +++ /dev/null @@ -1,130 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseCompleted : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseCompleted() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCompleted)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("response") != true) - { - writer.WritePropertyName("response"u8); - writer.WriteObjectValue(Response, options); - } - } - - InternalResponsesResponseStreamEventResponseCompleted IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseCompleted)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCompleted)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseCompleted(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseCompleted DeserializeInternalResponsesResponseStreamEventResponseCompleted(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - OpenAIResponse response = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("response"u8)) - { - response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseCompleted(kind, additionalBinaryDataProperties, response); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCompleted)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseCompleted IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseCompleted)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseCompleted(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCompleted)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseCompleted internalResponsesResponseStreamEventResponseCompleted) - { - if (internalResponsesResponseStreamEventResponseCompleted == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseCompleted, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseCompleted(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseCompleted(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCompleted.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseCompleted.cs deleted file mode 100644 index 6d2cc50a8..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCompleted.cs +++ /dev/null @@ -1,24 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseCompleted : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseCompleted(OpenAIResponse response) : base(StreamingResponseUpdateKind.ResponseCompleted) - { - Response = response; - } - - internal InternalResponsesResponseStreamEventResponseCompleted(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(kind, additionalBinaryDataProperties) - { - Response = response; - } - - public OpenAIResponse Response { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartAdded.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartAdded.cs deleted file mode 100644 index 6d2045351..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartAdded.cs +++ /dev/null @@ -1,34 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseContentPartAdded : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseContentPartAdded(string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(StreamingResponseUpdateKind.ResponseContentPartAdded) - { - ItemId = itemId; - OutputIndex = outputIndex; - ContentIndex = contentIndex; - Part = part; - } - - internal InternalResponsesResponseStreamEventResponseContentPartAdded(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - ContentIndex = contentIndex; - Part = part; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - - public int ContentIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartDone.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartDone.cs deleted file mode 100644 index b244c6c39..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartDone.cs +++ /dev/null @@ -1,34 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseContentPartDone : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseContentPartDone(string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(StreamingResponseUpdateKind.ResponseContentPartDone) - { - ItemId = itemId; - OutputIndex = outputIndex; - ContentIndex = contentIndex; - Part = part; - } - - internal InternalResponsesResponseStreamEventResponseContentPartDone(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - ContentIndex = contentIndex; - Part = part; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - - public int ContentIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCreated.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseCreated.Serialization.cs deleted file mode 100644 index f009a5cf8..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCreated.Serialization.cs +++ /dev/null @@ -1,130 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseCreated : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseCreated() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCreated)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("response") != true) - { - writer.WritePropertyName("response"u8); - writer.WriteObjectValue(Response, options); - } - } - - InternalResponsesResponseStreamEventResponseCreated IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseCreated)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCreated)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseCreated(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseCreated DeserializeInternalResponsesResponseStreamEventResponseCreated(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - OpenAIResponse response = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("response"u8)) - { - response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseCreated(kind, additionalBinaryDataProperties, response); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCreated)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseCreated IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseCreated)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseCreated(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseCreated)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseCreated internalResponsesResponseStreamEventResponseCreated) - { - if (internalResponsesResponseStreamEventResponseCreated == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseCreated, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseCreated(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseCreated(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCreated.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseCreated.cs deleted file mode 100644 index 0aaf6b4f3..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseCreated.cs +++ /dev/null @@ -1,24 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseCreated : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseCreated(OpenAIResponse response) : base(StreamingResponseUpdateKind.ResponseCreated) - { - Response = response; - } - - internal InternalResponsesResponseStreamEventResponseCreated(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(kind, additionalBinaryDataProperties) - { - Response = response; - } - - public OpenAIResponse Response { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFailed.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFailed.Serialization.cs deleted file mode 100644 index 0206d7158..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFailed.Serialization.cs +++ /dev/null @@ -1,130 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFailed : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseFailed() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFailed)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("response") != true) - { - writer.WritePropertyName("response"u8); - writer.WriteObjectValue(Response, options); - } - } - - InternalResponsesResponseStreamEventResponseFailed IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFailed)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFailed)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseFailed(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseFailed DeserializeInternalResponsesResponseStreamEventResponseFailed(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - OpenAIResponse response = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("response"u8)) - { - response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseFailed(kind, additionalBinaryDataProperties, response); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFailed)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseFailed IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFailed)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseFailed(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFailed)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseFailed internalResponsesResponseStreamEventResponseFailed) - { - if (internalResponsesResponseStreamEventResponseFailed == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseFailed, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseFailed(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseFailed(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFailed.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFailed.cs deleted file mode 100644 index f677f686c..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFailed.cs +++ /dev/null @@ -1,24 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFailed : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseFailed(OpenAIResponse response) : base(StreamingResponseUpdateKind.ResponseFailed) - { - Response = response; - } - - internal InternalResponsesResponseStreamEventResponseFailed(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(kind, additionalBinaryDataProperties) - { - Response = response; - } - - public OpenAIResponse Response { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallCompleted.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallCompleted.Serialization.cs deleted file mode 100644 index 16d6c319c..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallCompleted.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallCompleted : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseFileSearchCallCompleted() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallCompleted)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - } - - InternalResponsesResponseStreamEventResponseFileSearchCallCompleted IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFileSearchCallCompleted)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallCompleted)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallCompleted(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseFileSearchCallCompleted DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallCompleted(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseFileSearchCallCompleted(kind, additionalBinaryDataProperties, itemId, outputIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallCompleted)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseFileSearchCallCompleted IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFileSearchCallCompleted)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallCompleted(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallCompleted)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseFileSearchCallCompleted internalResponsesResponseStreamEventResponseFileSearchCallCompleted) - { - if (internalResponsesResponseStreamEventResponseFileSearchCallCompleted == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseFileSearchCallCompleted, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseFileSearchCallCompleted(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallCompleted(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallCompleted.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallCompleted.cs deleted file mode 100644 index 1a4d55f74..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallCompleted.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallCompleted : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseFileSearchCallCompleted(string itemId, int outputIndex) : base(StreamingResponseUpdateKind.ResponseFileSearchCallCompleted) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - internal InternalResponsesResponseStreamEventResponseFileSearchCallCompleted(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallInProgress.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallInProgress.Serialization.cs deleted file mode 100644 index 2f60938c7..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallInProgress.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallInProgress : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseFileSearchCallInProgress() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallInProgress)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - } - - InternalResponsesResponseStreamEventResponseFileSearchCallInProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFileSearchCallInProgress)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallInProgress)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallInProgress(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseFileSearchCallInProgress DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallInProgress(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseFileSearchCallInProgress(kind, additionalBinaryDataProperties, itemId, outputIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallInProgress)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseFileSearchCallInProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFileSearchCallInProgress)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallInProgress(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallInProgress)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseFileSearchCallInProgress internalResponsesResponseStreamEventResponseFileSearchCallInProgress) - { - if (internalResponsesResponseStreamEventResponseFileSearchCallInProgress == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseFileSearchCallInProgress, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseFileSearchCallInProgress(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallInProgress(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallInProgress.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallInProgress.cs deleted file mode 100644 index 087397506..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallInProgress.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallInProgress : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseFileSearchCallInProgress(string itemId, int outputIndex) : base(StreamingResponseUpdateKind.ResponseFileSearchCallInProgress) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - internal InternalResponsesResponseStreamEventResponseFileSearchCallInProgress(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallSearching.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallSearching.Serialization.cs deleted file mode 100644 index 28cc75730..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallSearching.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallSearching : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseFileSearchCallSearching() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallSearching)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - } - - InternalResponsesResponseStreamEventResponseFileSearchCallSearching IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFileSearchCallSearching)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallSearching)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallSearching(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseFileSearchCallSearching DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallSearching(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseFileSearchCallSearching(kind, additionalBinaryDataProperties, itemId, outputIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallSearching)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseFileSearchCallSearching IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFileSearchCallSearching)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallSearching(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFileSearchCallSearching)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseFileSearchCallSearching internalResponsesResponseStreamEventResponseFileSearchCallSearching) - { - if (internalResponsesResponseStreamEventResponseFileSearchCallSearching == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseFileSearchCallSearching, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseFileSearchCallSearching(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallSearching(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallSearching.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallSearching.cs deleted file mode 100644 index 3f173ae73..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFileSearchCallSearching.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFileSearchCallSearching : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseFileSearchCallSearching(string itemId, int outputIndex) : base(StreamingResponseUpdateKind.ResponseFileSearchCallSearching) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - internal InternalResponsesResponseStreamEventResponseFileSearchCallSearching(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta.Serialization.cs deleted file mode 100644 index 12f407045..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta.Serialization.cs +++ /dev/null @@ -1,152 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - if (_additionalBinaryDataProperties?.ContainsKey("delta") != true) - { - writer.WritePropertyName("delta"u8); - writer.WriteStringValue(Delta); - } - } - - InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - string delta = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - if (prop.NameEquals("delta"u8)) - { - delta = prop.Value.GetString(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(kind, additionalBinaryDataProperties, itemId, outputIndex, delta); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta internalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta) - { - if (internalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta.cs deleted file mode 100644 index 81e5ca120..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta.cs +++ /dev/null @@ -1,32 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(string itemId, int outputIndex, string delta) : base(StreamingResponseUpdateKind.ResponseFunctionCallArgumentsDelta) - { - ItemId = itemId; - OutputIndex = outputIndex; - Delta = delta; - } - - internal InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, string delta) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - Delta = delta; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - - public string Delta { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone.Serialization.cs deleted file mode 100644 index b3d7d407b..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone.Serialization.cs +++ /dev/null @@ -1,152 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - if (_additionalBinaryDataProperties?.ContainsKey("arguments") != true) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - } - } - - InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - string arguments = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - if (prop.NameEquals("arguments"u8)) - { - arguments = prop.Value.GetString(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(kind, additionalBinaryDataProperties, itemId, outputIndex, arguments); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone internalResponsesResponseStreamEventResponseFunctionCallArgumentsDone) - { - if (internalResponsesResponseStreamEventResponseFunctionCallArgumentsDone == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseFunctionCallArgumentsDone, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone.cs deleted file mode 100644 index 13cba08b7..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone.cs +++ /dev/null @@ -1,32 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(string itemId, int outputIndex, string arguments) : base(StreamingResponseUpdateKind.ResponseFunctionCallArgumentsDone) - { - ItemId = itemId; - OutputIndex = outputIndex; - Arguments = arguments; - } - - internal InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, string arguments) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - Arguments = arguments; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - - public string Arguments { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseInProgress.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseInProgress.Serialization.cs deleted file mode 100644 index 006043d77..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseInProgress.Serialization.cs +++ /dev/null @@ -1,130 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseInProgress : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseInProgress() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseInProgress)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("response") != true) - { - writer.WritePropertyName("response"u8); - writer.WriteObjectValue(Response, options); - } - } - - InternalResponsesResponseStreamEventResponseInProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseInProgress)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseInProgress)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseInProgress(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseInProgress DeserializeInternalResponsesResponseStreamEventResponseInProgress(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - OpenAIResponse response = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("response"u8)) - { - response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseInProgress(kind, additionalBinaryDataProperties, response); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseInProgress)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseInProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseInProgress)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseInProgress(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseInProgress)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseInProgress internalResponsesResponseStreamEventResponseInProgress) - { - if (internalResponsesResponseStreamEventResponseInProgress == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseInProgress, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseInProgress(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseInProgress(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseInProgress.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseInProgress.cs deleted file mode 100644 index e6a2866bc..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseInProgress.cs +++ /dev/null @@ -1,24 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseInProgress : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseInProgress(OpenAIResponse response) : base(StreamingResponseUpdateKind.ResponseInProgress) - { - Response = response; - } - - internal InternalResponsesResponseStreamEventResponseInProgress(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(kind, additionalBinaryDataProperties) - { - Response = response; - } - - public OpenAIResponse Response { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseIncomplete.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseIncomplete.Serialization.cs deleted file mode 100644 index be1e8ce82..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseIncomplete.Serialization.cs +++ /dev/null @@ -1,130 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseIncomplete : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseIncomplete() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseIncomplete)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("response") != true) - { - writer.WritePropertyName("response"u8); - writer.WriteObjectValue(Response, options); - } - } - - InternalResponsesResponseStreamEventResponseIncomplete IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseIncomplete)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseIncomplete)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseIncomplete(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseIncomplete DeserializeInternalResponsesResponseStreamEventResponseIncomplete(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - OpenAIResponse response = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("response"u8)) - { - response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseIncomplete(kind, additionalBinaryDataProperties, response); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseIncomplete)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseIncomplete IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseIncomplete)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseIncomplete(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseIncomplete)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseIncomplete internalResponsesResponseStreamEventResponseIncomplete) - { - if (internalResponsesResponseStreamEventResponseIncomplete == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseIncomplete, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseIncomplete(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseIncomplete(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseIncomplete.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseIncomplete.cs deleted file mode 100644 index 4a1809a57..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseIncomplete.cs +++ /dev/null @@ -1,24 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseIncomplete : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseIncomplete(OpenAIResponse response) : base(StreamingResponseUpdateKind.ResponseIncomplete) - { - Response = response; - } - - internal InternalResponsesResponseStreamEventResponseIncomplete(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(kind, additionalBinaryDataProperties) - { - Response = response; - } - - public OpenAIResponse Response { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemAdded.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemAdded.Serialization.cs deleted file mode 100644 index 87911a394..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemAdded.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseOutputItemAdded : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseOutputItemAdded() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemAdded)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - if (_additionalBinaryDataProperties?.ContainsKey("item") != true) - { - writer.WritePropertyName("item"u8); - writer.WriteObjectValue(Item, options); - } - } - - InternalResponsesResponseStreamEventResponseOutputItemAdded IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputItemAdded)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemAdded)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseOutputItemAdded(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseOutputItemAdded DeserializeInternalResponsesResponseStreamEventResponseOutputItemAdded(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - int outputIndex = default; - ResponseItem item = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - if (prop.NameEquals("item"u8)) - { - item = ResponseItem.DeserializeResponseItem(prop.Value, options); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseOutputItemAdded(kind, additionalBinaryDataProperties, outputIndex, item); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemAdded)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseOutputItemAdded IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputItemAdded)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseOutputItemAdded(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemAdded)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseOutputItemAdded internalResponsesResponseStreamEventResponseOutputItemAdded) - { - if (internalResponsesResponseStreamEventResponseOutputItemAdded == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseOutputItemAdded, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseOutputItemAdded(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseOutputItemAdded(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemAdded.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemAdded.cs deleted file mode 100644 index b474694eb..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemAdded.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseOutputItemAdded : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseOutputItemAdded(int outputIndex, ResponseItem item) : base(StreamingResponseUpdateKind.ResponseOutputItemAdded) - { - OutputIndex = outputIndex; - Item = item; - } - - internal InternalResponsesResponseStreamEventResponseOutputItemAdded(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, int outputIndex, ResponseItem item) : base(kind, additionalBinaryDataProperties) - { - OutputIndex = outputIndex; - Item = item; - } - - public int OutputIndex { get; } - - public ResponseItem Item { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemDone.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemDone.Serialization.cs deleted file mode 100644 index 1751f53f1..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemDone.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseOutputItemDone : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseOutputItemDone() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemDone)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - if (_additionalBinaryDataProperties?.ContainsKey("item") != true) - { - writer.WritePropertyName("item"u8); - writer.WriteObjectValue(Item, options); - } - } - - InternalResponsesResponseStreamEventResponseOutputItemDone IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputItemDone)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemDone)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseOutputItemDone(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseOutputItemDone DeserializeInternalResponsesResponseStreamEventResponseOutputItemDone(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - int outputIndex = default; - ResponseItem item = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - if (prop.NameEquals("item"u8)) - { - item = ResponseItem.DeserializeResponseItem(prop.Value, options); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseOutputItemDone(kind, additionalBinaryDataProperties, outputIndex, item); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemDone)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseOutputItemDone IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputItemDone)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseOutputItemDone(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputItemDone)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseOutputItemDone internalResponsesResponseStreamEventResponseOutputItemDone) - { - if (internalResponsesResponseStreamEventResponseOutputItemDone == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseOutputItemDone, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseOutputItemDone(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseOutputItemDone(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemDone.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemDone.cs deleted file mode 100644 index 2b9753143..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputItemDone.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseOutputItemDone : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseOutputItemDone(int outputIndex, ResponseItem item) : base(StreamingResponseUpdateKind.ResponseOutputItemDone) - { - OutputIndex = outputIndex; - Item = item; - } - - internal InternalResponsesResponseStreamEventResponseOutputItemDone(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, int outputIndex, ResponseItem item) : base(kind, additionalBinaryDataProperties) - { - OutputIndex = outputIndex; - Item = item; - } - - public int OutputIndex { get; } - - public ResponseItem Item { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallCompleted.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallCompleted.Serialization.cs deleted file mode 100644 index ec060b1ee..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallCompleted.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallCompleted : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseWebSearchCallCompleted() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallCompleted)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - } - - InternalResponsesResponseStreamEventResponseWebSearchCallCompleted IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseWebSearchCallCompleted)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallCompleted)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallCompleted(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseWebSearchCallCompleted DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallCompleted(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseWebSearchCallCompleted(kind, additionalBinaryDataProperties, itemId, outputIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallCompleted)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseWebSearchCallCompleted IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseWebSearchCallCompleted)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallCompleted(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallCompleted)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseWebSearchCallCompleted internalResponsesResponseStreamEventResponseWebSearchCallCompleted) - { - if (internalResponsesResponseStreamEventResponseWebSearchCallCompleted == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseWebSearchCallCompleted, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseWebSearchCallCompleted(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallCompleted(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallCompleted.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallCompleted.cs deleted file mode 100644 index 2ebed9a87..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallCompleted.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallCompleted : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseWebSearchCallCompleted(string itemId, int outputIndex) : base(StreamingResponseUpdateKind.ResponseWebSearchCallCompleted) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - internal InternalResponsesResponseStreamEventResponseWebSearchCallCompleted(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallInProgress.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallInProgress.Serialization.cs deleted file mode 100644 index 4fe297cff..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallInProgress.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallInProgress : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseWebSearchCallInProgress() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallInProgress)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - } - - InternalResponsesResponseStreamEventResponseWebSearchCallInProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseWebSearchCallInProgress)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallInProgress)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallInProgress(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseWebSearchCallInProgress DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallInProgress(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseWebSearchCallInProgress(kind, additionalBinaryDataProperties, itemId, outputIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallInProgress)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseWebSearchCallInProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseWebSearchCallInProgress)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallInProgress(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallInProgress)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseWebSearchCallInProgress internalResponsesResponseStreamEventResponseWebSearchCallInProgress) - { - if (internalResponsesResponseStreamEventResponseWebSearchCallInProgress == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseWebSearchCallInProgress, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseWebSearchCallInProgress(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallInProgress(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallInProgress.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallInProgress.cs deleted file mode 100644 index f393659dc..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallInProgress.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallInProgress : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseWebSearchCallInProgress(string itemId, int outputIndex) : base(StreamingResponseUpdateKind.ResponseWebSearchCallInProgress) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - internal InternalResponsesResponseStreamEventResponseWebSearchCallInProgress(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallSearching.Serialization.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallSearching.Serialization.cs deleted file mode 100644 index d64ae15a8..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallSearching.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallSearching : IJsonModel - { - internal InternalResponsesResponseStreamEventResponseWebSearchCallSearching() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallSearching)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) - { - writer.WritePropertyName("item_id"u8); - writer.WriteStringValue(ItemId); - } - if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) - { - writer.WritePropertyName("output_index"u8); - writer.WriteNumberValue(OutputIndex); - } - } - - InternalResponsesResponseStreamEventResponseWebSearchCallSearching IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseWebSearchCallSearching)JsonModelCreateCore(ref reader, options); - - protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallSearching)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallSearching(document.RootElement, options); - } - - internal static InternalResponsesResponseStreamEventResponseWebSearchCallSearching DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallSearching(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StreamingResponseUpdateKind kind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string itemId = default; - int outputIndex = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("item_id"u8)) - { - itemId = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("output_index"u8)) - { - outputIndex = prop.Value.GetInt32(); - continue; - } - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalResponsesResponseStreamEventResponseWebSearchCallSearching(kind, additionalBinaryDataProperties, itemId, outputIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallSearching)} does not support writing '{options.Format}' format."); - } - } - - InternalResponsesResponseStreamEventResponseWebSearchCallSearching IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseWebSearchCallSearching)PersistableModelCreateCore(data, options); - - protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallSearching(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseWebSearchCallSearching)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseWebSearchCallSearching internalResponsesResponseStreamEventResponseWebSearchCallSearching) - { - if (internalResponsesResponseStreamEventResponseWebSearchCallSearching == null) - { - return null; - } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseWebSearchCallSearching, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalResponsesResponseStreamEventResponseWebSearchCallSearching(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallSearching(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallSearching.cs b/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallSearching.cs deleted file mode 100644 index 8419952ce..000000000 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseWebSearchCallSearching.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.Responses -{ - internal partial class InternalResponsesResponseStreamEventResponseWebSearchCallSearching : StreamingResponseUpdate - { - internal InternalResponsesResponseStreamEventResponseWebSearchCallSearching(string itemId, int outputIndex) : base(StreamingResponseUpdateKind.ResponseWebSearchCallSearching) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - internal InternalResponsesResponseStreamEventResponseWebSearchCallSearching(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(kind, additionalBinaryDataProperties) - { - ItemId = itemId; - OutputIndex = outputIndex; - } - - public string ItemId { get; } - - public int OutputIndex { get; } - } -} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventType.cs b/src/Generated/Models/InternalResponsesResponseStreamEventType.cs new file mode 100644 index 000000000..b8cc6440d --- /dev/null +++ b/src/Generated/Models/InternalResponsesResponseStreamEventType.cs @@ -0,0 +1,107 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Responses +{ + internal readonly partial struct InternalResponsesResponseStreamEventType : IEquatable + { + private readonly string _value; + private const string ErrorValue = "error"; + private const string ResponseCompletedValue = "response.completed"; + private const string ResponseContentPartAddedValue = "response.content_part.added"; + private const string ResponseContentPartDoneValue = "response.content_part.done"; + private const string ResponseCreatedValue = "response.created"; + private const string ResponseFailedValue = "response.failed"; + private const string ResponseFileSearchCallCompletedValue = "response.file_search_call.completed"; + private const string ResponseFileSearchCallInProgressValue = "response.file_search_call.in.progress"; + private const string ResponseFileSearchCallSearchingValue = "response.file_search_call.searching"; + private const string ResponseFunctionCallArgumentsDeltaValue = "response.function_call_arguments.delta"; + private const string ResponseFunctionCallArgumentsDoneValue = "response.function_call_arguments.done"; + private const string ResponseInProgressValue = "response.in_progress"; + private const string ResponseIncompleteValue = "response.incomplete"; + private const string ResponseOutputItemAddedValue = "response.output_item.added"; + private const string ResponseOutputItemDoneValue = "response.output_item.done"; + private const string ResponseOutputTextAnnotationAddedValue = "response.output_text.annotation.added"; + private const string ResponseOutputTextDeltaValue = "response.output_text.delta"; + private const string ResponseOutputTextDoneValue = "response.output_text.done"; + private const string ResponseRefusalDeltaValue = "response.refusal.delta"; + private const string ResponseRefusalDoneValue = "response.refusal.done"; + private const string ResponseWebSearchCallCompletedValue = "response.web_search_call.completed"; + private const string ResponseWebSearchCallInProgressValue = "response.web_search_call.in_progress"; + private const string ResponseWebSearchCallSearchingValue = "response.web_search_call.searching"; + + public InternalResponsesResponseStreamEventType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalResponsesResponseStreamEventType Error { get; } = new InternalResponsesResponseStreamEventType(ErrorValue); + + public static InternalResponsesResponseStreamEventType ResponseCompleted { get; } = new InternalResponsesResponseStreamEventType(ResponseCompletedValue); + + public static InternalResponsesResponseStreamEventType ResponseContentPartAdded { get; } = new InternalResponsesResponseStreamEventType(ResponseContentPartAddedValue); + + public static InternalResponsesResponseStreamEventType ResponseContentPartDone { get; } = new InternalResponsesResponseStreamEventType(ResponseContentPartDoneValue); + + public static InternalResponsesResponseStreamEventType ResponseCreated { get; } = new InternalResponsesResponseStreamEventType(ResponseCreatedValue); + + public static InternalResponsesResponseStreamEventType ResponseFailed { get; } = new InternalResponsesResponseStreamEventType(ResponseFailedValue); + + public static InternalResponsesResponseStreamEventType ResponseFileSearchCallCompleted { get; } = new InternalResponsesResponseStreamEventType(ResponseFileSearchCallCompletedValue); + + public static InternalResponsesResponseStreamEventType ResponseFileSearchCallInProgress { get; } = new InternalResponsesResponseStreamEventType(ResponseFileSearchCallInProgressValue); + + public static InternalResponsesResponseStreamEventType ResponseFileSearchCallSearching { get; } = new InternalResponsesResponseStreamEventType(ResponseFileSearchCallSearchingValue); + + public static InternalResponsesResponseStreamEventType ResponseFunctionCallArgumentsDelta { get; } = new InternalResponsesResponseStreamEventType(ResponseFunctionCallArgumentsDeltaValue); + + public static InternalResponsesResponseStreamEventType ResponseFunctionCallArgumentsDone { get; } = new InternalResponsesResponseStreamEventType(ResponseFunctionCallArgumentsDoneValue); + + public static InternalResponsesResponseStreamEventType ResponseInProgress { get; } = new InternalResponsesResponseStreamEventType(ResponseInProgressValue); + + public static InternalResponsesResponseStreamEventType ResponseIncomplete { get; } = new InternalResponsesResponseStreamEventType(ResponseIncompleteValue); + + public static InternalResponsesResponseStreamEventType ResponseOutputItemAdded { get; } = new InternalResponsesResponseStreamEventType(ResponseOutputItemAddedValue); + + public static InternalResponsesResponseStreamEventType ResponseOutputItemDone { get; } = new InternalResponsesResponseStreamEventType(ResponseOutputItemDoneValue); + + public static InternalResponsesResponseStreamEventType ResponseOutputTextAnnotationAdded { get; } = new InternalResponsesResponseStreamEventType(ResponseOutputTextAnnotationAddedValue); + + public static InternalResponsesResponseStreamEventType ResponseOutputTextDelta { get; } = new InternalResponsesResponseStreamEventType(ResponseOutputTextDeltaValue); + + public static InternalResponsesResponseStreamEventType ResponseOutputTextDone { get; } = new InternalResponsesResponseStreamEventType(ResponseOutputTextDoneValue); + + public static InternalResponsesResponseStreamEventType ResponseRefusalDelta { get; } = new InternalResponsesResponseStreamEventType(ResponseRefusalDeltaValue); + + public static InternalResponsesResponseStreamEventType ResponseRefusalDone { get; } = new InternalResponsesResponseStreamEventType(ResponseRefusalDoneValue); + + public static InternalResponsesResponseStreamEventType ResponseWebSearchCallCompleted { get; } = new InternalResponsesResponseStreamEventType(ResponseWebSearchCallCompletedValue); + + public static InternalResponsesResponseStreamEventType ResponseWebSearchCallInProgress { get; } = new InternalResponsesResponseStreamEventType(ResponseWebSearchCallInProgressValue); + + public static InternalResponsesResponseStreamEventType ResponseWebSearchCallSearching { get; } = new InternalResponsesResponseStreamEventType(ResponseWebSearchCallSearchingValue); + + public static bool operator ==(InternalResponsesResponseStreamEventType left, InternalResponsesResponseStreamEventType right) => left.Equals(right); + + public static bool operator !=(InternalResponsesResponseStreamEventType left, InternalResponsesResponseStreamEventType right) => !left.Equals(right); + + public static implicit operator InternalResponsesResponseStreamEventType(string value) => new InternalResponsesResponseStreamEventType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalResponsesResponseStreamEventType other && Equals(other); + + public bool Equals(InternalResponsesResponseStreamEventType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/src/Generated/Models/InternalResponsesSystemMessage.Serialization.cs b/src/Generated/Models/InternalResponsesSystemMessage.Serialization.cs index 4091bd4e2..58d210547 100644 --- a/src/Generated/Models/InternalResponsesSystemMessage.Serialization.cs +++ b/src/Generated/Models/InternalResponsesSystemMessage.Serialization.cs @@ -67,7 +67,7 @@ internal static InternalResponsesSystemMessage DeserializeInternalResponsesSyste string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); MessageStatus? status = default; - MessageRole role = default; + InternalResponsesMessageRole internalRole = default; IList internalContent = default; foreach (var prop in element.EnumerateObject()) { @@ -92,7 +92,7 @@ internal static InternalResponsesSystemMessage DeserializeInternalResponsesSyste } if (prop.NameEquals("role"u8)) { - role = new MessageRole(prop.Value.GetString()); + internalRole = new InternalResponsesMessageRole(prop.Value.GetString()); continue; } if (prop.NameEquals("content"u8)) @@ -112,7 +112,7 @@ internal static InternalResponsesSystemMessage DeserializeInternalResponsesSyste id, additionalBinaryDataProperties, status, - role, + internalRole, internalContent); } diff --git a/src/Generated/Models/InternalResponsesSystemMessage.cs b/src/Generated/Models/InternalResponsesSystemMessage.cs index 72741eae0..d2afad776 100644 --- a/src/Generated/Models/InternalResponsesSystemMessage.cs +++ b/src/Generated/Models/InternalResponsesSystemMessage.cs @@ -4,13 +4,21 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenAI; namespace OpenAI.Responses { internal partial class InternalResponsesSystemMessage : MessageResponseItem { - internal InternalResponsesSystemMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, MessageRole role, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, role) + public InternalResponsesSystemMessage(IEnumerable internalContent) : base(InternalResponsesMessageRole.System) + { + Argument.AssertNotNull(internalContent, nameof(internalContent)); + + InternalContent = internalContent.ToList(); + } + + internal InternalResponsesSystemMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, InternalResponsesMessageRole internalRole, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, internalRole) { // Plugin customization: ensure initialization of collection InternalContent = internalContent ?? new ChangeTrackingList(); diff --git a/src/Generated/Models/InternalResponsesTextFormatJsonObject.Serialization.cs b/src/Generated/Models/InternalResponsesTextFormatJsonObject.Serialization.cs index ac1040462..1f652cdf9 100644 --- a/src/Generated/Models/InternalResponsesTextFormatJsonObject.Serialization.cs +++ b/src/Generated/Models/InternalResponsesTextFormatJsonObject.Serialization.cs @@ -49,18 +49,18 @@ internal static InternalResponsesTextFormatJsonObject DeserializeInternalRespons { return null; } - InternalResponsesTextFormatType @type = default; + InternalResponsesTextFormatType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - @type = new InternalResponsesTextFormatType(prop.Value.GetString()); + internalType = new InternalResponsesTextFormatType(prop.Value.GetString()); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesTextFormatJsonObject(@type, additionalBinaryDataProperties); + return new InternalResponsesTextFormatJsonObject(internalType, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesTextFormatJsonObject.cs b/src/Generated/Models/InternalResponsesTextFormatJsonObject.cs index 56b3b2aa1..0e3e570a6 100644 --- a/src/Generated/Models/InternalResponsesTextFormatJsonObject.cs +++ b/src/Generated/Models/InternalResponsesTextFormatJsonObject.cs @@ -13,7 +13,7 @@ public InternalResponsesTextFormatJsonObject() : base(InternalResponsesTextForma { } - internal InternalResponsesTextFormatJsonObject(InternalResponsesTextFormatType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + internal InternalResponsesTextFormatJsonObject(InternalResponsesTextFormatType internalType, IDictionary additionalBinaryDataProperties) : base(internalType, additionalBinaryDataProperties) { } } diff --git a/src/Generated/Models/InternalResponsesTextFormatJsonSchema.Serialization.cs b/src/Generated/Models/InternalResponsesTextFormatJsonSchema.Serialization.cs index 0a81aa8c4..c4377754f 100644 --- a/src/Generated/Models/InternalResponsesTextFormatJsonSchema.Serialization.cs +++ b/src/Generated/Models/InternalResponsesTextFormatJsonSchema.Serialization.cs @@ -80,7 +80,7 @@ internal static InternalResponsesTextFormatJsonSchema DeserializeInternalRespons { return null; } - InternalResponsesTextFormatType @type = default; + InternalResponsesTextFormatType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string name = default; BinaryData schema = default; @@ -90,7 +90,7 @@ internal static InternalResponsesTextFormatJsonSchema DeserializeInternalRespons { if (prop.NameEquals("type"u8)) { - @type = new InternalResponsesTextFormatType(prop.Value.GetString()); + internalType = new InternalResponsesTextFormatType(prop.Value.GetString()); continue; } if (prop.NameEquals("name"u8)) @@ -121,7 +121,7 @@ internal static InternalResponsesTextFormatJsonSchema DeserializeInternalRespons additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } return new InternalResponsesTextFormatJsonSchema( - @type, + internalType, additionalBinaryDataProperties, name, schema, diff --git a/src/Generated/Models/InternalResponsesTextFormatJsonSchema.cs b/src/Generated/Models/InternalResponsesTextFormatJsonSchema.cs index 873138a5c..9d713497f 100644 --- a/src/Generated/Models/InternalResponsesTextFormatJsonSchema.cs +++ b/src/Generated/Models/InternalResponsesTextFormatJsonSchema.cs @@ -19,7 +19,7 @@ public InternalResponsesTextFormatJsonSchema(string name, BinaryData schema) : b Schema = schema; } - internal InternalResponsesTextFormatJsonSchema(InternalResponsesTextFormatType @type, IDictionary additionalBinaryDataProperties, string name, BinaryData schema, string description, bool? strict) : base(@type, additionalBinaryDataProperties) + internal InternalResponsesTextFormatJsonSchema(InternalResponsesTextFormatType internalType, IDictionary additionalBinaryDataProperties, string name, BinaryData schema, string description, bool? strict) : base(internalType, additionalBinaryDataProperties) { Name = name; Schema = schema; diff --git a/src/Generated/Models/InternalResponsesTextFormatText.Serialization.cs b/src/Generated/Models/InternalResponsesTextFormatText.Serialization.cs index 4830ba78d..80bfdec5a 100644 --- a/src/Generated/Models/InternalResponsesTextFormatText.Serialization.cs +++ b/src/Generated/Models/InternalResponsesTextFormatText.Serialization.cs @@ -49,18 +49,18 @@ internal static InternalResponsesTextFormatText DeserializeInternalResponsesText { return null; } - InternalResponsesTextFormatType @type = default; + InternalResponsesTextFormatType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - @type = new InternalResponsesTextFormatType(prop.Value.GetString()); + internalType = new InternalResponsesTextFormatType(prop.Value.GetString()); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesTextFormatText(@type, additionalBinaryDataProperties); + return new InternalResponsesTextFormatText(internalType, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesTextFormatText.cs b/src/Generated/Models/InternalResponsesTextFormatText.cs index 6669f3e52..acab0e2a7 100644 --- a/src/Generated/Models/InternalResponsesTextFormatText.cs +++ b/src/Generated/Models/InternalResponsesTextFormatText.cs @@ -13,7 +13,7 @@ public InternalResponsesTextFormatText() : base(InternalResponsesTextFormatType. { } - internal InternalResponsesTextFormatText(InternalResponsesTextFormatType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + internal InternalResponsesTextFormatText(InternalResponsesTextFormatType internalType, IDictionary additionalBinaryDataProperties) : base(internalType, additionalBinaryDataProperties) { } } diff --git a/src/Generated/Models/InternalResponsesToolChoiceObject.Serialization.cs b/src/Generated/Models/InternalResponsesToolChoiceObject.Serialization.cs index b59403728..7fce166f2 100644 --- a/src/Generated/Models/InternalResponsesToolChoiceObject.Serialization.cs +++ b/src/Generated/Models/InternalResponsesToolChoiceObject.Serialization.cs @@ -10,7 +10,7 @@ namespace OpenAI.Responses { - [PersistableModelProxy(typeof(UnknownResponsesToolChoiceObject))] + [PersistableModelProxy(typeof(InternalUnknownResponsesToolChoiceObject))] internal abstract partial class InternalResponsesToolChoiceObject : IJsonModel { internal InternalResponsesToolChoiceObject() @@ -90,7 +90,7 @@ internal static InternalResponsesToolChoiceObject DeserializeInternalResponsesTo return InternalResponsesToolChoiceObjectComputer.DeserializeInternalResponsesToolChoiceObjectComputer(element, options); } } - return UnknownResponsesToolChoiceObject.DeserializeUnknownResponsesToolChoiceObject(element, options); + return InternalUnknownResponsesToolChoiceObject.DeserializeInternalUnknownResponsesToolChoiceObject(element, options); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalResponsesUserMessage.Serialization.cs b/src/Generated/Models/InternalResponsesUserMessage.Serialization.cs index 91f13368e..7699f6542 100644 --- a/src/Generated/Models/InternalResponsesUserMessage.Serialization.cs +++ b/src/Generated/Models/InternalResponsesUserMessage.Serialization.cs @@ -67,7 +67,7 @@ internal static InternalResponsesUserMessage DeserializeInternalResponsesUserMes string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); MessageStatus? status = default; - MessageRole role = default; + InternalResponsesMessageRole internalRole = default; IList internalContent = default; foreach (var prop in element.EnumerateObject()) { @@ -92,7 +92,7 @@ internal static InternalResponsesUserMessage DeserializeInternalResponsesUserMes } if (prop.NameEquals("role"u8)) { - role = new MessageRole(prop.Value.GetString()); + internalRole = new InternalResponsesMessageRole(prop.Value.GetString()); continue; } if (prop.NameEquals("content"u8)) @@ -112,7 +112,7 @@ internal static InternalResponsesUserMessage DeserializeInternalResponsesUserMes id, additionalBinaryDataProperties, status, - role, + internalRole, internalContent); } diff --git a/src/Generated/Models/InternalResponsesUserMessage.cs b/src/Generated/Models/InternalResponsesUserMessage.cs index 426997a87..cf6508bea 100644 --- a/src/Generated/Models/InternalResponsesUserMessage.cs +++ b/src/Generated/Models/InternalResponsesUserMessage.cs @@ -4,13 +4,21 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenAI; namespace OpenAI.Responses { internal partial class InternalResponsesUserMessage : MessageResponseItem { - internal InternalResponsesUserMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, MessageRole role, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, role) + public InternalResponsesUserMessage(IEnumerable internalContent) : base(InternalResponsesMessageRole.User) + { + Argument.AssertNotNull(internalContent, nameof(internalContent)); + + InternalContent = internalContent.ToList(); + } + + internal InternalResponsesUserMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, InternalResponsesMessageRole internalRole, IList internalContent) : base(@type, id, additionalBinaryDataProperties, status, internalRole) { // Plugin customization: ensure initialization of collection InternalContent = internalContent ?? new ChangeTrackingList(); diff --git a/src/Generated/Models/InternalUnknownComparisonFilter.Serialization.cs b/src/Generated/Models/InternalUnknownComparisonFilter.Serialization.cs new file mode 100644 index 000000000..252bd0719 --- /dev/null +++ b/src/Generated/Models/InternalUnknownComparisonFilter.Serialization.cs @@ -0,0 +1,114 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownComparisonFilter : IJsonModel + { + internal InternalUnknownComparisonFilter() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalComparisonFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected override InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + + internal static InternalUnknownComparisonFilter DeserializeInternalUnknownComparisonFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalUnknownComparisonFilter(@type, key, value, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{options.Format}' format."); + } + } + + InternalComparisonFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected override InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/src/Generated/Models/InternalUnknownComparisonFilter.cs b/src/Generated/Models/InternalUnknownComparisonFilter.cs new file mode 100644 index 000000000..c5a1174da --- /dev/null +++ b/src/Generated/Models/InternalUnknownComparisonFilter.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownComparisonFilter : InternalComparisonFilter + { + internal InternalUnknownComparisonFilter(InternalComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", key, value, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalUnknownCompoundFilter.Serialization.cs b/src/Generated/Models/InternalUnknownCompoundFilter.Serialization.cs new file mode 100644 index 000000000..8f718057b --- /dev/null +++ b/src/Generated/Models/InternalUnknownCompoundFilter.Serialization.cs @@ -0,0 +1,120 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownCompoundFilter : IJsonModel + { + internal InternalUnknownCompoundFilter() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + InternalCompoundFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected override InternalCompoundFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + + internal static InternalUnknownCompoundFilter DeserializeInternalUnknownCompoundFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCompoundFilterType @type = default; + IList filters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalCompoundFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("filters"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + filters = array; + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new InternalUnknownCompoundFilter(@type, filters, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{options.Format}' format."); + } + } + + InternalCompoundFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected override InternalCompoundFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/src/Generated/Models/InternalUnknownCompoundFilter.cs b/src/Generated/Models/InternalUnknownCompoundFilter.cs new file mode 100644 index 000000000..5089c6ca0 --- /dev/null +++ b/src/Generated/Models/InternalUnknownCompoundFilter.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownCompoundFilter : InternalCompoundFilter + { + internal InternalUnknownCompoundFilter(InternalCompoundFilterType @type, IList filters, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", filters, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/UnknownResponsesContent.Serialization.cs b/src/Generated/Models/InternalUnknownResponsesContent.Serialization.cs similarity index 87% rename from src/Generated/Models/UnknownResponsesContent.Serialization.cs rename to src/Generated/Models/InternalUnknownResponsesContent.Serialization.cs index 59f4ac91c..4cd6c1165 100644 --- a/src/Generated/Models/UnknownResponsesContent.Serialization.cs +++ b/src/Generated/Models/InternalUnknownResponsesContent.Serialization.cs @@ -6,13 +6,13 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using OpenAI.Responses; +using OpenAI; -namespace OpenAI +namespace OpenAI.Responses { - internal partial class UnknownResponsesContent : IJsonModel + internal partial class InternalUnknownResponsesContent : IJsonModel { - internal UnknownResponsesContent() + internal InternalUnknownResponsesContent() { } @@ -46,24 +46,24 @@ protected override ResponseContentPart JsonModelCreateCore(ref Utf8JsonReader re return DeserializeResponseContentPart(document.RootElement, options); } - internal static UnknownResponsesContent DeserializeUnknownResponsesContent(JsonElement element, ModelReaderWriterOptions options) + internal static InternalUnknownResponsesContent DeserializeInternalUnknownResponsesContent(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - ResponseContentPartKind kind = default; + InternalResponsesContentType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - kind = prop.Value.GetString().ToResponseContentPartKind(); + internalType = new InternalResponsesContentType(prop.Value.GetString()); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new UnknownResponsesContent(kind, additionalBinaryDataProperties); + return new InternalUnknownResponsesContent(internalType, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalUnknownResponsesContent.cs b/src/Generated/Models/InternalUnknownResponsesContent.cs new file mode 100644 index 000000000..0d4a4e594 --- /dev/null +++ b/src/Generated/Models/InternalUnknownResponsesContent.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownResponsesContent : ResponseContentPart + { + internal InternalUnknownResponsesContent(InternalResponsesContentType internalType, IDictionary additionalBinaryDataProperties) : base(internalType != default ? internalType : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalUnknownResponsesMessage.Serialization.cs b/src/Generated/Models/InternalUnknownResponsesMessage.Serialization.cs index c2982532f..461cc35c1 100644 --- a/src/Generated/Models/InternalUnknownResponsesMessage.Serialization.cs +++ b/src/Generated/Models/InternalUnknownResponsesMessage.Serialization.cs @@ -56,7 +56,7 @@ internal static InternalUnknownResponsesMessage DeserializeInternalUnknownRespon string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); MessageStatus? status = default; - MessageRole role = default; + InternalResponsesMessageRole internalRole = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) @@ -80,12 +80,12 @@ internal static InternalUnknownResponsesMessage DeserializeInternalUnknownRespon } if (prop.NameEquals("role"u8)) { - role = new MessageRole(prop.Value.GetString()); + internalRole = new InternalResponsesMessageRole(prop.Value.GetString()); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalUnknownResponsesMessage(@type, id, additionalBinaryDataProperties, status, role); + return new InternalUnknownResponsesMessage(@type, id, additionalBinaryDataProperties, status, internalRole); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalUnknownResponsesMessage.cs b/src/Generated/Models/InternalUnknownResponsesMessage.cs index 346c0aae4..91f03ca20 100644 --- a/src/Generated/Models/InternalUnknownResponsesMessage.cs +++ b/src/Generated/Models/InternalUnknownResponsesMessage.cs @@ -9,7 +9,7 @@ namespace OpenAI.Responses { internal partial class InternalUnknownResponsesMessage : MessageResponseItem { - internal InternalUnknownResponsesMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, MessageRole role) : base(@type != default ? @type : "unknown", id, additionalBinaryDataProperties, status, role != default ? role : "unknown") + internal InternalUnknownResponsesMessage(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, InternalResponsesMessageRole internalRole) : base(@type != default ? @type : "unknown", id, additionalBinaryDataProperties, status, internalRole != default ? internalRole : "unknown") { } } diff --git a/src/Generated/Models/UnknownResponsesOutputTextAnnotation.Serialization.cs b/src/Generated/Models/InternalUnknownResponsesOutputTextAnnotation.Serialization.cs similarity index 89% rename from src/Generated/Models/UnknownResponsesOutputTextAnnotation.Serialization.cs rename to src/Generated/Models/InternalUnknownResponsesOutputTextAnnotation.Serialization.cs index 09eb45243..ae6216e55 100644 --- a/src/Generated/Models/UnknownResponsesOutputTextAnnotation.Serialization.cs +++ b/src/Generated/Models/InternalUnknownResponsesOutputTextAnnotation.Serialization.cs @@ -6,13 +6,13 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using OpenAI.Responses; +using OpenAI; -namespace OpenAI +namespace OpenAI.Responses { - internal partial class UnknownResponsesOutputTextAnnotation : IJsonModel + internal partial class InternalUnknownResponsesOutputTextAnnotation : IJsonModel { - internal UnknownResponsesOutputTextAnnotation() + internal InternalUnknownResponsesOutputTextAnnotation() { } @@ -46,7 +46,7 @@ protected override ResponseMessageAnnotation JsonModelCreateCore(ref Utf8JsonRea return DeserializeResponseMessageAnnotation(document.RootElement, options); } - internal static UnknownResponsesOutputTextAnnotation DeserializeUnknownResponsesOutputTextAnnotation(JsonElement element, ModelReaderWriterOptions options) + internal static InternalUnknownResponsesOutputTextAnnotation DeserializeInternalUnknownResponsesOutputTextAnnotation(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -63,7 +63,7 @@ internal static UnknownResponsesOutputTextAnnotation DeserializeUnknownResponses } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new UnknownResponsesOutputTextAnnotation(kind, additionalBinaryDataProperties); + return new InternalUnknownResponsesOutputTextAnnotation(kind, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalUnknownResponsesOutputTextAnnotation.cs b/src/Generated/Models/InternalUnknownResponsesOutputTextAnnotation.cs new file mode 100644 index 000000000..25aa8759f --- /dev/null +++ b/src/Generated/Models/InternalUnknownResponsesOutputTextAnnotation.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownResponsesOutputTextAnnotation : ResponseMessageAnnotation + { + internal InternalUnknownResponsesOutputTextAnnotation(ResponseMessageAnnotationKind kind, IDictionary additionalBinaryDataProperties) : base(kind, additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/UnknownResponsesReasoningItemSummaryElement.Serialization.cs b/src/Generated/Models/InternalUnknownResponsesReasoningItemSummaryElement.Serialization.cs similarity index 89% rename from src/Generated/Models/UnknownResponsesReasoningItemSummaryElement.Serialization.cs rename to src/Generated/Models/InternalUnknownResponsesReasoningItemSummaryElement.Serialization.cs index 32c3962a8..7217d1140 100644 --- a/src/Generated/Models/UnknownResponsesReasoningItemSummaryElement.Serialization.cs +++ b/src/Generated/Models/InternalUnknownResponsesReasoningItemSummaryElement.Serialization.cs @@ -6,13 +6,13 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using OpenAI.Responses; +using OpenAI; -namespace OpenAI +namespace OpenAI.Responses { - internal partial class UnknownResponsesReasoningItemSummaryElement : IJsonModel + internal partial class InternalUnknownResponsesReasoningItemSummaryElement : IJsonModel { - internal UnknownResponsesReasoningItemSummaryElement() + internal InternalUnknownResponsesReasoningItemSummaryElement() { } @@ -46,7 +46,7 @@ protected override InternalResponsesReasoningItemSummaryElement JsonModelCreateC return DeserializeInternalResponsesReasoningItemSummaryElement(document.RootElement, options); } - internal static UnknownResponsesReasoningItemSummaryElement DeserializeUnknownResponsesReasoningItemSummaryElement(JsonElement element, ModelReaderWriterOptions options) + internal static InternalUnknownResponsesReasoningItemSummaryElement DeserializeInternalUnknownResponsesReasoningItemSummaryElement(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -63,7 +63,7 @@ internal static UnknownResponsesReasoningItemSummaryElement DeserializeUnknownRe } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new UnknownResponsesReasoningItemSummaryElement(@type, additionalBinaryDataProperties); + return new InternalUnknownResponsesReasoningItemSummaryElement(@type, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalUnknownResponsesReasoningItemSummaryElement.cs b/src/Generated/Models/InternalUnknownResponsesReasoningItemSummaryElement.cs new file mode 100644 index 000000000..89ebaabec --- /dev/null +++ b/src/Generated/Models/InternalUnknownResponsesReasoningItemSummaryElement.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownResponsesReasoningItemSummaryElement : InternalResponsesReasoningItemSummaryElement + { + internal InternalUnknownResponsesReasoningItemSummaryElement(InternalResponsesReasoningItemSummaryType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/InternalUnknownResponsesTextFormat.Serialization.cs b/src/Generated/Models/InternalUnknownResponsesTextFormat.Serialization.cs index 486875aaa..3b697ebfe 100644 --- a/src/Generated/Models/InternalUnknownResponsesTextFormat.Serialization.cs +++ b/src/Generated/Models/InternalUnknownResponsesTextFormat.Serialization.cs @@ -52,18 +52,18 @@ internal static InternalUnknownResponsesTextFormat DeserializeInternalUnknownRes { return null; } - InternalResponsesTextFormatType @type = default; + InternalResponsesTextFormatType internalType = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - @type = new InternalResponsesTextFormatType(prop.Value.GetString()); + internalType = new InternalResponsesTextFormatType(prop.Value.GetString()); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalUnknownResponsesTextFormat(@type, additionalBinaryDataProperties); + return new InternalUnknownResponsesTextFormat(internalType, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalUnknownResponsesTextFormat.cs b/src/Generated/Models/InternalUnknownResponsesTextFormat.cs index a8cc63802..ca2dd3a28 100644 --- a/src/Generated/Models/InternalUnknownResponsesTextFormat.cs +++ b/src/Generated/Models/InternalUnknownResponsesTextFormat.cs @@ -9,7 +9,7 @@ namespace OpenAI.Responses { internal partial class InternalUnknownResponsesTextFormat : ResponseTextFormat { - internal InternalUnknownResponsesTextFormat(InternalResponsesTextFormatType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + internal InternalUnknownResponsesTextFormat(InternalResponsesTextFormatType internalType, IDictionary additionalBinaryDataProperties) : base(internalType != default ? internalType : "unknown", additionalBinaryDataProperties) { } } diff --git a/src/Generated/Models/UnknownResponsesToolChoiceObject.Serialization.cs b/src/Generated/Models/InternalUnknownResponsesToolChoiceObject.Serialization.cs similarity index 90% rename from src/Generated/Models/UnknownResponsesToolChoiceObject.Serialization.cs rename to src/Generated/Models/InternalUnknownResponsesToolChoiceObject.Serialization.cs index 63bb2b90e..c701297c9 100644 --- a/src/Generated/Models/UnknownResponsesToolChoiceObject.Serialization.cs +++ b/src/Generated/Models/InternalUnknownResponsesToolChoiceObject.Serialization.cs @@ -6,13 +6,13 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using OpenAI.Responses; +using OpenAI; -namespace OpenAI +namespace OpenAI.Responses { - internal partial class UnknownResponsesToolChoiceObject : IJsonModel + internal partial class InternalUnknownResponsesToolChoiceObject : IJsonModel { - internal UnknownResponsesToolChoiceObject() + internal InternalUnknownResponsesToolChoiceObject() { } @@ -46,7 +46,7 @@ protected override InternalResponsesToolChoiceObject JsonModelCreateCore(ref Utf return DeserializeInternalResponsesToolChoiceObject(document.RootElement, options); } - internal static UnknownResponsesToolChoiceObject DeserializeUnknownResponsesToolChoiceObject(JsonElement element, ModelReaderWriterOptions options) + internal static InternalUnknownResponsesToolChoiceObject DeserializeInternalUnknownResponsesToolChoiceObject(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -63,7 +63,7 @@ internal static UnknownResponsesToolChoiceObject DeserializeUnknownResponsesTool } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new UnknownResponsesToolChoiceObject(@type, additionalBinaryDataProperties); + return new InternalUnknownResponsesToolChoiceObject(@type, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalUnknownResponsesToolChoiceObject.cs b/src/Generated/Models/InternalUnknownResponsesToolChoiceObject.cs new file mode 100644 index 000000000..6d6b4dac8 --- /dev/null +++ b/src/Generated/Models/InternalUnknownResponsesToolChoiceObject.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownResponsesToolChoiceObject : InternalResponsesToolChoiceObject + { + internal InternalUnknownResponsesToolChoiceObject(InternalResponsesToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/UnknownResponsesWebSearchLocation.Serialization.cs b/src/Generated/Models/InternalUnknownResponsesWebSearchLocation.Serialization.cs similarity index 89% rename from src/Generated/Models/UnknownResponsesWebSearchLocation.Serialization.cs rename to src/Generated/Models/InternalUnknownResponsesWebSearchLocation.Serialization.cs index cae3f08a4..dc166cec2 100644 --- a/src/Generated/Models/UnknownResponsesWebSearchLocation.Serialization.cs +++ b/src/Generated/Models/InternalUnknownResponsesWebSearchLocation.Serialization.cs @@ -6,13 +6,13 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using OpenAI.Responses; +using OpenAI; -namespace OpenAI +namespace OpenAI.Responses { - internal partial class UnknownResponsesWebSearchLocation : IJsonModel + internal partial class InternalUnknownResponsesWebSearchLocation : IJsonModel { - internal UnknownResponsesWebSearchLocation() + internal InternalUnknownResponsesWebSearchLocation() { } @@ -46,7 +46,7 @@ protected override WebSearchToolLocation JsonModelCreateCore(ref Utf8JsonReader return DeserializeWebSearchToolLocation(document.RootElement, options); } - internal static UnknownResponsesWebSearchLocation DeserializeUnknownResponsesWebSearchLocation(JsonElement element, ModelReaderWriterOptions options) + internal static InternalUnknownResponsesWebSearchLocation DeserializeInternalUnknownResponsesWebSearchLocation(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -63,7 +63,7 @@ internal static UnknownResponsesWebSearchLocation DeserializeUnknownResponsesWeb } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new UnknownResponsesWebSearchLocation(@type, additionalBinaryDataProperties); + return new InternalUnknownResponsesWebSearchLocation(@type, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/InternalUnknownResponsesWebSearchLocation.cs b/src/Generated/Models/InternalUnknownResponsesWebSearchLocation.cs new file mode 100644 index 000000000..d6481ce12 --- /dev/null +++ b/src/Generated/Models/InternalUnknownResponsesWebSearchLocation.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + internal partial class InternalUnknownResponsesWebSearchLocation : WebSearchToolLocation + { + internal InternalUnknownResponsesWebSearchLocation(string @type, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/src/Generated/Models/MessageResponseItem.Serialization.cs b/src/Generated/Models/MessageResponseItem.Serialization.cs index ced07c75b..15b31bdbf 100644 --- a/src/Generated/Models/MessageResponseItem.Serialization.cs +++ b/src/Generated/Models/MessageResponseItem.Serialization.cs @@ -39,7 +39,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (_additionalBinaryDataProperties?.ContainsKey("role") != true) { writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToString()); + writer.WriteStringValue(InternalRole.ToString()); } } diff --git a/src/Generated/Models/MessageResponseItem.cs b/src/Generated/Models/MessageResponseItem.cs index 6231e6947..bfb6fbff2 100644 --- a/src/Generated/Models/MessageResponseItem.cs +++ b/src/Generated/Models/MessageResponseItem.cs @@ -9,15 +9,10 @@ namespace OpenAI.Responses { public partial class MessageResponseItem : ResponseItem { - public MessageResponseItem(MessageRole role) : base(InternalResponsesItemType.Message) - { - Role = role; - } - - internal MessageResponseItem(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, MessageRole role) : base(@type, id, additionalBinaryDataProperties) + internal MessageResponseItem(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, MessageStatus? status, InternalResponsesMessageRole internalRole) : base(@type, id, additionalBinaryDataProperties) { Status = status; - Role = role; + InternalRole = internalRole; } public MessageStatus? Status { get; } diff --git a/src/Generated/Models/MessageRole.cs b/src/Generated/Models/MessageRole.cs deleted file mode 100644 index 021ea8070..000000000 --- a/src/Generated/Models/MessageRole.cs +++ /dev/null @@ -1,50 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Responses -{ - public readonly partial struct MessageRole : IEquatable - { - private readonly string _value; - private const string SystemValue = "system"; - private const string DeveloperValue = "developer"; - private const string UserValue = "user"; - private const string AssistantValue = "assistant"; - - public MessageRole(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static MessageRole System { get; } = new MessageRole(SystemValue); - - public static MessageRole Developer { get; } = new MessageRole(DeveloperValue); - - public static MessageRole User { get; } = new MessageRole(UserValue); - - public static MessageRole Assistant { get; } = new MessageRole(AssistantValue); - - public static bool operator ==(MessageRole left, MessageRole right) => left.Equals(right); - - public static bool operator !=(MessageRole left, MessageRole right) => !left.Equals(right); - - public static implicit operator MessageRole(string value) => new MessageRole(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageRole other && Equals(other); - - public bool Equals(MessageRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/src/Generated/Models/OpenAIResponse.Serialization.cs b/src/Generated/Models/OpenAIResponse.Serialization.cs index c22bd1af7..4104cf5cd 100644 --- a/src/Generated/Models/OpenAIResponse.Serialization.cs +++ b/src/Generated/Models/OpenAIResponse.Serialization.cs @@ -92,18 +92,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("temperature"u8); writer.WriteNumberValue(Temperature); } - if (_additionalBinaryDataProperties?.ContainsKey("tool_choice") != true) - { - writer.WritePropertyName("tool_choice"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ToolChoice); -#else - using (JsonDocument document = JsonDocument.Parse(ToolChoice)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } if (_additionalBinaryDataProperties?.ContainsKey("tools") != true) { writer.WritePropertyName("tools"u8); @@ -202,7 +190,12 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("parallel_tool_calls") != true) { writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(AllowParallelToolCalls); + writer.WriteBooleanValue(ParallelToolCallsEnabled); + } + if (_additionalBinaryDataProperties?.ContainsKey("tool_choice") != true) + { + writer.WritePropertyName("tool_choice"u8); + writer.WriteObjectValue(ToolChoice, options); } if (_additionalBinaryDataProperties != null) { @@ -252,7 +245,6 @@ internal static OpenAIResponse DeserializeOpenAIResponse(JsonElement element, Mo string model = default; string previousResponseId = default; float temperature = default; - BinaryData toolChoice = default; IList tools = default; float topP = default; ResponseTokenUsage usage = default; @@ -265,7 +257,8 @@ internal static OpenAIResponse DeserializeOpenAIResponse(JsonElement element, Mo ResponseTruncationMode? truncationMode = default; ResponseIncompleteStatusDetails incompleteStatusDetails = default; IList outputItems = default; - bool allowParallelToolCalls = default; + bool parallelToolCallsEnabled = default; + ResponseToolChoice toolChoice = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -328,11 +321,6 @@ internal static OpenAIResponse DeserializeOpenAIResponse(JsonElement element, Mo temperature = prop.Value.GetSingle(); continue; } - if (prop.NameEquals("tool_choice"u8)) - { - toolChoice = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } if (prop.NameEquals("tools"u8)) { List array = new List(); @@ -450,7 +438,12 @@ internal static OpenAIResponse DeserializeOpenAIResponse(JsonElement element, Mo } if (prop.NameEquals("parallel_tool_calls"u8)) { - allowParallelToolCalls = prop.Value.GetBoolean(); + parallelToolCallsEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("tool_choice"u8)) + { + toolChoice = ResponseToolChoice.DeserializeResponseToolChoice(prop.Value, options); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -464,7 +457,6 @@ internal static OpenAIResponse DeserializeOpenAIResponse(JsonElement element, Mo model, previousResponseId, temperature, - toolChoice, tools, topP, usage, @@ -477,7 +469,8 @@ internal static OpenAIResponse DeserializeOpenAIResponse(JsonElement element, Mo truncationMode, incompleteStatusDetails, outputItems, - allowParallelToolCalls, + parallelToolCallsEnabled, + toolChoice, additionalBinaryDataProperties); } diff --git a/src/Generated/Models/OpenAIResponse.cs b/src/Generated/Models/OpenAIResponse.cs index 1c1f591d1..4b819b70b 100644 --- a/src/Generated/Models/OpenAIResponse.cs +++ b/src/Generated/Models/OpenAIResponse.cs @@ -12,7 +12,7 @@ public partial class OpenAIResponse { private protected IDictionary _additionalBinaryDataProperties; - internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseError error, string instructions, string model, string previousResponseId, float temperature, BinaryData toolChoice, IEnumerable tools, float topP, IDictionary metadata, ResponseIncompleteStatusDetails incompleteStatusDetails, IEnumerable outputItems, bool allowParallelToolCalls) + internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseError error, string instructions, string model, string previousResponseId, float temperature, IEnumerable tools, float topP, IDictionary metadata, ResponseIncompleteStatusDetails incompleteStatusDetails, IEnumerable outputItems, bool parallelToolCallsEnabled, ResponseToolChoice toolChoice) { Id = id; CreatedAt = createdAt; @@ -21,16 +21,16 @@ internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseError error Model = model; PreviousResponseId = previousResponseId; Temperature = temperature; - ToolChoice = toolChoice; Tools = tools.ToList(); TopP = topP; Metadata = metadata; IncompleteStatusDetails = incompleteStatusDetails; OutputItems = outputItems.ToList(); - AllowParallelToolCalls = allowParallelToolCalls; + ParallelToolCallsEnabled = parallelToolCallsEnabled; + ToolChoice = toolChoice; } - internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseStatus? status, ResponseError error, string instructions, string model, string previousResponseId, float temperature, BinaryData toolChoice, IList tools, float topP, ResponseTokenUsage usage, IDictionary metadata, InternalCreateResponsesResponseObject @object, string endUserId, ResponseReasoningOptions reasoningOptions, int? maxOutputTokenCount, ResponseTextOptions textOptions, ResponseTruncationMode? truncationMode, ResponseIncompleteStatusDetails incompleteStatusDetails, IList outputItems, bool allowParallelToolCalls, IDictionary additionalBinaryDataProperties) + internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseStatus? status, ResponseError error, string instructions, string model, string previousResponseId, float temperature, IList tools, float topP, ResponseTokenUsage usage, IDictionary metadata, InternalCreateResponsesResponseObject @object, string endUserId, ResponseReasoningOptions reasoningOptions, int? maxOutputTokenCount, ResponseTextOptions textOptions, ResponseTruncationMode? truncationMode, ResponseIncompleteStatusDetails incompleteStatusDetails, IList outputItems, bool parallelToolCallsEnabled, ResponseToolChoice toolChoice, IDictionary additionalBinaryDataProperties) { Id = id; CreatedAt = createdAt; @@ -40,7 +40,6 @@ internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseStatus? sta Model = model; PreviousResponseId = previousResponseId; Temperature = temperature; - ToolChoice = toolChoice; Tools = tools; TopP = topP; Usage = usage; @@ -53,7 +52,8 @@ internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseStatus? sta TruncationMode = truncationMode; IncompleteStatusDetails = incompleteStatusDetails; OutputItems = outputItems; - AllowParallelToolCalls = allowParallelToolCalls; + ParallelToolCallsEnabled = parallelToolCallsEnabled; + ToolChoice = toolChoice; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -73,8 +73,6 @@ internal OpenAIResponse(string id, DateTimeOffset createdAt, ResponseStatus? sta public float Temperature { get; } - public BinaryData ToolChoice { get; } - public IList Tools { get; } public float TopP { get; } diff --git a/src/Generated/Models/ResponseContentPart.Serialization.cs b/src/Generated/Models/ResponseContentPart.Serialization.cs index 1f1aa1e9d..c07bb09ba 100644 --- a/src/Generated/Models/ResponseContentPart.Serialization.cs +++ b/src/Generated/Models/ResponseContentPart.Serialization.cs @@ -33,7 +33,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("type") != true) { writer.WritePropertyName("type"u8); - writer.WriteStringValue(Kind.ToSerialString()); + writer.WriteStringValue(InternalType.ToString()); } if (_additionalBinaryDataProperties != null) { @@ -91,7 +91,7 @@ internal static ResponseContentPart DeserializeResponseContentPart(JsonElement e return InternalResponsesOutputRefusalContentPart.DeserializeInternalResponsesOutputRefusalContentPart(element, options); } } - return UnknownResponsesContent.DeserializeUnknownResponsesContent(element, options); + return InternalUnknownResponsesContent.DeserializeInternalUnknownResponsesContent(element, options); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/ResponseContentPart.cs b/src/Generated/Models/ResponseContentPart.cs index 52c5cd460..3e5c2d130 100644 --- a/src/Generated/Models/ResponseContentPart.cs +++ b/src/Generated/Models/ResponseContentPart.cs @@ -11,14 +11,14 @@ public partial class ResponseContentPart { private protected IDictionary _additionalBinaryDataProperties; - private protected ResponseContentPart(ResponseContentPartKind kind) + private protected ResponseContentPart(InternalResponsesContentType internalType) { - Kind = kind; + InternalType = internalType; } - internal ResponseContentPart(ResponseContentPartKind kind, IDictionary additionalBinaryDataProperties) + internal ResponseContentPart(InternalResponsesContentType internalType, IDictionary additionalBinaryDataProperties) { - Kind = kind; + InternalType = internalType; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/src/Generated/Models/ResponseContentPartKind.Serialization.cs b/src/Generated/Models/ResponseContentPartKind.Serialization.cs deleted file mode 100644 index dea45607c..000000000 --- a/src/Generated/Models/ResponseContentPartKind.Serialization.cs +++ /dev/null @@ -1,46 +0,0 @@ -// - -#nullable disable - -using System; - -namespace OpenAI.Responses -{ - internal static partial class ResponseContentPartKindExtensions - { - public static string ToSerialString(this ResponseContentPartKind value) => value switch - { - ResponseContentPartKind.InputText => "input_text", - ResponseContentPartKind.InputImage => "input_image", - ResponseContentPartKind.InputFile => "input_file", - ResponseContentPartKind.OutputText => "output_text", - ResponseContentPartKind.Refusal => "refusal", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseContentPartKind value.") - }; - - public static ResponseContentPartKind ToResponseContentPartKind(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_text")) - { - return ResponseContentPartKind.InputText; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_image")) - { - return ResponseContentPartKind.InputImage; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_file")) - { - return ResponseContentPartKind.InputFile; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "output_text")) - { - return ResponseContentPartKind.OutputText; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "refusal")) - { - return ResponseContentPartKind.Refusal; - } - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseContentPartKind value."); - } - } -} diff --git a/src/Generated/Models/ResponseCreationOptions.Serialization.cs b/src/Generated/Models/ResponseCreationOptions.Serialization.cs index 2ec93c9f4..8f555d164 100644 --- a/src/Generated/Models/ResponseCreationOptions.Serialization.cs +++ b/src/Generated/Models/ResponseCreationOptions.Serialization.cs @@ -63,28 +63,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("instructions"u8); writer.WriteStringValue(Instructions); } - if (Optional.IsCollectionDefined(Tools) && _additionalBinaryDataProperties?.ContainsKey("tools") != true) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (ResponseTool item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(ToolChoice) && _additionalBinaryDataProperties?.ContainsKey("tool_choice") != true) - { - writer.WritePropertyName("tool_choice"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ToolChoice); -#else - using (JsonDocument document = JsonDocument.Parse(ToolChoice)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } if (Optional.IsCollectionDefined(Include) && _additionalBinaryDataProperties?.ContainsKey("include") != true) { writer.WritePropertyName("include"u8); @@ -140,16 +118,31 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("truncation"u8); writer.WriteStringValue(TruncationMode.Value.ToString()); } - if (Optional.IsDefined(AllowParallelToolCalls) && _additionalBinaryDataProperties?.ContainsKey("parallel_tool_calls") != true) + if (Optional.IsDefined(ParallelToolCallsEnabled) && _additionalBinaryDataProperties?.ContainsKey("parallel_tool_calls") != true) { writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(AllowParallelToolCalls.Value); + writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); } if (Optional.IsDefined(StoredOutputEnabled) && _additionalBinaryDataProperties?.ContainsKey("store") != true) { writer.WritePropertyName("store"u8); writer.WriteBooleanValue(StoredOutputEnabled.Value); } + if (Optional.IsDefined(ToolChoice) && _additionalBinaryDataProperties?.ContainsKey("tool_choice") != true) + { + writer.WritePropertyName("tool_choice"u8); + writer.WriteObjectValue(ToolChoice, options); + } + if (Optional.IsCollectionDefined(Tools) && _additionalBinaryDataProperties?.ContainsKey("tools") != true) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (ResponseTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } if (_additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -195,8 +188,6 @@ internal static ResponseCreationOptions DeserializeResponseCreationOptions(JsonE float? topP = default; string previousResponseId = default; string instructions = default; - IList tools = default; - BinaryData toolChoice = default; IList include = default; InternalCreateResponsesRequestModel model = default; IList input = default; @@ -206,8 +197,10 @@ internal static ResponseCreationOptions DeserializeResponseCreationOptions(JsonE int? maxOutputTokenCount = default; ResponseTextOptions textOptions = default; ResponseTruncationMode? truncationMode = default; - bool? allowParallelToolCalls = default; + bool? parallelToolCallsEnabled = default; bool? storedOutputEnabled = default; + ResponseToolChoice toolChoice = default; + IList tools = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -272,29 +265,6 @@ internal static ResponseCreationOptions DeserializeResponseCreationOptions(JsonE instructions = prop.Value.GetString(); continue; } - if (prop.NameEquals("tools"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in prop.Value.EnumerateArray()) - { - array.Add(ResponseTool.DeserializeResponseTool(item, options)); - } - tools = array; - continue; - } - if (prop.NameEquals("tool_choice"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - toolChoice = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } if (prop.NameEquals("include"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -381,10 +351,10 @@ internal static ResponseCreationOptions DeserializeResponseCreationOptions(JsonE { if (prop.Value.ValueKind == JsonValueKind.Null) { - allowParallelToolCalls = null; + parallelToolCallsEnabled = null; continue; } - allowParallelToolCalls = prop.Value.GetBoolean(); + parallelToolCallsEnabled = prop.Value.GetBoolean(); continue; } if (prop.NameEquals("store"u8)) @@ -397,6 +367,29 @@ internal static ResponseCreationOptions DeserializeResponseCreationOptions(JsonE storedOutputEnabled = prop.Value.GetBoolean(); continue; } + if (prop.NameEquals("tool_choice"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + toolChoice = ResponseToolChoice.DeserializeResponseToolChoice(prop.Value, options); + continue; + } + if (prop.NameEquals("tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ResponseTool.DeserializeResponseTool(item, options)); + } + tools = array; + continue; + } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } return new ResponseCreationOptions( @@ -405,8 +398,6 @@ internal static ResponseCreationOptions DeserializeResponseCreationOptions(JsonE topP, previousResponseId, instructions, - tools ?? new ChangeTrackingList(), - toolChoice, include ?? new ChangeTrackingList(), model, input, @@ -416,8 +407,10 @@ internal static ResponseCreationOptions DeserializeResponseCreationOptions(JsonE maxOutputTokenCount, textOptions, truncationMode, - allowParallelToolCalls, + parallelToolCallsEnabled, storedOutputEnabled, + toolChoice, + tools ?? new ChangeTrackingList(), additionalBinaryDataProperties); } diff --git a/src/Generated/Models/ResponseCreationOptions.cs b/src/Generated/Models/ResponseCreationOptions.cs index e67f79cb5..e5d478e1e 100644 --- a/src/Generated/Models/ResponseCreationOptions.cs +++ b/src/Generated/Models/ResponseCreationOptions.cs @@ -11,15 +11,13 @@ public partial class ResponseCreationOptions { private protected IDictionary _additionalBinaryDataProperties; - internal ResponseCreationOptions(IDictionary metadata, float? temperature, float? topP, string previousResponseId, string instructions, IList tools, BinaryData toolChoice, IList include, InternalCreateResponsesRequestModel model, IList input, bool? stream, string endUserId, ResponseReasoningOptions reasoningOptions, int? maxOutputTokenCount, ResponseTextOptions textOptions, ResponseTruncationMode? truncationMode, bool? allowParallelToolCalls, bool? storedOutputEnabled, IDictionary additionalBinaryDataProperties) + internal ResponseCreationOptions(IDictionary metadata, float? temperature, float? topP, string previousResponseId, string instructions, IList include, InternalCreateResponsesRequestModel model, IList input, bool? stream, string endUserId, ResponseReasoningOptions reasoningOptions, int? maxOutputTokenCount, ResponseTextOptions textOptions, ResponseTruncationMode? truncationMode, bool? parallelToolCallsEnabled, bool? storedOutputEnabled, ResponseToolChoice toolChoice, IList tools, IDictionary additionalBinaryDataProperties) { Metadata = metadata; Temperature = temperature; TopP = topP; PreviousResponseId = previousResponseId; Instructions = instructions; - Tools = tools; - ToolChoice = toolChoice; Include = include; Model = model; Input = input; @@ -29,8 +27,10 @@ internal ResponseCreationOptions(IDictionary metadata, float? te MaxOutputTokenCount = maxOutputTokenCount; TextOptions = textOptions; TruncationMode = truncationMode; - AllowParallelToolCalls = allowParallelToolCalls; + ParallelToolCallsEnabled = parallelToolCallsEnabled; StoredOutputEnabled = storedOutputEnabled; + ToolChoice = toolChoice; + Tools = tools; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -44,10 +44,6 @@ internal ResponseCreationOptions(IDictionary metadata, float? te public string Instructions { get; set; } - public IList Tools { get; set; } - - public BinaryData ToolChoice { get; set; } - internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/src/Generated/Models/ResponseMessageAnnotation.Serialization.cs b/src/Generated/Models/ResponseMessageAnnotation.Serialization.cs index bc929438d..389756d19 100644 --- a/src/Generated/Models/ResponseMessageAnnotation.Serialization.cs +++ b/src/Generated/Models/ResponseMessageAnnotation.Serialization.cs @@ -87,7 +87,7 @@ internal static ResponseMessageAnnotation DeserializeResponseMessageAnnotation(J return InternalResponsesMessageAnnotationFilePath.DeserializeInternalResponsesMessageAnnotationFilePath(element, options); } } - return UnknownResponsesOutputTextAnnotation.DeserializeUnknownResponsesOutputTextAnnotation(element, options); + return InternalUnknownResponsesOutputTextAnnotation.DeserializeInternalUnknownResponsesOutputTextAnnotation(element, options); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/ResponseTextFormat.Serialization.cs b/src/Generated/Models/ResponseTextFormat.Serialization.cs index 8cdb79b8c..c1250a278 100644 --- a/src/Generated/Models/ResponseTextFormat.Serialization.cs +++ b/src/Generated/Models/ResponseTextFormat.Serialization.cs @@ -33,7 +33,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("type") != true) { writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); + writer.WriteStringValue(InternalType.ToString()); } if (_additionalBinaryDataProperties != null) { diff --git a/src/Generated/Models/ResponseTextFormat.cs b/src/Generated/Models/ResponseTextFormat.cs index c1f994a74..0f64245e7 100644 --- a/src/Generated/Models/ResponseTextFormat.cs +++ b/src/Generated/Models/ResponseTextFormat.cs @@ -11,19 +11,17 @@ public partial class ResponseTextFormat { private protected IDictionary _additionalBinaryDataProperties; - private protected ResponseTextFormat(InternalResponsesTextFormatType @type) + private protected ResponseTextFormat(InternalResponsesTextFormatType internalType) { - Type = @type; + InternalType = internalType; } - internal ResponseTextFormat(InternalResponsesTextFormatType @type, IDictionary additionalBinaryDataProperties) + internal ResponseTextFormat(InternalResponsesTextFormatType internalType, IDictionary additionalBinaryDataProperties) { - Type = @type; + InternalType = internalType; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - internal InternalResponsesTextFormatType Type { get; set; } - internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/src/Generated/Models/ResponseTextOptions.Serialization.cs b/src/Generated/Models/ResponseTextOptions.Serialization.cs index 6da104a8d..6c897d365 100644 --- a/src/Generated/Models/ResponseTextOptions.Serialization.cs +++ b/src/Generated/Models/ResponseTextOptions.Serialization.cs @@ -27,10 +27,10 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(ResponseTextOptions)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ResponseFormat) && _additionalBinaryDataProperties?.ContainsKey("format") != true) + if (Optional.IsDefined(TextFormat) && _additionalBinaryDataProperties?.ContainsKey("format") != true) { writer.WritePropertyName("format"u8); - writer.WriteObjectValue(ResponseFormat, options); + writer.WriteObjectValue(TextFormat, options); } if (_additionalBinaryDataProperties != null) { @@ -72,7 +72,7 @@ internal static ResponseTextOptions DeserializeResponseTextOptions(JsonElement e { return null; } - ResponseTextFormat responseFormat = default; + ResponseTextFormat textFormat = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -82,12 +82,12 @@ internal static ResponseTextOptions DeserializeResponseTextOptions(JsonElement e { continue; } - responseFormat = ResponseTextFormat.DeserializeResponseTextFormat(prop.Value, options); + textFormat = ResponseTextFormat.DeserializeResponseTextFormat(prop.Value, options); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new ResponseTextOptions(responseFormat, additionalBinaryDataProperties); + return new ResponseTextOptions(textFormat, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/ResponseTextOptions.cs b/src/Generated/Models/ResponseTextOptions.cs index b85d11dce..02bcccb2b 100644 --- a/src/Generated/Models/ResponseTextOptions.cs +++ b/src/Generated/Models/ResponseTextOptions.cs @@ -15,9 +15,9 @@ public ResponseTextOptions() { } - internal ResponseTextOptions(ResponseTextFormat responseFormat, IDictionary additionalBinaryDataProperties) + internal ResponseTextOptions(ResponseTextFormat textFormat, IDictionary additionalBinaryDataProperties) { - ResponseFormat = responseFormat; + TextFormat = textFormat; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs b/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs index c3966f662..8ee89e924 100644 --- a/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs +++ b/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs @@ -176,7 +176,6 @@ internal static StreamingChatCompletionUpdate DeserializeStreamingChatCompletion { if (prop.Value.ValueKind == JsonValueKind.Null) { - usage = null; continue; } usage = ChatTokenUsage.DeserializeChatTokenUsage(prop.Value, options); diff --git a/src/Generated/Models/StreamingResponseCompletedUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseCompletedUpdate.Serialization.cs new file mode 100644 index 000000000..7297283f7 --- /dev/null +++ b/src/Generated/Models/StreamingResponseCompletedUpdate.Serialization.cs @@ -0,0 +1,130 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseCompletedUpdate : IJsonModel + { + internal StreamingResponseCompletedUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseCompletedUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("response") != true) + { + writer.WritePropertyName("response"u8); + writer.WriteObjectValue(Response, options); + } + } + + StreamingResponseCompletedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseCompletedUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseCompletedUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseCompletedUpdate(document.RootElement, options); + } + + internal static StreamingResponseCompletedUpdate DeserializeStreamingResponseCompletedUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenAIResponse response = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("response"u8)) + { + response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseCompletedUpdate(@type, additionalBinaryDataProperties, response); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseCompletedUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseCompletedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseCompletedUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseCompletedUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseCompletedUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseCompletedUpdate streamingResponseCompletedUpdate) + { + if (streamingResponseCompletedUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseCompletedUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseCompletedUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseCompletedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseCompletedUpdate.cs b/src/Generated/Models/StreamingResponseCompletedUpdate.cs new file mode 100644 index 000000000..e42c6f784 --- /dev/null +++ b/src/Generated/Models/StreamingResponseCompletedUpdate.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseCompletedUpdate : StreamingResponseUpdate + { + internal StreamingResponseCompletedUpdate(OpenAIResponse response) : base(InternalResponsesResponseStreamEventType.ResponseCompleted) + { + Response = response; + } + + internal StreamingResponseCompletedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(@type, additionalBinaryDataProperties) + { + Response = response; + } + + public OpenAIResponse Response { get; } + } +} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartAdded.Serialization.cs b/src/Generated/Models/StreamingResponseContentPartAddedUpdate.Serialization.cs similarity index 55% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartAdded.Serialization.cs rename to src/Generated/Models/StreamingResponseContentPartAddedUpdate.Serialization.cs index 574f80edc..b766b7d42 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartAdded.Serialization.cs +++ b/src/Generated/Models/StreamingResponseContentPartAddedUpdate.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseContentPartAdded : IJsonModel + public partial class StreamingResponseContentPartAddedUpdate : IJsonModel { - internal InternalResponsesResponseStreamEventResponseContentPartAdded() + internal StreamingResponseContentPartAddedUpdate() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Wr protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartAdded)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartAddedUpdate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) @@ -54,26 +54,26 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - InternalResponsesResponseStreamEventResponseContentPartAdded IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseContentPartAdded)JsonModelCreateCore(ref reader, options); + StreamingResponseContentPartAddedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseContentPartAddedUpdate)JsonModelCreateCore(ref reader, options); protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartAdded)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartAddedUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseContentPartAdded(document.RootElement, options); + return DeserializeStreamingResponseContentPartAddedUpdate(document.RootElement, options); } - internal static InternalResponsesResponseStreamEventResponseContentPartAdded DeserializeInternalResponsesResponseStreamEventResponseContentPartAdded(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingResponseContentPartAddedUpdate DeserializeStreamingResponseContentPartAddedUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string itemId = default; int outputIndex = default; @@ -83,7 +83,7 @@ internal static InternalResponsesResponseStreamEventResponseContentPartAdded Des { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("item_id"u8)) @@ -108,8 +108,8 @@ internal static InternalResponsesResponseStreamEventResponseContentPartAdded Des } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesResponseStreamEventResponseContentPartAdded( - kind, + return new StreamingResponseContentPartAddedUpdate( + @type, additionalBinaryDataProperties, itemId, outputIndex, @@ -117,53 +117,53 @@ internal static InternalResponsesResponseStreamEventResponseContentPartAdded Des part); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartAdded)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartAddedUpdate)} does not support writing '{options.Format}' format."); } } - InternalResponsesResponseStreamEventResponseContentPartAdded IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseContentPartAdded)PersistableModelCreateCore(data, options); + StreamingResponseContentPartAddedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseContentPartAddedUpdate)PersistableModelCreateCore(data, options); protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalResponsesResponseStreamEventResponseContentPartAdded(document.RootElement, options); + return DeserializeStreamingResponseContentPartAddedUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartAdded)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartAddedUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseContentPartAdded internalResponsesResponseStreamEventResponseContentPartAdded) + public static implicit operator BinaryContent(StreamingResponseContentPartAddedUpdate streamingResponseContentPartAddedUpdate) { - if (internalResponsesResponseStreamEventResponseContentPartAdded == null) + if (streamingResponseContentPartAddedUpdate == null) { return null; } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseContentPartAdded, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingResponseContentPartAddedUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalResponsesResponseStreamEventResponseContentPartAdded(ClientResult result) + public static explicit operator StreamingResponseContentPartAddedUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseContentPartAdded(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingResponseContentPartAddedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/src/Generated/Models/StreamingResponseContentPartAddedUpdate.cs b/src/Generated/Models/StreamingResponseContentPartAddedUpdate.cs new file mode 100644 index 000000000..73e1e94c8 --- /dev/null +++ b/src/Generated/Models/StreamingResponseContentPartAddedUpdate.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseContentPartAddedUpdate : StreamingResponseUpdate + { + internal StreamingResponseContentPartAddedUpdate(string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(InternalResponsesResponseStreamEventType.ResponseContentPartAdded) + { + ItemId = itemId; + OutputIndex = outputIndex; + ContentIndex = contentIndex; + Part = part; + } + + internal StreamingResponseContentPartAddedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + ContentIndex = contentIndex; + Part = part; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + + public int ContentIndex { get; } + } +} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartDone.Serialization.cs b/src/Generated/Models/StreamingResponseContentPartDoneUpdate.Serialization.cs similarity index 55% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartDone.Serialization.cs rename to src/Generated/Models/StreamingResponseContentPartDoneUpdate.Serialization.cs index 8ba55fd59..0d76db1d6 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseContentPartDone.Serialization.cs +++ b/src/Generated/Models/StreamingResponseContentPartDoneUpdate.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseContentPartDone : IJsonModel + public partial class StreamingResponseContentPartDoneUpdate : IJsonModel { - internal InternalResponsesResponseStreamEventResponseContentPartDone() + internal StreamingResponseContentPartDoneUpdate() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Wri protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartDone)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartDoneUpdate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) @@ -54,26 +54,26 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - InternalResponsesResponseStreamEventResponseContentPartDone IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseContentPartDone)JsonModelCreateCore(ref reader, options); + StreamingResponseContentPartDoneUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseContentPartDoneUpdate)JsonModelCreateCore(ref reader, options); protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartDone)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartDoneUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseContentPartDone(document.RootElement, options); + return DeserializeStreamingResponseContentPartDoneUpdate(document.RootElement, options); } - internal static InternalResponsesResponseStreamEventResponseContentPartDone DeserializeInternalResponsesResponseStreamEventResponseContentPartDone(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingResponseContentPartDoneUpdate DeserializeStreamingResponseContentPartDoneUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string itemId = default; int outputIndex = default; @@ -83,7 +83,7 @@ internal static InternalResponsesResponseStreamEventResponseContentPartDone Dese { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("item_id"u8)) @@ -108,8 +108,8 @@ internal static InternalResponsesResponseStreamEventResponseContentPartDone Dese } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesResponseStreamEventResponseContentPartDone( - kind, + return new StreamingResponseContentPartDoneUpdate( + @type, additionalBinaryDataProperties, itemId, outputIndex, @@ -117,53 +117,53 @@ internal static InternalResponsesResponseStreamEventResponseContentPartDone Dese part); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartDone)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartDoneUpdate)} does not support writing '{options.Format}' format."); } } - InternalResponsesResponseStreamEventResponseContentPartDone IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseContentPartDone)PersistableModelCreateCore(data, options); + StreamingResponseContentPartDoneUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseContentPartDoneUpdate)PersistableModelCreateCore(data, options); protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalResponsesResponseStreamEventResponseContentPartDone(document.RootElement, options); + return DeserializeStreamingResponseContentPartDoneUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseContentPartDone)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseContentPartDoneUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseContentPartDone internalResponsesResponseStreamEventResponseContentPartDone) + public static implicit operator BinaryContent(StreamingResponseContentPartDoneUpdate streamingResponseContentPartDoneUpdate) { - if (internalResponsesResponseStreamEventResponseContentPartDone == null) + if (streamingResponseContentPartDoneUpdate == null) { return null; } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseContentPartDone, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingResponseContentPartDoneUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalResponsesResponseStreamEventResponseContentPartDone(ClientResult result) + public static explicit operator StreamingResponseContentPartDoneUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseContentPartDone(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingResponseContentPartDoneUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/src/Generated/Models/StreamingResponseContentPartDoneUpdate.cs b/src/Generated/Models/StreamingResponseContentPartDoneUpdate.cs new file mode 100644 index 000000000..68f11d073 --- /dev/null +++ b/src/Generated/Models/StreamingResponseContentPartDoneUpdate.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseContentPartDoneUpdate : StreamingResponseUpdate + { + internal StreamingResponseContentPartDoneUpdate(string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(InternalResponsesResponseStreamEventType.ResponseContentPartDone) + { + ItemId = itemId; + OutputIndex = outputIndex; + ContentIndex = contentIndex; + Part = part; + } + + internal StreamingResponseContentPartDoneUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, ResponseContentPart part) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + ContentIndex = contentIndex; + Part = part; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + + public int ContentIndex { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseCreatedUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseCreatedUpdate.Serialization.cs new file mode 100644 index 000000000..eb3f93bd7 --- /dev/null +++ b/src/Generated/Models/StreamingResponseCreatedUpdate.Serialization.cs @@ -0,0 +1,130 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseCreatedUpdate : IJsonModel + { + internal StreamingResponseCreatedUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseCreatedUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("response") != true) + { + writer.WritePropertyName("response"u8); + writer.WriteObjectValue(Response, options); + } + } + + StreamingResponseCreatedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseCreatedUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseCreatedUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseCreatedUpdate(document.RootElement, options); + } + + internal static StreamingResponseCreatedUpdate DeserializeStreamingResponseCreatedUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenAIResponse response = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("response"u8)) + { + response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseCreatedUpdate(@type, additionalBinaryDataProperties, response); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseCreatedUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseCreatedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseCreatedUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseCreatedUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseCreatedUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseCreatedUpdate streamingResponseCreatedUpdate) + { + if (streamingResponseCreatedUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseCreatedUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseCreatedUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseCreatedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseCreatedUpdate.cs b/src/Generated/Models/StreamingResponseCreatedUpdate.cs new file mode 100644 index 000000000..a71f772ab --- /dev/null +++ b/src/Generated/Models/StreamingResponseCreatedUpdate.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseCreatedUpdate : StreamingResponseUpdate + { + internal StreamingResponseCreatedUpdate(OpenAIResponse response) : base(InternalResponsesResponseStreamEventType.ResponseCreated) + { + Response = response; + } + + internal StreamingResponseCreatedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(@type, additionalBinaryDataProperties) + { + Response = response; + } + + public OpenAIResponse Response { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseErrorUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseErrorUpdate.Serialization.cs index 5b2f2ddef..5fd872eb8 100644 --- a/src/Generated/Models/StreamingResponseErrorUpdate.Serialization.cs +++ b/src/Generated/Models/StreamingResponseErrorUpdate.Serialization.cs @@ -82,7 +82,7 @@ internal static StreamingResponseErrorUpdate DeserializeStreamingResponseErrorUp { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string message = default; string code = default; @@ -91,7 +91,7 @@ internal static StreamingResponseErrorUpdate DeserializeStreamingResponseErrorUp { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("message"u8)) @@ -121,7 +121,7 @@ internal static StreamingResponseErrorUpdate DeserializeStreamingResponseErrorUp } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new StreamingResponseErrorUpdate(kind, additionalBinaryDataProperties, message, code, @param); + return new StreamingResponseErrorUpdate(@type, additionalBinaryDataProperties, message, code, @param); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/StreamingResponseErrorUpdate.cs b/src/Generated/Models/StreamingResponseErrorUpdate.cs index 9e45d2bbe..88c4a68ae 100644 --- a/src/Generated/Models/StreamingResponseErrorUpdate.cs +++ b/src/Generated/Models/StreamingResponseErrorUpdate.cs @@ -9,14 +9,14 @@ namespace OpenAI.Responses { public partial class StreamingResponseErrorUpdate : StreamingResponseUpdate { - internal StreamingResponseErrorUpdate(string message, string code, string @param) : base(StreamingResponseUpdateKind.Error) + internal StreamingResponseErrorUpdate(string message, string code, string @param) : base(InternalResponsesResponseStreamEventType.Error) { Message = message; Code = code; Param = @param; } - internal StreamingResponseErrorUpdate(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string message, string code, string @param) : base(kind, additionalBinaryDataProperties) + internal StreamingResponseErrorUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string message, string code, string @param) : base(@type, additionalBinaryDataProperties) { Message = message; Code = code; diff --git a/src/Generated/Models/StreamingResponseFailedUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseFailedUpdate.Serialization.cs new file mode 100644 index 000000000..39d71ee1f --- /dev/null +++ b/src/Generated/Models/StreamingResponseFailedUpdate.Serialization.cs @@ -0,0 +1,130 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFailedUpdate : IJsonModel + { + internal StreamingResponseFailedUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFailedUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("response") != true) + { + writer.WritePropertyName("response"u8); + writer.WriteObjectValue(Response, options); + } + } + + StreamingResponseFailedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseFailedUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFailedUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseFailedUpdate(document.RootElement, options); + } + + internal static StreamingResponseFailedUpdate DeserializeStreamingResponseFailedUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenAIResponse response = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("response"u8)) + { + response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseFailedUpdate(@type, additionalBinaryDataProperties, response); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseFailedUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseFailedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseFailedUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseFailedUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseFailedUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseFailedUpdate streamingResponseFailedUpdate) + { + if (streamingResponseFailedUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseFailedUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseFailedUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseFailedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseFailedUpdate.cs b/src/Generated/Models/StreamingResponseFailedUpdate.cs new file mode 100644 index 000000000..138242f27 --- /dev/null +++ b/src/Generated/Models/StreamingResponseFailedUpdate.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFailedUpdate : StreamingResponseUpdate + { + internal StreamingResponseFailedUpdate(OpenAIResponse response) : base(InternalResponsesResponseStreamEventType.ResponseFailed) + { + Response = response; + } + + internal StreamingResponseFailedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(@type, additionalBinaryDataProperties) + { + Response = response; + } + + public OpenAIResponse Response { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseFileSearchCallCompletedUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseFileSearchCallCompletedUpdate.Serialization.cs new file mode 100644 index 000000000..f8f931fc5 --- /dev/null +++ b/src/Generated/Models/StreamingResponseFileSearchCallCompletedUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFileSearchCallCompletedUpdate : IJsonModel + { + internal StreamingResponseFileSearchCallCompletedUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallCompletedUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + } + + StreamingResponseFileSearchCallCompletedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseFileSearchCallCompletedUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallCompletedUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseFileSearchCallCompletedUpdate(document.RootElement, options); + } + + internal static StreamingResponseFileSearchCallCompletedUpdate DeserializeStreamingResponseFileSearchCallCompletedUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseFileSearchCallCompletedUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallCompletedUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseFileSearchCallCompletedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseFileSearchCallCompletedUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseFileSearchCallCompletedUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallCompletedUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseFileSearchCallCompletedUpdate streamingResponseFileSearchCallCompletedUpdate) + { + if (streamingResponseFileSearchCallCompletedUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseFileSearchCallCompletedUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseFileSearchCallCompletedUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseFileSearchCallCompletedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseFileSearchCallCompletedUpdate.cs b/src/Generated/Models/StreamingResponseFileSearchCallCompletedUpdate.cs new file mode 100644 index 000000000..e9cad5a96 --- /dev/null +++ b/src/Generated/Models/StreamingResponseFileSearchCallCompletedUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFileSearchCallCompletedUpdate : StreamingResponseUpdate + { + internal StreamingResponseFileSearchCallCompletedUpdate(string itemId, int outputIndex) : base(InternalResponsesResponseStreamEventType.ResponseFileSearchCallCompleted) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + internal StreamingResponseFileSearchCallCompletedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseFileSearchCallInProgressUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseFileSearchCallInProgressUpdate.Serialization.cs new file mode 100644 index 000000000..a16632eec --- /dev/null +++ b/src/Generated/Models/StreamingResponseFileSearchCallInProgressUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFileSearchCallInProgressUpdate : IJsonModel + { + internal StreamingResponseFileSearchCallInProgressUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallInProgressUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + } + + StreamingResponseFileSearchCallInProgressUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseFileSearchCallInProgressUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallInProgressUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseFileSearchCallInProgressUpdate(document.RootElement, options); + } + + internal static StreamingResponseFileSearchCallInProgressUpdate DeserializeStreamingResponseFileSearchCallInProgressUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseFileSearchCallInProgressUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallInProgressUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseFileSearchCallInProgressUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseFileSearchCallInProgressUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseFileSearchCallInProgressUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallInProgressUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseFileSearchCallInProgressUpdate streamingResponseFileSearchCallInProgressUpdate) + { + if (streamingResponseFileSearchCallInProgressUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseFileSearchCallInProgressUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseFileSearchCallInProgressUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseFileSearchCallInProgressUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseFileSearchCallInProgressUpdate.cs b/src/Generated/Models/StreamingResponseFileSearchCallInProgressUpdate.cs new file mode 100644 index 000000000..7f14a5164 --- /dev/null +++ b/src/Generated/Models/StreamingResponseFileSearchCallInProgressUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFileSearchCallInProgressUpdate : StreamingResponseUpdate + { + internal StreamingResponseFileSearchCallInProgressUpdate(string itemId, int outputIndex) : base(InternalResponsesResponseStreamEventType.ResponseFileSearchCallInProgress) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + internal StreamingResponseFileSearchCallInProgressUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseFileSearchCallSearchingUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseFileSearchCallSearchingUpdate.Serialization.cs new file mode 100644 index 000000000..3ea451a2e --- /dev/null +++ b/src/Generated/Models/StreamingResponseFileSearchCallSearchingUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFileSearchCallSearchingUpdate : IJsonModel + { + internal StreamingResponseFileSearchCallSearchingUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallSearchingUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + } + + StreamingResponseFileSearchCallSearchingUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseFileSearchCallSearchingUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallSearchingUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseFileSearchCallSearchingUpdate(document.RootElement, options); + } + + internal static StreamingResponseFileSearchCallSearchingUpdate DeserializeStreamingResponseFileSearchCallSearchingUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseFileSearchCallSearchingUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallSearchingUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseFileSearchCallSearchingUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseFileSearchCallSearchingUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseFileSearchCallSearchingUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseFileSearchCallSearchingUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseFileSearchCallSearchingUpdate streamingResponseFileSearchCallSearchingUpdate) + { + if (streamingResponseFileSearchCallSearchingUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseFileSearchCallSearchingUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseFileSearchCallSearchingUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseFileSearchCallSearchingUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseFileSearchCallSearchingUpdate.cs b/src/Generated/Models/StreamingResponseFileSearchCallSearchingUpdate.cs new file mode 100644 index 000000000..83ca499d6 --- /dev/null +++ b/src/Generated/Models/StreamingResponseFileSearchCallSearchingUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFileSearchCallSearchingUpdate : StreamingResponseUpdate + { + internal StreamingResponseFileSearchCallSearchingUpdate(string itemId, int outputIndex) : base(InternalResponsesResponseStreamEventType.ResponseFileSearchCallSearching) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + internal StreamingResponseFileSearchCallSearchingUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseFunctionCallArgumentsDeltaUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDeltaUpdate.Serialization.cs new file mode 100644 index 000000000..b862b1082 --- /dev/null +++ b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDeltaUpdate.Serialization.cs @@ -0,0 +1,152 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFunctionCallArgumentsDeltaUpdate : IJsonModel + { + internal StreamingResponseFunctionCallArgumentsDeltaUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDeltaUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + if (_additionalBinaryDataProperties?.ContainsKey("delta") != true) + { + writer.WritePropertyName("delta"u8); + writer.WriteStringValue(Delta); + } + } + + StreamingResponseFunctionCallArgumentsDeltaUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseFunctionCallArgumentsDeltaUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDeltaUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseFunctionCallArgumentsDeltaUpdate(document.RootElement, options); + } + + internal static StreamingResponseFunctionCallArgumentsDeltaUpdate DeserializeStreamingResponseFunctionCallArgumentsDeltaUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + string delta = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("delta"u8)) + { + delta = prop.Value.GetString(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseFunctionCallArgumentsDeltaUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex, delta); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDeltaUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseFunctionCallArgumentsDeltaUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseFunctionCallArgumentsDeltaUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseFunctionCallArgumentsDeltaUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDeltaUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseFunctionCallArgumentsDeltaUpdate streamingResponseFunctionCallArgumentsDeltaUpdate) + { + if (streamingResponseFunctionCallArgumentsDeltaUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseFunctionCallArgumentsDeltaUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseFunctionCallArgumentsDeltaUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseFunctionCallArgumentsDeltaUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseFunctionCallArgumentsDeltaUpdate.cs b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDeltaUpdate.cs new file mode 100644 index 000000000..197e40a5e --- /dev/null +++ b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDeltaUpdate.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFunctionCallArgumentsDeltaUpdate : StreamingResponseUpdate + { + internal StreamingResponseFunctionCallArgumentsDeltaUpdate(string itemId, int outputIndex, string delta) : base(InternalResponsesResponseStreamEventType.ResponseFunctionCallArgumentsDelta) + { + ItemId = itemId; + OutputIndex = outputIndex; + Delta = delta; + } + + internal StreamingResponseFunctionCallArgumentsDeltaUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, string delta) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + Delta = delta; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + + public string Delta { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseFunctionCallArgumentsDoneUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDoneUpdate.Serialization.cs new file mode 100644 index 000000000..e8e2981da --- /dev/null +++ b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDoneUpdate.Serialization.cs @@ -0,0 +1,152 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFunctionCallArgumentsDoneUpdate : IJsonModel + { + internal StreamingResponseFunctionCallArgumentsDoneUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDoneUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + if (_additionalBinaryDataProperties?.ContainsKey("arguments") != true) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + } + + StreamingResponseFunctionCallArgumentsDoneUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseFunctionCallArgumentsDoneUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDoneUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseFunctionCallArgumentsDoneUpdate(document.RootElement, options); + } + + internal static StreamingResponseFunctionCallArgumentsDoneUpdate DeserializeStreamingResponseFunctionCallArgumentsDoneUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + string arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseFunctionCallArgumentsDoneUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex, arguments); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDoneUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseFunctionCallArgumentsDoneUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseFunctionCallArgumentsDoneUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseFunctionCallArgumentsDoneUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseFunctionCallArgumentsDoneUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseFunctionCallArgumentsDoneUpdate streamingResponseFunctionCallArgumentsDoneUpdate) + { + if (streamingResponseFunctionCallArgumentsDoneUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseFunctionCallArgumentsDoneUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseFunctionCallArgumentsDoneUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseFunctionCallArgumentsDoneUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseFunctionCallArgumentsDoneUpdate.cs b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDoneUpdate.cs new file mode 100644 index 000000000..142b980b8 --- /dev/null +++ b/src/Generated/Models/StreamingResponseFunctionCallArgumentsDoneUpdate.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseFunctionCallArgumentsDoneUpdate : StreamingResponseUpdate + { + internal StreamingResponseFunctionCallArgumentsDoneUpdate(string itemId, int outputIndex, string arguments) : base(InternalResponsesResponseStreamEventType.ResponseFunctionCallArgumentsDone) + { + ItemId = itemId; + OutputIndex = outputIndex; + Arguments = arguments; + } + + internal StreamingResponseFunctionCallArgumentsDoneUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, string arguments) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + Arguments = arguments; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + + public string Arguments { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseInProgressUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseInProgressUpdate.Serialization.cs new file mode 100644 index 000000000..c035c55dc --- /dev/null +++ b/src/Generated/Models/StreamingResponseInProgressUpdate.Serialization.cs @@ -0,0 +1,130 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseInProgressUpdate : IJsonModel + { + internal StreamingResponseInProgressUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseInProgressUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("response") != true) + { + writer.WritePropertyName("response"u8); + writer.WriteObjectValue(Response, options); + } + } + + StreamingResponseInProgressUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseInProgressUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseInProgressUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseInProgressUpdate(document.RootElement, options); + } + + internal static StreamingResponseInProgressUpdate DeserializeStreamingResponseInProgressUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenAIResponse response = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("response"u8)) + { + response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseInProgressUpdate(@type, additionalBinaryDataProperties, response); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseInProgressUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseInProgressUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseInProgressUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseInProgressUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseInProgressUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseInProgressUpdate streamingResponseInProgressUpdate) + { + if (streamingResponseInProgressUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseInProgressUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseInProgressUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseInProgressUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseInProgressUpdate.cs b/src/Generated/Models/StreamingResponseInProgressUpdate.cs new file mode 100644 index 000000000..711f6b2f5 --- /dev/null +++ b/src/Generated/Models/StreamingResponseInProgressUpdate.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseInProgressUpdate : StreamingResponseUpdate + { + internal StreamingResponseInProgressUpdate(OpenAIResponse response) : base(InternalResponsesResponseStreamEventType.ResponseInProgress) + { + Response = response; + } + + internal StreamingResponseInProgressUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(@type, additionalBinaryDataProperties) + { + Response = response; + } + + public OpenAIResponse Response { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseIncompleteUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseIncompleteUpdate.Serialization.cs new file mode 100644 index 000000000..d87a34af0 --- /dev/null +++ b/src/Generated/Models/StreamingResponseIncompleteUpdate.Serialization.cs @@ -0,0 +1,130 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseIncompleteUpdate : IJsonModel + { + internal StreamingResponseIncompleteUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseIncompleteUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("response") != true) + { + writer.WritePropertyName("response"u8); + writer.WriteObjectValue(Response, options); + } + } + + StreamingResponseIncompleteUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseIncompleteUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseIncompleteUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseIncompleteUpdate(document.RootElement, options); + } + + internal static StreamingResponseIncompleteUpdate DeserializeStreamingResponseIncompleteUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenAIResponse response = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("response"u8)) + { + response = OpenAIResponse.DeserializeOpenAIResponse(prop.Value, options); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseIncompleteUpdate(@type, additionalBinaryDataProperties, response); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseIncompleteUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseIncompleteUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseIncompleteUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseIncompleteUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseIncompleteUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseIncompleteUpdate streamingResponseIncompleteUpdate) + { + if (streamingResponseIncompleteUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseIncompleteUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseIncompleteUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseIncompleteUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseIncompleteUpdate.cs b/src/Generated/Models/StreamingResponseIncompleteUpdate.cs new file mode 100644 index 000000000..8d23427fc --- /dev/null +++ b/src/Generated/Models/StreamingResponseIncompleteUpdate.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseIncompleteUpdate : StreamingResponseUpdate + { + internal StreamingResponseIncompleteUpdate(OpenAIResponse response) : base(InternalResponsesResponseStreamEventType.ResponseIncomplete) + { + Response = response; + } + + internal StreamingResponseIncompleteUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, OpenAIResponse response) : base(@type, additionalBinaryDataProperties) + { + Response = response; + } + + public OpenAIResponse Response { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseOutputItemAddedUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseOutputItemAddedUpdate.Serialization.cs new file mode 100644 index 000000000..440402d42 --- /dev/null +++ b/src/Generated/Models/StreamingResponseOutputItemAddedUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseOutputItemAddedUpdate : IJsonModel + { + internal StreamingResponseOutputItemAddedUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseOutputItemAddedUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + if (_additionalBinaryDataProperties?.ContainsKey("item") != true) + { + writer.WritePropertyName("item"u8); + writer.WriteObjectValue(Item, options); + } + } + + StreamingResponseOutputItemAddedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseOutputItemAddedUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseOutputItemAddedUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseOutputItemAddedUpdate(document.RootElement, options); + } + + internal static StreamingResponseOutputItemAddedUpdate DeserializeStreamingResponseOutputItemAddedUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int outputIndex = default; + ResponseItem item = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("item"u8)) + { + item = ResponseItem.DeserializeResponseItem(prop.Value, options); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseOutputItemAddedUpdate(@type, additionalBinaryDataProperties, outputIndex, item); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseOutputItemAddedUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseOutputItemAddedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseOutputItemAddedUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseOutputItemAddedUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseOutputItemAddedUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseOutputItemAddedUpdate streamingResponseOutputItemAddedUpdate) + { + if (streamingResponseOutputItemAddedUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseOutputItemAddedUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseOutputItemAddedUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseOutputItemAddedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseOutputItemAddedUpdate.cs b/src/Generated/Models/StreamingResponseOutputItemAddedUpdate.cs new file mode 100644 index 000000000..d782a381a --- /dev/null +++ b/src/Generated/Models/StreamingResponseOutputItemAddedUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseOutputItemAddedUpdate : StreamingResponseUpdate + { + internal StreamingResponseOutputItemAddedUpdate(int outputIndex, ResponseItem item) : base(InternalResponsesResponseStreamEventType.ResponseOutputItemAdded) + { + OutputIndex = outputIndex; + Item = item; + } + + internal StreamingResponseOutputItemAddedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, int outputIndex, ResponseItem item) : base(@type, additionalBinaryDataProperties) + { + OutputIndex = outputIndex; + Item = item; + } + + public int OutputIndex { get; } + + public ResponseItem Item { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseOutputItemDoneUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseOutputItemDoneUpdate.Serialization.cs new file mode 100644 index 000000000..cbee82b90 --- /dev/null +++ b/src/Generated/Models/StreamingResponseOutputItemDoneUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseOutputItemDoneUpdate : IJsonModel + { + internal StreamingResponseOutputItemDoneUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseOutputItemDoneUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + if (_additionalBinaryDataProperties?.ContainsKey("item") != true) + { + writer.WritePropertyName("item"u8); + writer.WriteObjectValue(Item, options); + } + } + + StreamingResponseOutputItemDoneUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseOutputItemDoneUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseOutputItemDoneUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseOutputItemDoneUpdate(document.RootElement, options); + } + + internal static StreamingResponseOutputItemDoneUpdate DeserializeStreamingResponseOutputItemDoneUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int outputIndex = default; + ResponseItem item = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("item"u8)) + { + item = ResponseItem.DeserializeResponseItem(prop.Value, options); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseOutputItemDoneUpdate(@type, additionalBinaryDataProperties, outputIndex, item); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseOutputItemDoneUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseOutputItemDoneUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseOutputItemDoneUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseOutputItemDoneUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseOutputItemDoneUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseOutputItemDoneUpdate streamingResponseOutputItemDoneUpdate) + { + if (streamingResponseOutputItemDoneUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseOutputItemDoneUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseOutputItemDoneUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseOutputItemDoneUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseOutputItemDoneUpdate.cs b/src/Generated/Models/StreamingResponseOutputItemDoneUpdate.cs new file mode 100644 index 000000000..978126a87 --- /dev/null +++ b/src/Generated/Models/StreamingResponseOutputItemDoneUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseOutputItemDoneUpdate : StreamingResponseUpdate + { + internal StreamingResponseOutputItemDoneUpdate(int outputIndex, ResponseItem item) : base(InternalResponsesResponseStreamEventType.ResponseOutputItemDone) + { + OutputIndex = outputIndex; + Item = item; + } + + internal StreamingResponseOutputItemDoneUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, int outputIndex, ResponseItem item) : base(@type, additionalBinaryDataProperties) + { + OutputIndex = outputIndex; + Item = item; + } + + public int OutputIndex { get; } + + public ResponseItem Item { get; } + } +} diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDelta.Serialization.cs b/src/Generated/Models/StreamingResponseOutputTextDeltaUpdate.Serialization.cs similarity index 55% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDelta.Serialization.cs rename to src/Generated/Models/StreamingResponseOutputTextDeltaUpdate.Serialization.cs index 1dfc65ff3..ccb4552e1 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDelta.Serialization.cs +++ b/src/Generated/Models/StreamingResponseOutputTextDeltaUpdate.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseOutputTextDelta : IJsonModel + public partial class StreamingResponseOutputTextDeltaUpdate : IJsonModel { - internal InternalResponsesResponseStreamEventResponseOutputTextDelta() + internal StreamingResponseOutputTextDeltaUpdate() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Wri protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDelta)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDeltaUpdate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) @@ -54,26 +54,26 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - InternalResponsesResponseStreamEventResponseOutputTextDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputTextDelta)JsonModelCreateCore(ref reader, options); + StreamingResponseOutputTextDeltaUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseOutputTextDeltaUpdate)JsonModelCreateCore(ref reader, options); protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDelta)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDeltaUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseOutputTextDelta(document.RootElement, options); + return DeserializeStreamingResponseOutputTextDeltaUpdate(document.RootElement, options); } - internal static InternalResponsesResponseStreamEventResponseOutputTextDelta DeserializeInternalResponsesResponseStreamEventResponseOutputTextDelta(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingResponseOutputTextDeltaUpdate DeserializeStreamingResponseOutputTextDeltaUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string itemId = default; int outputIndex = default; @@ -83,7 +83,7 @@ internal static InternalResponsesResponseStreamEventResponseOutputTextDelta Dese { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("item_id"u8)) @@ -108,8 +108,8 @@ internal static InternalResponsesResponseStreamEventResponseOutputTextDelta Dese } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesResponseStreamEventResponseOutputTextDelta( - kind, + return new StreamingResponseOutputTextDeltaUpdate( + @type, additionalBinaryDataProperties, itemId, outputIndex, @@ -117,53 +117,53 @@ internal static InternalResponsesResponseStreamEventResponseOutputTextDelta Dese delta); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDelta)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDeltaUpdate)} does not support writing '{options.Format}' format."); } } - InternalResponsesResponseStreamEventResponseOutputTextDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputTextDelta)PersistableModelCreateCore(data, options); + StreamingResponseOutputTextDeltaUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseOutputTextDeltaUpdate)PersistableModelCreateCore(data, options); protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalResponsesResponseStreamEventResponseOutputTextDelta(document.RootElement, options); + return DeserializeStreamingResponseOutputTextDeltaUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDelta)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDeltaUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseOutputTextDelta internalResponsesResponseStreamEventResponseOutputTextDelta) + public static implicit operator BinaryContent(StreamingResponseOutputTextDeltaUpdate streamingResponseOutputTextDeltaUpdate) { - if (internalResponsesResponseStreamEventResponseOutputTextDelta == null) + if (streamingResponseOutputTextDeltaUpdate == null) { return null; } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseOutputTextDelta, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingResponseOutputTextDeltaUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalResponsesResponseStreamEventResponseOutputTextDelta(ClientResult result) + public static explicit operator StreamingResponseOutputTextDeltaUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseOutputTextDelta(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingResponseOutputTextDeltaUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDelta.cs b/src/Generated/Models/StreamingResponseOutputTextDeltaUpdate.cs similarity index 50% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDelta.cs rename to src/Generated/Models/StreamingResponseOutputTextDeltaUpdate.cs index be4fa6e83..1c1cce7aa 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDelta.cs +++ b/src/Generated/Models/StreamingResponseOutputTextDeltaUpdate.cs @@ -7,9 +7,9 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseRefusalDelta : StreamingResponseUpdate + public partial class StreamingResponseOutputTextDeltaUpdate : StreamingResponseUpdate { - internal InternalResponsesResponseStreamEventResponseRefusalDelta(string itemId, int outputIndex, int contentIndex, string delta) : base(StreamingResponseUpdateKind.ResponseRefusalDelta) + internal StreamingResponseOutputTextDeltaUpdate(string itemId, int outputIndex, int contentIndex, string delta) : base(InternalResponsesResponseStreamEventType.ResponseOutputTextDelta) { ItemId = itemId; OutputIndex = outputIndex; @@ -17,7 +17,7 @@ internal InternalResponsesResponseStreamEventResponseRefusalDelta(string itemId, Delta = delta; } - internal InternalResponsesResponseStreamEventResponseRefusalDelta(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string delta) : base(kind, additionalBinaryDataProperties) + internal StreamingResponseOutputTextDeltaUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string delta) : base(@type, additionalBinaryDataProperties) { ItemId = itemId; OutputIndex = outputIndex; diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDone.Serialization.cs b/src/Generated/Models/StreamingResponseOutputTextDoneUpdate.Serialization.cs similarity index 55% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDone.Serialization.cs rename to src/Generated/Models/StreamingResponseOutputTextDoneUpdate.Serialization.cs index 7b87f6831..29fa49431 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDone.Serialization.cs +++ b/src/Generated/Models/StreamingResponseOutputTextDoneUpdate.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseOutputTextDone : IJsonModel + public partial class StreamingResponseOutputTextDoneUpdate : IJsonModel { - internal InternalResponsesResponseStreamEventResponseOutputTextDone() + internal StreamingResponseOutputTextDoneUpdate() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Writ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDone)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDoneUpdate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) @@ -54,26 +54,26 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - InternalResponsesResponseStreamEventResponseOutputTextDone IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputTextDone)JsonModelCreateCore(ref reader, options); + StreamingResponseOutputTextDoneUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseOutputTextDoneUpdate)JsonModelCreateCore(ref reader, options); protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDone)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDoneUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseOutputTextDone(document.RootElement, options); + return DeserializeStreamingResponseOutputTextDoneUpdate(document.RootElement, options); } - internal static InternalResponsesResponseStreamEventResponseOutputTextDone DeserializeInternalResponsesResponseStreamEventResponseOutputTextDone(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingResponseOutputTextDoneUpdate DeserializeStreamingResponseOutputTextDoneUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string itemId = default; int outputIndex = default; @@ -83,7 +83,7 @@ internal static InternalResponsesResponseStreamEventResponseOutputTextDone Deser { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("item_id"u8)) @@ -108,8 +108,8 @@ internal static InternalResponsesResponseStreamEventResponseOutputTextDone Deser } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesResponseStreamEventResponseOutputTextDone( - kind, + return new StreamingResponseOutputTextDoneUpdate( + @type, additionalBinaryDataProperties, itemId, outputIndex, @@ -117,53 +117,53 @@ internal static InternalResponsesResponseStreamEventResponseOutputTextDone Deser text); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDone)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDoneUpdate)} does not support writing '{options.Format}' format."); } } - InternalResponsesResponseStreamEventResponseOutputTextDone IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseOutputTextDone)PersistableModelCreateCore(data, options); + StreamingResponseOutputTextDoneUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseOutputTextDoneUpdate)PersistableModelCreateCore(data, options); protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalResponsesResponseStreamEventResponseOutputTextDone(document.RootElement, options); + return DeserializeStreamingResponseOutputTextDoneUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseOutputTextDone)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseOutputTextDoneUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseOutputTextDone internalResponsesResponseStreamEventResponseOutputTextDone) + public static implicit operator BinaryContent(StreamingResponseOutputTextDoneUpdate streamingResponseOutputTextDoneUpdate) { - if (internalResponsesResponseStreamEventResponseOutputTextDone == null) + if (streamingResponseOutputTextDoneUpdate == null) { return null; } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseOutputTextDone, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingResponseOutputTextDoneUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalResponsesResponseStreamEventResponseOutputTextDone(ClientResult result) + public static explicit operator StreamingResponseOutputTextDoneUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseOutputTextDone(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingResponseOutputTextDoneUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDone.cs b/src/Generated/Models/StreamingResponseOutputTextDoneUpdate.cs similarity index 50% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDone.cs rename to src/Generated/Models/StreamingResponseOutputTextDoneUpdate.cs index b469bbdf2..fd09cc55f 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDone.cs +++ b/src/Generated/Models/StreamingResponseOutputTextDoneUpdate.cs @@ -7,9 +7,9 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseOutputTextDone : StreamingResponseUpdate + public partial class StreamingResponseOutputTextDoneUpdate : StreamingResponseUpdate { - internal InternalResponsesResponseStreamEventResponseOutputTextDone(string itemId, int outputIndex, int contentIndex, string text) : base(StreamingResponseUpdateKind.ResponseOutputTextDone) + internal StreamingResponseOutputTextDoneUpdate(string itemId, int outputIndex, int contentIndex, string text) : base(InternalResponsesResponseStreamEventType.ResponseOutputTextDone) { ItemId = itemId; OutputIndex = outputIndex; @@ -17,7 +17,7 @@ internal InternalResponsesResponseStreamEventResponseOutputTextDone(string itemI Text = text; } - internal InternalResponsesResponseStreamEventResponseOutputTextDone(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string text) : base(kind, additionalBinaryDataProperties) + internal StreamingResponseOutputTextDoneUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string text) : base(@type, additionalBinaryDataProperties) { ItemId = itemId; OutputIndex = outputIndex; diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDelta.Serialization.cs b/src/Generated/Models/StreamingResponseRefusalDeltaUpdate.Serialization.cs similarity index 55% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDelta.Serialization.cs rename to src/Generated/Models/StreamingResponseRefusalDeltaUpdate.Serialization.cs index 1dbe0a4e1..0dab5d7c3 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDelta.Serialization.cs +++ b/src/Generated/Models/StreamingResponseRefusalDeltaUpdate.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseRefusalDelta : IJsonModel + public partial class StreamingResponseRefusalDeltaUpdate : IJsonModel { - internal InternalResponsesResponseStreamEventResponseRefusalDelta() + internal StreamingResponseRefusalDeltaUpdate() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Write( protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDelta)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDeltaUpdate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) @@ -54,26 +54,26 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - InternalResponsesResponseStreamEventResponseRefusalDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseRefusalDelta)JsonModelCreateCore(ref reader, options); + StreamingResponseRefusalDeltaUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseRefusalDeltaUpdate)JsonModelCreateCore(ref reader, options); protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDelta)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDeltaUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseRefusalDelta(document.RootElement, options); + return DeserializeStreamingResponseRefusalDeltaUpdate(document.RootElement, options); } - internal static InternalResponsesResponseStreamEventResponseRefusalDelta DeserializeInternalResponsesResponseStreamEventResponseRefusalDelta(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingResponseRefusalDeltaUpdate DeserializeStreamingResponseRefusalDeltaUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string itemId = default; int outputIndex = default; @@ -83,7 +83,7 @@ internal static InternalResponsesResponseStreamEventResponseRefusalDelta Deseria { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("item_id"u8)) @@ -108,8 +108,8 @@ internal static InternalResponsesResponseStreamEventResponseRefusalDelta Deseria } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesResponseStreamEventResponseRefusalDelta( - kind, + return new StreamingResponseRefusalDeltaUpdate( + @type, additionalBinaryDataProperties, itemId, outputIndex, @@ -117,53 +117,53 @@ internal static InternalResponsesResponseStreamEventResponseRefusalDelta Deseria delta); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDelta)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDeltaUpdate)} does not support writing '{options.Format}' format."); } } - InternalResponsesResponseStreamEventResponseRefusalDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseRefusalDelta)PersistableModelCreateCore(data, options); + StreamingResponseRefusalDeltaUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseRefusalDeltaUpdate)PersistableModelCreateCore(data, options); protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalResponsesResponseStreamEventResponseRefusalDelta(document.RootElement, options); + return DeserializeStreamingResponseRefusalDeltaUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDelta)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDeltaUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseRefusalDelta internalResponsesResponseStreamEventResponseRefusalDelta) + public static implicit operator BinaryContent(StreamingResponseRefusalDeltaUpdate streamingResponseRefusalDeltaUpdate) { - if (internalResponsesResponseStreamEventResponseRefusalDelta == null) + if (streamingResponseRefusalDeltaUpdate == null) { return null; } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseRefusalDelta, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingResponseRefusalDeltaUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalResponsesResponseStreamEventResponseRefusalDelta(ClientResult result) + public static explicit operator StreamingResponseRefusalDeltaUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseRefusalDelta(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingResponseRefusalDeltaUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDelta.cs b/src/Generated/Models/StreamingResponseRefusalDeltaUpdate.cs similarity index 50% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDelta.cs rename to src/Generated/Models/StreamingResponseRefusalDeltaUpdate.cs index e2d7de570..887e685e1 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseOutputTextDelta.cs +++ b/src/Generated/Models/StreamingResponseRefusalDeltaUpdate.cs @@ -7,9 +7,9 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseOutputTextDelta : StreamingResponseUpdate + public partial class StreamingResponseRefusalDeltaUpdate : StreamingResponseUpdate { - internal InternalResponsesResponseStreamEventResponseOutputTextDelta(string itemId, int outputIndex, int contentIndex, string delta) : base(StreamingResponseUpdateKind.ResponseOutputTextDelta) + internal StreamingResponseRefusalDeltaUpdate(string itemId, int outputIndex, int contentIndex, string delta) : base(InternalResponsesResponseStreamEventType.ResponseRefusalDelta) { ItemId = itemId; OutputIndex = outputIndex; @@ -17,7 +17,7 @@ internal InternalResponsesResponseStreamEventResponseOutputTextDelta(string item Delta = delta; } - internal InternalResponsesResponseStreamEventResponseOutputTextDelta(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string delta) : base(kind, additionalBinaryDataProperties) + internal StreamingResponseRefusalDeltaUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string delta) : base(@type, additionalBinaryDataProperties) { ItemId = itemId; OutputIndex = outputIndex; diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDone.Serialization.cs b/src/Generated/Models/StreamingResponseRefusalDoneUpdate.Serialization.cs similarity index 56% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDone.Serialization.cs rename to src/Generated/Models/StreamingResponseRefusalDoneUpdate.Serialization.cs index 63adbf086..1cbfe17a6 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDone.Serialization.cs +++ b/src/Generated/Models/StreamingResponseRefusalDoneUpdate.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseRefusalDone : IJsonModel + public partial class StreamingResponseRefusalDoneUpdate : IJsonModel { - internal InternalResponsesResponseStreamEventResponseRefusalDone() + internal StreamingResponseRefusalDoneUpdate() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Write(U protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDone)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDoneUpdate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) @@ -54,26 +54,26 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - InternalResponsesResponseStreamEventResponseRefusalDone IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseRefusalDone)JsonModelCreateCore(ref reader, options); + StreamingResponseRefusalDoneUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseRefusalDoneUpdate)JsonModelCreateCore(ref reader, options); protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDone)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDoneUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponsesResponseStreamEventResponseRefusalDone(document.RootElement, options); + return DeserializeStreamingResponseRefusalDoneUpdate(document.RootElement, options); } - internal static InternalResponsesResponseStreamEventResponseRefusalDone DeserializeInternalResponsesResponseStreamEventResponseRefusalDone(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingResponseRefusalDoneUpdate DeserializeStreamingResponseRefusalDoneUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string itemId = default; int outputIndex = default; @@ -83,7 +83,7 @@ internal static InternalResponsesResponseStreamEventResponseRefusalDone Deserial { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("item_id"u8)) @@ -108,8 +108,8 @@ internal static InternalResponsesResponseStreamEventResponseRefusalDone Deserial } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new InternalResponsesResponseStreamEventResponseRefusalDone( - kind, + return new StreamingResponseRefusalDoneUpdate( + @type, additionalBinaryDataProperties, itemId, outputIndex, @@ -117,53 +117,53 @@ internal static InternalResponsesResponseStreamEventResponseRefusalDone Deserial refusal); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDone)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDoneUpdate)} does not support writing '{options.Format}' format."); } } - InternalResponsesResponseStreamEventResponseRefusalDone IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesResponseStreamEventResponseRefusalDone)PersistableModelCreateCore(data, options); + StreamingResponseRefusalDoneUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseRefusalDoneUpdate)PersistableModelCreateCore(data, options); protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalResponsesResponseStreamEventResponseRefusalDone(document.RootElement, options); + return DeserializeStreamingResponseRefusalDoneUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalResponsesResponseStreamEventResponseRefusalDone)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseRefusalDoneUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalResponsesResponseStreamEventResponseRefusalDone internalResponsesResponseStreamEventResponseRefusalDone) + public static implicit operator BinaryContent(StreamingResponseRefusalDoneUpdate streamingResponseRefusalDoneUpdate) { - if (internalResponsesResponseStreamEventResponseRefusalDone == null) + if (streamingResponseRefusalDoneUpdate == null) { return null; } - return BinaryContent.Create(internalResponsesResponseStreamEventResponseRefusalDone, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingResponseRefusalDoneUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalResponsesResponseStreamEventResponseRefusalDone(ClientResult result) + public static explicit operator StreamingResponseRefusalDoneUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponsesResponseStreamEventResponseRefusalDone(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingResponseRefusalDoneUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDone.cs b/src/Generated/Models/StreamingResponseRefusalDoneUpdate.cs similarity index 51% rename from src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDone.cs rename to src/Generated/Models/StreamingResponseRefusalDoneUpdate.cs index fa075e674..6fa0047a9 100644 --- a/src/Generated/Models/InternalResponsesResponseStreamEventResponseRefusalDone.cs +++ b/src/Generated/Models/StreamingResponseRefusalDoneUpdate.cs @@ -7,9 +7,9 @@ namespace OpenAI.Responses { - internal partial class InternalResponsesResponseStreamEventResponseRefusalDone : StreamingResponseUpdate + public partial class StreamingResponseRefusalDoneUpdate : StreamingResponseUpdate { - internal InternalResponsesResponseStreamEventResponseRefusalDone(string itemId, int outputIndex, int contentIndex, string refusal) : base(StreamingResponseUpdateKind.ResponseRefusalDone) + internal StreamingResponseRefusalDoneUpdate(string itemId, int outputIndex, int contentIndex, string refusal) : base(InternalResponsesResponseStreamEventType.ResponseRefusalDone) { ItemId = itemId; OutputIndex = outputIndex; @@ -17,7 +17,7 @@ internal InternalResponsesResponseStreamEventResponseRefusalDone(string itemId, Refusal = refusal; } - internal InternalResponsesResponseStreamEventResponseRefusalDone(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string refusal) : base(kind, additionalBinaryDataProperties) + internal StreamingResponseRefusalDoneUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, string refusal) : base(@type, additionalBinaryDataProperties) { ItemId = itemId; OutputIndex = outputIndex; diff --git a/src/Generated/Models/StreamingResponseTextAnnotationUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseTextAnnotationAddedUpdate.Serialization.cs similarity index 65% rename from src/Generated/Models/StreamingResponseTextAnnotationUpdate.Serialization.cs rename to src/Generated/Models/StreamingResponseTextAnnotationAddedUpdate.Serialization.cs index d500f0810..603c1d471 100644 --- a/src/Generated/Models/StreamingResponseTextAnnotationUpdate.Serialization.cs +++ b/src/Generated/Models/StreamingResponseTextAnnotationAddedUpdate.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Responses { - public partial class StreamingResponseTextAnnotationUpdate : IJsonModel + public partial class StreamingResponseTextAnnotationAddedUpdate : IJsonModel { - internal StreamingResponseTextAnnotationUpdate() + internal StreamingResponseTextAnnotationAddedUpdate() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Write(Utf8JsonWriter writ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationUpdate)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationAddedUpdate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) @@ -54,26 +54,26 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - StreamingResponseTextAnnotationUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseTextAnnotationUpdate)JsonModelCreateCore(ref reader, options); + StreamingResponseTextAnnotationAddedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseTextAnnotationAddedUpdate)JsonModelCreateCore(ref reader, options); protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationUpdate)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationAddedUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeStreamingResponseTextAnnotationUpdate(document.RootElement, options); + return DeserializeStreamingResponseTextAnnotationAddedUpdate(document.RootElement, options); } - internal static StreamingResponseTextAnnotationUpdate DeserializeStreamingResponseTextAnnotationUpdate(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingResponseTextAnnotationAddedUpdate DeserializeStreamingResponseTextAnnotationAddedUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string itemId = default; int outputIndex = default; @@ -83,7 +83,7 @@ internal static StreamingResponseTextAnnotationUpdate DeserializeStreamingRespon { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } if (prop.NameEquals("item_id"u8)) @@ -108,8 +108,8 @@ internal static StreamingResponseTextAnnotationUpdate DeserializeStreamingRespon } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new StreamingResponseTextAnnotationUpdate( - kind, + return new StreamingResponseTextAnnotationAddedUpdate( + @type, additionalBinaryDataProperties, itemId, outputIndex, @@ -117,53 +117,53 @@ internal static StreamingResponseTextAnnotationUpdate DeserializeStreamingRespon annotation); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationUpdate)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationAddedUpdate)} does not support writing '{options.Format}' format."); } } - StreamingResponseTextAnnotationUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseTextAnnotationUpdate)PersistableModelCreateCore(data, options); + StreamingResponseTextAnnotationAddedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseTextAnnotationAddedUpdate)PersistableModelCreateCore(data, options); protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeStreamingResponseTextAnnotationUpdate(document.RootElement, options); + return DeserializeStreamingResponseTextAnnotationAddedUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationUpdate)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingResponseTextAnnotationAddedUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(StreamingResponseTextAnnotationUpdate streamingResponseTextAnnotationUpdate) + public static implicit operator BinaryContent(StreamingResponseTextAnnotationAddedUpdate streamingResponseTextAnnotationAddedUpdate) { - if (streamingResponseTextAnnotationUpdate == null) + if (streamingResponseTextAnnotationAddedUpdate == null) { return null; } - return BinaryContent.Create(streamingResponseTextAnnotationUpdate, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingResponseTextAnnotationAddedUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator StreamingResponseTextAnnotationUpdate(ClientResult result) + public static explicit operator StreamingResponseTextAnnotationAddedUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeStreamingResponseTextAnnotationUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingResponseTextAnnotationAddedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/src/Generated/Models/StreamingResponseTextAnnotationUpdate.cs b/src/Generated/Models/StreamingResponseTextAnnotationAddedUpdate.cs similarity index 50% rename from src/Generated/Models/StreamingResponseTextAnnotationUpdate.cs rename to src/Generated/Models/StreamingResponseTextAnnotationAddedUpdate.cs index 29c46dbfe..6177ff79f 100644 --- a/src/Generated/Models/StreamingResponseTextAnnotationUpdate.cs +++ b/src/Generated/Models/StreamingResponseTextAnnotationAddedUpdate.cs @@ -7,9 +7,9 @@ namespace OpenAI.Responses { - public partial class StreamingResponseTextAnnotationUpdate : StreamingResponseUpdate + public partial class StreamingResponseTextAnnotationAddedUpdate : StreamingResponseUpdate { - internal StreamingResponseTextAnnotationUpdate(string itemId, int outputIndex, int contentIndex, ResponseMessageAnnotation annotation) : base(StreamingResponseUpdateKind.ResponseOutputTextAnnotationAdded) + internal StreamingResponseTextAnnotationAddedUpdate(string itemId, int outputIndex, int contentIndex, ResponseMessageAnnotation annotation) : base(InternalResponsesResponseStreamEventType.ResponseOutputTextAnnotationAdded) { ItemId = itemId; OutputIndex = outputIndex; @@ -17,7 +17,7 @@ internal StreamingResponseTextAnnotationUpdate(string itemId, int outputIndex, i Annotation = annotation; } - internal StreamingResponseTextAnnotationUpdate(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, ResponseMessageAnnotation annotation) : base(kind, additionalBinaryDataProperties) + internal StreamingResponseTextAnnotationAddedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex, int contentIndex, ResponseMessageAnnotation annotation) : base(@type, additionalBinaryDataProperties) { ItemId = itemId; OutputIndex = outputIndex; diff --git a/src/Generated/Models/StreamingResponseUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseUpdate.Serialization.cs index 765e6f3b3..503fda64b 100644 --- a/src/Generated/Models/StreamingResponseUpdate.Serialization.cs +++ b/src/Generated/Models/StreamingResponseUpdate.Serialization.cs @@ -33,7 +33,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("type") != true) { writer.WritePropertyName("type"u8); - writer.WriteStringValue(Kind.ToString()); + writer.WriteStringValue(Type.ToString()); } if (_additionalBinaryDataProperties != null) { @@ -82,49 +82,49 @@ internal static StreamingResponseUpdate DeserializeStreamingResponseUpdate(JsonE case "error": return StreamingResponseErrorUpdate.DeserializeStreamingResponseErrorUpdate(element, options); case "response.completed": - return InternalResponsesResponseStreamEventResponseCompleted.DeserializeInternalResponsesResponseStreamEventResponseCompleted(element, options); + return StreamingResponseCompletedUpdate.DeserializeStreamingResponseCompletedUpdate(element, options); case "response.content_part.added": - return InternalResponsesResponseStreamEventResponseContentPartAdded.DeserializeInternalResponsesResponseStreamEventResponseContentPartAdded(element, options); + return StreamingResponseContentPartAddedUpdate.DeserializeStreamingResponseContentPartAddedUpdate(element, options); case "response.content_part.done": - return InternalResponsesResponseStreamEventResponseContentPartDone.DeserializeInternalResponsesResponseStreamEventResponseContentPartDone(element, options); + return StreamingResponseContentPartDoneUpdate.DeserializeStreamingResponseContentPartDoneUpdate(element, options); case "response.created": - return InternalResponsesResponseStreamEventResponseCreated.DeserializeInternalResponsesResponseStreamEventResponseCreated(element, options); + return StreamingResponseCreatedUpdate.DeserializeStreamingResponseCreatedUpdate(element, options); case "response.failed": - return InternalResponsesResponseStreamEventResponseFailed.DeserializeInternalResponsesResponseStreamEventResponseFailed(element, options); + return StreamingResponseFailedUpdate.DeserializeStreamingResponseFailedUpdate(element, options); case "response.file_search_call.completed": - return InternalResponsesResponseStreamEventResponseFileSearchCallCompleted.DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallCompleted(element, options); + return StreamingResponseFileSearchCallCompletedUpdate.DeserializeStreamingResponseFileSearchCallCompletedUpdate(element, options); case "response.file_search_call.in.progress": - return InternalResponsesResponseStreamEventResponseFileSearchCallInProgress.DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallInProgress(element, options); + return StreamingResponseFileSearchCallInProgressUpdate.DeserializeStreamingResponseFileSearchCallInProgressUpdate(element, options); case "response.file_search_call.searching": - return InternalResponsesResponseStreamEventResponseFileSearchCallSearching.DeserializeInternalResponsesResponseStreamEventResponseFileSearchCallSearching(element, options); + return StreamingResponseFileSearchCallSearchingUpdate.DeserializeStreamingResponseFileSearchCallSearchingUpdate(element, options); case "response.function_call_arguments.delta": - return InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta.DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDelta(element, options); + return StreamingResponseFunctionCallArgumentsDeltaUpdate.DeserializeStreamingResponseFunctionCallArgumentsDeltaUpdate(element, options); case "response.function_call_arguments.done": - return InternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone.DeserializeInternalResponsesResponseStreamEventResponseFunctionCallArgumentsDone(element, options); + return StreamingResponseFunctionCallArgumentsDoneUpdate.DeserializeStreamingResponseFunctionCallArgumentsDoneUpdate(element, options); case "response.incomplete": - return InternalResponsesResponseStreamEventResponseIncomplete.DeserializeInternalResponsesResponseStreamEventResponseIncomplete(element, options); + return StreamingResponseIncompleteUpdate.DeserializeStreamingResponseIncompleteUpdate(element, options); case "response.in_progress": - return InternalResponsesResponseStreamEventResponseInProgress.DeserializeInternalResponsesResponseStreamEventResponseInProgress(element, options); + return StreamingResponseInProgressUpdate.DeserializeStreamingResponseInProgressUpdate(element, options); case "response.output_item.added": - return InternalResponsesResponseStreamEventResponseOutputItemAdded.DeserializeInternalResponsesResponseStreamEventResponseOutputItemAdded(element, options); + return StreamingResponseOutputItemAddedUpdate.DeserializeStreamingResponseOutputItemAddedUpdate(element, options); case "response.output_item.done": - return InternalResponsesResponseStreamEventResponseOutputItemDone.DeserializeInternalResponsesResponseStreamEventResponseOutputItemDone(element, options); + return StreamingResponseOutputItemDoneUpdate.DeserializeStreamingResponseOutputItemDoneUpdate(element, options); case "response.output_text.annotation.added": - return StreamingResponseTextAnnotationUpdate.DeserializeStreamingResponseTextAnnotationUpdate(element, options); + return StreamingResponseTextAnnotationAddedUpdate.DeserializeStreamingResponseTextAnnotationAddedUpdate(element, options); case "response.output_text.delta": - return InternalResponsesResponseStreamEventResponseOutputTextDelta.DeserializeInternalResponsesResponseStreamEventResponseOutputTextDelta(element, options); + return StreamingResponseOutputTextDeltaUpdate.DeserializeStreamingResponseOutputTextDeltaUpdate(element, options); case "response.output_text.done": - return InternalResponsesResponseStreamEventResponseOutputTextDone.DeserializeInternalResponsesResponseStreamEventResponseOutputTextDone(element, options); + return StreamingResponseOutputTextDoneUpdate.DeserializeStreamingResponseOutputTextDoneUpdate(element, options); case "response.refusal.delta": - return InternalResponsesResponseStreamEventResponseRefusalDelta.DeserializeInternalResponsesResponseStreamEventResponseRefusalDelta(element, options); + return StreamingResponseRefusalDeltaUpdate.DeserializeStreamingResponseRefusalDeltaUpdate(element, options); case "response.refusal.done": - return InternalResponsesResponseStreamEventResponseRefusalDone.DeserializeInternalResponsesResponseStreamEventResponseRefusalDone(element, options); + return StreamingResponseRefusalDoneUpdate.DeserializeStreamingResponseRefusalDoneUpdate(element, options); case "response.web_search_call.completed": - return InternalResponsesResponseStreamEventResponseWebSearchCallCompleted.DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallCompleted(element, options); + return StreamingResponseWebSearchCallCompletedUpdate.DeserializeStreamingResponseWebSearchCallCompletedUpdate(element, options); case "response.web_search_call.in_progress": - return InternalResponsesResponseStreamEventResponseWebSearchCallInProgress.DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallInProgress(element, options); + return StreamingResponseWebSearchCallInProgressUpdate.DeserializeStreamingResponseWebSearchCallInProgressUpdate(element, options); case "response.web_search_call.searching": - return InternalResponsesResponseStreamEventResponseWebSearchCallSearching.DeserializeInternalResponsesResponseStreamEventResponseWebSearchCallSearching(element, options); + return StreamingResponseWebSearchCallSearchingUpdate.DeserializeStreamingResponseWebSearchCallSearchingUpdate(element, options); } } return UnknownResponsesResponseStreamEvent.DeserializeUnknownResponsesResponseStreamEvent(element, options); diff --git a/src/Generated/Models/StreamingResponseUpdate.cs b/src/Generated/Models/StreamingResponseUpdate.cs index b5c21bd07..179cb11c2 100644 --- a/src/Generated/Models/StreamingResponseUpdate.cs +++ b/src/Generated/Models/StreamingResponseUpdate.cs @@ -11,17 +11,19 @@ public partial class StreamingResponseUpdate { private protected IDictionary _additionalBinaryDataProperties; - private protected StreamingResponseUpdate(StreamingResponseUpdateKind kind) + private protected StreamingResponseUpdate(InternalResponsesResponseStreamEventType @type) { - Kind = kind; + Type = @type; } - internal StreamingResponseUpdate(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties) + internal StreamingResponseUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties) { - Kind = kind; + Type = @type; _additionalBinaryDataProperties = additionalBinaryDataProperties; } + internal InternalResponsesResponseStreamEventType Type { get; set; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/src/Generated/Models/StreamingResponseUpdateKind.cs b/src/Generated/Models/StreamingResponseUpdateKind.cs deleted file mode 100644 index fbed5f21e..000000000 --- a/src/Generated/Models/StreamingResponseUpdateKind.cs +++ /dev/null @@ -1,107 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Responses -{ - public readonly partial struct StreamingResponseUpdateKind : IEquatable - { - private readonly string _value; - private const string ErrorValue = "error"; - private const string ResponseCompletedValue = "response.completed"; - private const string ResponseContentPartAddedValue = "response.content_part.added"; - private const string ResponseContentPartDoneValue = "response.content_part.done"; - private const string ResponseCreatedValue = "response.created"; - private const string ResponseFailedValue = "response.failed"; - private const string ResponseFileSearchCallCompletedValue = "response.file_search_call.completed"; - private const string ResponseFileSearchCallInProgressValue = "response.file_search_call.in.progress"; - private const string ResponseFileSearchCallSearchingValue = "response.file_search_call.searching"; - private const string ResponseFunctionCallArgumentsDeltaValue = "response.function_call_arguments.delta"; - private const string ResponseFunctionCallArgumentsDoneValue = "response.function_call_arguments.done"; - private const string ResponseInProgressValue = "response.in_progress"; - private const string ResponseIncompleteValue = "response.incomplete"; - private const string ResponseOutputItemAddedValue = "response.output_item.added"; - private const string ResponseOutputItemDoneValue = "response.output_item.done"; - private const string ResponseOutputTextAnnotationAddedValue = "response.output_text.annotation.added"; - private const string ResponseOutputTextDeltaValue = "response.output_text.delta"; - private const string ResponseOutputTextDoneValue = "response.output_text.done"; - private const string ResponseRefusalDeltaValue = "response.refusal.delta"; - private const string ResponseRefusalDoneValue = "response.refusal.done"; - private const string ResponseWebSearchCallCompletedValue = "response.web_search_call.completed"; - private const string ResponseWebSearchCallInProgressValue = "response.web_search_call.in_progress"; - private const string ResponseWebSearchCallSearchingValue = "response.web_search_call.searching"; - - public StreamingResponseUpdateKind(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static StreamingResponseUpdateKind Error { get; } = new StreamingResponseUpdateKind(ErrorValue); - - public static StreamingResponseUpdateKind ResponseCompleted { get; } = new StreamingResponseUpdateKind(ResponseCompletedValue); - - public static StreamingResponseUpdateKind ResponseContentPartAdded { get; } = new StreamingResponseUpdateKind(ResponseContentPartAddedValue); - - public static StreamingResponseUpdateKind ResponseContentPartDone { get; } = new StreamingResponseUpdateKind(ResponseContentPartDoneValue); - - public static StreamingResponseUpdateKind ResponseCreated { get; } = new StreamingResponseUpdateKind(ResponseCreatedValue); - - public static StreamingResponseUpdateKind ResponseFailed { get; } = new StreamingResponseUpdateKind(ResponseFailedValue); - - public static StreamingResponseUpdateKind ResponseFileSearchCallCompleted { get; } = new StreamingResponseUpdateKind(ResponseFileSearchCallCompletedValue); - - public static StreamingResponseUpdateKind ResponseFileSearchCallInProgress { get; } = new StreamingResponseUpdateKind(ResponseFileSearchCallInProgressValue); - - public static StreamingResponseUpdateKind ResponseFileSearchCallSearching { get; } = new StreamingResponseUpdateKind(ResponseFileSearchCallSearchingValue); - - public static StreamingResponseUpdateKind ResponseFunctionCallArgumentsDelta { get; } = new StreamingResponseUpdateKind(ResponseFunctionCallArgumentsDeltaValue); - - public static StreamingResponseUpdateKind ResponseFunctionCallArgumentsDone { get; } = new StreamingResponseUpdateKind(ResponseFunctionCallArgumentsDoneValue); - - public static StreamingResponseUpdateKind ResponseInProgress { get; } = new StreamingResponseUpdateKind(ResponseInProgressValue); - - public static StreamingResponseUpdateKind ResponseIncomplete { get; } = new StreamingResponseUpdateKind(ResponseIncompleteValue); - - public static StreamingResponseUpdateKind ResponseOutputItemAdded { get; } = new StreamingResponseUpdateKind(ResponseOutputItemAddedValue); - - public static StreamingResponseUpdateKind ResponseOutputItemDone { get; } = new StreamingResponseUpdateKind(ResponseOutputItemDoneValue); - - public static StreamingResponseUpdateKind ResponseOutputTextAnnotationAdded { get; } = new StreamingResponseUpdateKind(ResponseOutputTextAnnotationAddedValue); - - public static StreamingResponseUpdateKind ResponseOutputTextDelta { get; } = new StreamingResponseUpdateKind(ResponseOutputTextDeltaValue); - - public static StreamingResponseUpdateKind ResponseOutputTextDone { get; } = new StreamingResponseUpdateKind(ResponseOutputTextDoneValue); - - public static StreamingResponseUpdateKind ResponseRefusalDelta { get; } = new StreamingResponseUpdateKind(ResponseRefusalDeltaValue); - - public static StreamingResponseUpdateKind ResponseRefusalDone { get; } = new StreamingResponseUpdateKind(ResponseRefusalDoneValue); - - public static StreamingResponseUpdateKind ResponseWebSearchCallCompleted { get; } = new StreamingResponseUpdateKind(ResponseWebSearchCallCompletedValue); - - public static StreamingResponseUpdateKind ResponseWebSearchCallInProgress { get; } = new StreamingResponseUpdateKind(ResponseWebSearchCallInProgressValue); - - public static StreamingResponseUpdateKind ResponseWebSearchCallSearching { get; } = new StreamingResponseUpdateKind(ResponseWebSearchCallSearchingValue); - - public static bool operator ==(StreamingResponseUpdateKind left, StreamingResponseUpdateKind right) => left.Equals(right); - - public static bool operator !=(StreamingResponseUpdateKind left, StreamingResponseUpdateKind right) => !left.Equals(right); - - public static implicit operator StreamingResponseUpdateKind(string value) => new StreamingResponseUpdateKind(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is StreamingResponseUpdateKind other && Equals(other); - - public bool Equals(StreamingResponseUpdateKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/src/Generated/Models/StreamingResponseWebSearchCallCompletedUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseWebSearchCallCompletedUpdate.Serialization.cs new file mode 100644 index 000000000..da5c54a47 --- /dev/null +++ b/src/Generated/Models/StreamingResponseWebSearchCallCompletedUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseWebSearchCallCompletedUpdate : IJsonModel + { + internal StreamingResponseWebSearchCallCompletedUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallCompletedUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + } + + StreamingResponseWebSearchCallCompletedUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseWebSearchCallCompletedUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallCompletedUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseWebSearchCallCompletedUpdate(document.RootElement, options); + } + + internal static StreamingResponseWebSearchCallCompletedUpdate DeserializeStreamingResponseWebSearchCallCompletedUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseWebSearchCallCompletedUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallCompletedUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseWebSearchCallCompletedUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseWebSearchCallCompletedUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseWebSearchCallCompletedUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallCompletedUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseWebSearchCallCompletedUpdate streamingResponseWebSearchCallCompletedUpdate) + { + if (streamingResponseWebSearchCallCompletedUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseWebSearchCallCompletedUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseWebSearchCallCompletedUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseWebSearchCallCompletedUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseWebSearchCallCompletedUpdate.cs b/src/Generated/Models/StreamingResponseWebSearchCallCompletedUpdate.cs new file mode 100644 index 000000000..7e734e090 --- /dev/null +++ b/src/Generated/Models/StreamingResponseWebSearchCallCompletedUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseWebSearchCallCompletedUpdate : StreamingResponseUpdate + { + internal StreamingResponseWebSearchCallCompletedUpdate(string itemId, int outputIndex) : base(InternalResponsesResponseStreamEventType.ResponseWebSearchCallCompleted) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + internal StreamingResponseWebSearchCallCompletedUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseWebSearchCallInProgressUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseWebSearchCallInProgressUpdate.Serialization.cs new file mode 100644 index 000000000..6086b8309 --- /dev/null +++ b/src/Generated/Models/StreamingResponseWebSearchCallInProgressUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseWebSearchCallInProgressUpdate : IJsonModel + { + internal StreamingResponseWebSearchCallInProgressUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallInProgressUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + } + + StreamingResponseWebSearchCallInProgressUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseWebSearchCallInProgressUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallInProgressUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseWebSearchCallInProgressUpdate(document.RootElement, options); + } + + internal static StreamingResponseWebSearchCallInProgressUpdate DeserializeStreamingResponseWebSearchCallInProgressUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseWebSearchCallInProgressUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallInProgressUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseWebSearchCallInProgressUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseWebSearchCallInProgressUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseWebSearchCallInProgressUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallInProgressUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseWebSearchCallInProgressUpdate streamingResponseWebSearchCallInProgressUpdate) + { + if (streamingResponseWebSearchCallInProgressUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseWebSearchCallInProgressUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseWebSearchCallInProgressUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseWebSearchCallInProgressUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseWebSearchCallInProgressUpdate.cs b/src/Generated/Models/StreamingResponseWebSearchCallInProgressUpdate.cs new file mode 100644 index 000000000..4ab162e76 --- /dev/null +++ b/src/Generated/Models/StreamingResponseWebSearchCallInProgressUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseWebSearchCallInProgressUpdate : StreamingResponseUpdate + { + internal StreamingResponseWebSearchCallInProgressUpdate(string itemId, int outputIndex) : base(InternalResponsesResponseStreamEventType.ResponseWebSearchCallInProgress) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + internal StreamingResponseWebSearchCallInProgressUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + } +} diff --git a/src/Generated/Models/StreamingResponseWebSearchCallSearchingUpdate.Serialization.cs b/src/Generated/Models/StreamingResponseWebSearchCallSearchingUpdate.Serialization.cs new file mode 100644 index 000000000..6f3f9691b --- /dev/null +++ b/src/Generated/Models/StreamingResponseWebSearchCallSearchingUpdate.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseWebSearchCallSearchingUpdate : IJsonModel + { + internal StreamingResponseWebSearchCallSearchingUpdate() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallSearchingUpdate)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("item_id") != true) + { + writer.WritePropertyName("item_id"u8); + writer.WriteStringValue(ItemId); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_index") != true) + { + writer.WritePropertyName("output_index"u8); + writer.WriteNumberValue(OutputIndex); + } + } + + StreamingResponseWebSearchCallSearchingUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StreamingResponseWebSearchCallSearchingUpdate)JsonModelCreateCore(ref reader, options); + + protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallSearchingUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingResponseWebSearchCallSearchingUpdate(document.RootElement, options); + } + + internal static StreamingResponseWebSearchCallSearchingUpdate DeserializeStreamingResponseWebSearchCallSearchingUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponsesResponseStreamEventType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string itemId = default; + int outputIndex = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("item_id"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output_index"u8)) + { + outputIndex = prop.Value.GetInt32(); + continue; + } + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new StreamingResponseWebSearchCallSearchingUpdate(@type, additionalBinaryDataProperties, itemId, outputIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallSearchingUpdate)} does not support writing '{options.Format}' format."); + } + } + + StreamingResponseWebSearchCallSearchingUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StreamingResponseWebSearchCallSearchingUpdate)PersistableModelCreateCore(data, options); + + protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeStreamingResponseWebSearchCallSearchingUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingResponseWebSearchCallSearchingUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(StreamingResponseWebSearchCallSearchingUpdate streamingResponseWebSearchCallSearchingUpdate) + { + if (streamingResponseWebSearchCallSearchingUpdate == null) + { + return null; + } + return BinaryContent.Create(streamingResponseWebSearchCallSearchingUpdate, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator StreamingResponseWebSearchCallSearchingUpdate(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeStreamingResponseWebSearchCallSearchingUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StreamingResponseWebSearchCallSearchingUpdate.cs b/src/Generated/Models/StreamingResponseWebSearchCallSearchingUpdate.cs new file mode 100644 index 000000000..83dc6bd82 --- /dev/null +++ b/src/Generated/Models/StreamingResponseWebSearchCallSearchingUpdate.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Responses +{ + public partial class StreamingResponseWebSearchCallSearchingUpdate : StreamingResponseUpdate + { + internal StreamingResponseWebSearchCallSearchingUpdate(string itemId, int outputIndex) : base(InternalResponsesResponseStreamEventType.ResponseWebSearchCallSearching) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + internal StreamingResponseWebSearchCallSearchingUpdate(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties, string itemId, int outputIndex) : base(@type, additionalBinaryDataProperties) + { + ItemId = itemId; + OutputIndex = outputIndex; + } + + public string ItemId { get; } + + public int OutputIndex { get; } + } +} diff --git a/src/Generated/Models/UnknownResponsesContent.cs b/src/Generated/Models/UnknownResponsesContent.cs deleted file mode 100644 index 20293275b..000000000 --- a/src/Generated/Models/UnknownResponsesContent.cs +++ /dev/null @@ -1,17 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI.Responses; - -namespace OpenAI -{ - internal partial class UnknownResponsesContent : ResponseContentPart - { - internal UnknownResponsesContent(ResponseContentPartKind kind, IDictionary additionalBinaryDataProperties) : base(kind, additionalBinaryDataProperties) - { - } - } -} diff --git a/src/Generated/Models/UnknownResponsesOutputTextAnnotation.cs b/src/Generated/Models/UnknownResponsesOutputTextAnnotation.cs deleted file mode 100644 index 0c3b555b8..000000000 --- a/src/Generated/Models/UnknownResponsesOutputTextAnnotation.cs +++ /dev/null @@ -1,17 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI.Responses; - -namespace OpenAI -{ - internal partial class UnknownResponsesOutputTextAnnotation : ResponseMessageAnnotation - { - internal UnknownResponsesOutputTextAnnotation(ResponseMessageAnnotationKind kind, IDictionary additionalBinaryDataProperties) : base(kind, additionalBinaryDataProperties) - { - } - } -} diff --git a/src/Generated/Models/UnknownResponsesReasoningItemSummaryElement.cs b/src/Generated/Models/UnknownResponsesReasoningItemSummaryElement.cs deleted file mode 100644 index c618d6a69..000000000 --- a/src/Generated/Models/UnknownResponsesReasoningItemSummaryElement.cs +++ /dev/null @@ -1,17 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI.Responses; - -namespace OpenAI -{ - internal partial class UnknownResponsesReasoningItemSummaryElement : InternalResponsesReasoningItemSummaryElement - { - internal UnknownResponsesReasoningItemSummaryElement(InternalResponsesReasoningItemSummaryType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) - { - } - } -} diff --git a/src/Generated/Models/UnknownResponsesResponseStreamEvent.Serialization.cs b/src/Generated/Models/UnknownResponsesResponseStreamEvent.Serialization.cs index cbdab1514..2e9241c99 100644 --- a/src/Generated/Models/UnknownResponsesResponseStreamEvent.Serialization.cs +++ b/src/Generated/Models/UnknownResponsesResponseStreamEvent.Serialization.cs @@ -52,18 +52,18 @@ internal static UnknownResponsesResponseStreamEvent DeserializeUnknownResponsesR { return null; } - StreamingResponseUpdateKind kind = default; + InternalResponsesResponseStreamEventType @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - kind = new StreamingResponseUpdateKind(prop.Value.GetString()); + @type = new InternalResponsesResponseStreamEventType(prop.Value.GetString()); continue; } additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } - return new UnknownResponsesResponseStreamEvent(kind, additionalBinaryDataProperties); + return new UnknownResponsesResponseStreamEvent(@type, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/Models/UnknownResponsesResponseStreamEvent.cs b/src/Generated/Models/UnknownResponsesResponseStreamEvent.cs index 8ee608057..ba87e2c73 100644 --- a/src/Generated/Models/UnknownResponsesResponseStreamEvent.cs +++ b/src/Generated/Models/UnknownResponsesResponseStreamEvent.cs @@ -9,7 +9,7 @@ namespace OpenAI.Responses { internal partial class UnknownResponsesResponseStreamEvent : StreamingResponseUpdate { - internal UnknownResponsesResponseStreamEvent(StreamingResponseUpdateKind kind, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", additionalBinaryDataProperties) + internal UnknownResponsesResponseStreamEvent(InternalResponsesResponseStreamEventType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) { } } diff --git a/src/Generated/Models/UnknownResponsesToolChoiceObject.cs b/src/Generated/Models/UnknownResponsesToolChoiceObject.cs deleted file mode 100644 index cf98164f0..000000000 --- a/src/Generated/Models/UnknownResponsesToolChoiceObject.cs +++ /dev/null @@ -1,17 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI.Responses; - -namespace OpenAI -{ - internal partial class UnknownResponsesToolChoiceObject : InternalResponsesToolChoiceObject - { - internal UnknownResponsesToolChoiceObject(InternalResponsesToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) - { - } - } -} diff --git a/src/Generated/Models/UnknownResponsesWebSearchLocation.cs b/src/Generated/Models/UnknownResponsesWebSearchLocation.cs deleted file mode 100644 index 0c755dfe8..000000000 --- a/src/Generated/Models/UnknownResponsesWebSearchLocation.cs +++ /dev/null @@ -1,17 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI.Responses; - -namespace OpenAI -{ - internal partial class UnknownResponsesWebSearchLocation : WebSearchToolLocation - { - internal UnknownResponsesWebSearchLocation(string @type, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", additionalBinaryDataProperties) - { - } - } -} diff --git a/src/Generated/Models/WebSearchCallResponseItem.cs b/src/Generated/Models/WebSearchCallResponseItem.cs index b10174636..bccdc2e05 100644 --- a/src/Generated/Models/WebSearchCallResponseItem.cs +++ b/src/Generated/Models/WebSearchCallResponseItem.cs @@ -9,6 +9,10 @@ namespace OpenAI.Responses { public partial class WebSearchCallResponseItem : ResponseItem { + public WebSearchCallResponseItem() : base(InternalResponsesItemType.WebSearchCall) + { + } + internal WebSearchCallResponseItem(InternalResponsesItemType @type, string id, IDictionary additionalBinaryDataProperties, WebSearchCallStatus status) : base(@type, id, additionalBinaryDataProperties) { Status = status; diff --git a/src/Generated/Models/WebSearchToolLocation.Serialization.cs b/src/Generated/Models/WebSearchToolLocation.Serialization.cs index 6cbf4214e..4acdd6db5 100644 --- a/src/Generated/Models/WebSearchToolLocation.Serialization.cs +++ b/src/Generated/Models/WebSearchToolLocation.Serialization.cs @@ -79,7 +79,7 @@ internal static WebSearchToolLocation DeserializeWebSearchToolLocation(JsonEleme return InternalResponsesWebSearchApproximateLocation.DeserializeInternalResponsesWebSearchApproximateLocation(element, options); } } - return UnknownResponsesWebSearchLocation.DeserializeUnknownResponsesWebSearchLocation(element, options); + return InternalUnknownResponsesWebSearchLocation.DeserializeInternalUnknownResponsesWebSearchLocation(element, options); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/src/Generated/OpenAIModelFactory.cs b/src/Generated/OpenAIModelFactory.cs index c540279cb..1e3e78e69 100644 --- a/src/Generated/OpenAIModelFactory.cs +++ b/src/Generated/OpenAIModelFactory.cs @@ -89,10 +89,10 @@ public static ResponseReasoningOptions ResponseReasoningOptions(ResponseReasonin return new ResponseReasoningOptions(reasoningEffortLevel, reasoningSummaryVerbosity, additionalBinaryDataProperties: null); } - public static ResponseTextOptions ResponseTextOptions(ResponseTextFormat responseFormat = default) + public static ResponseTextOptions ResponseTextOptions(ResponseTextFormat textFormat = default) { - return new ResponseTextOptions(responseFormat, additionalBinaryDataProperties: null); + return new ResponseTextOptions(textFormat, additionalBinaryDataProperties: null); } public static FileSearchToolRankingOptions FileSearchToolRankingOptions(FileSearchToolRanker? ranker = default, float? scoreThreshold = default) @@ -104,19 +104,13 @@ public static FileSearchToolRankingOptions FileSearchToolRankingOptions(FileSear public static WebSearchToolLocation WebSearchToolLocation(string @type = default) { - return new UnknownResponsesWebSearchLocation(@type, additionalBinaryDataProperties: null); - } - - public static ResponseContentPart ResponseContentPart(string kind = default) - { - - return new UnknownResponsesContent(kind.ToResponseContentPartKind(), additionalBinaryDataProperties: null); + return new InternalUnknownResponsesWebSearchLocation(@type, additionalBinaryDataProperties: null); } public static ResponseMessageAnnotation ResponseMessageAnnotation(string kind = default) { - return new UnknownResponsesOutputTextAnnotation(kind.ToResponseMessageAnnotationKind(), additionalBinaryDataProperties: null); + return new InternalUnknownResponsesOutputTextAnnotation(kind.ToResponseMessageAnnotationKind(), additionalBinaryDataProperties: null); } public static ComputerCallAction ComputerCallAction(string kind = default) @@ -144,18 +138,6 @@ public static FileSearchCallResult FileSearchCallResult(string fileId = default, additionalBinaryDataProperties: null); } - public static StreamingResponseUpdate StreamingResponseUpdate(string kind = default) - { - - return new UnknownResponsesResponseStreamEvent(new StreamingResponseUpdateKind(kind), additionalBinaryDataProperties: null); - } - - public static StreamingResponseErrorUpdate StreamingResponseErrorUpdate(string message = default, string code = default, string @param = default) - { - - return new StreamingResponseErrorUpdate(StreamingResponseUpdateKind.Error, additionalBinaryDataProperties: null, message, code, @param); - } - public static ResponseError ResponseError(string code = default, string message = default) { @@ -180,18 +162,6 @@ public static ResponseOutputTokenUsageDetails ResponseOutputTokenUsageDetails(in return new ResponseOutputTokenUsageDetails(reasoningTokenCount, additionalBinaryDataProperties: null); } - public static StreamingResponseTextAnnotationUpdate StreamingResponseTextAnnotationUpdate(string itemId = default, int outputIndex = default, int contentIndex = default, ResponseMessageAnnotation annotation = default) - { - - return new StreamingResponseTextAnnotationUpdate( - StreamingResponseUpdateKind.ResponseOutputTextAnnotationAdded, - additionalBinaryDataProperties: null, - itemId, - outputIndex, - contentIndex, - annotation); - } - public static ThreadCreationOptions ThreadCreationOptions(IDictionary metadata = default, ToolResources toolResources = default, IEnumerable internalMessages = default) { metadata ??= new ChangeTrackingDictionary(); @@ -838,7 +808,7 @@ public static ChatMessageContent ChatMessageContent() return new ChatMessageContent(additionalBinaryDataProperties: null); } - public static ChatMessageContentPart ChatMessageContentPart(ChatMessageContentPartKind kind = default, string text = default, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default) + public static ChatMessageContentPart ChatMessageContentPart(ChatMessageContentPartKind kind = default, string text = default, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default, InternalChatCompletionRequestMessageContentPartFileFile fileFile = default) { return new ChatMessageContentPart( @@ -847,6 +817,7 @@ public static ChatMessageContentPart ChatMessageContentPart(ChatMessageContentPa imageUri, refusal, inputAudio, + fileFile, serializedAdditionalRawData: null); } diff --git a/src/Generated/VectorStoreClient.RestClient.cs b/src/Generated/VectorStoreClient.RestClient.cs index 1ff1b42cf..d81e0e87a 100644 --- a/src/Generated/VectorStoreClient.RestClient.cs +++ b/src/Generated/VectorStoreClient.RestClient.cs @@ -41,7 +41,6 @@ internal virtual PipelineMessage CreateListVectorStoresRequest(int? limit, strin } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -57,7 +56,6 @@ internal virtual PipelineMessage CreateCreateVectorStoreRequest(BinaryContent co uri.AppendPath("/vector_stores", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); @@ -76,7 +74,6 @@ internal virtual PipelineMessage CreateGetVectorStoreRequest(string vectorStoreI uri.AppendPath(vectorStoreId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -93,7 +90,6 @@ internal virtual PipelineMessage CreateModifyVectorStoreRequest(string vectorSto uri.AppendPath(vectorStoreId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); @@ -112,7 +108,6 @@ internal virtual PipelineMessage CreateDeleteVectorStoreRequest(string vectorSto uri.AppendPath(vectorStoreId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -150,7 +145,6 @@ internal virtual PipelineMessage CreateListVectorStoreFilesRequest(string vector } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -168,7 +162,6 @@ internal virtual PipelineMessage CreateCreateVectorStoreFileRequest(string vecto uri.AppendPath("/files", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); @@ -189,7 +182,6 @@ internal virtual PipelineMessage CreateGetVectorStoreFileRequest(string vectorSt uri.AppendPath(fileId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -208,7 +200,6 @@ internal virtual PipelineMessage CreateDeleteVectorStoreFileRequest(string vecto uri.AppendPath(fileId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -226,7 +217,6 @@ internal virtual PipelineMessage CreateCreateVectorStoreFileBatchRequest(string uri.AppendPath("/file_batches", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); @@ -247,7 +237,6 @@ internal virtual PipelineMessage CreateGetVectorStoreFileBatchRequest(string vec uri.AppendPath(batchId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -267,7 +256,6 @@ internal virtual PipelineMessage CreateCancelVectorStoreFileBatchRequest(string uri.AppendPath("/cancel", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } @@ -307,7 +295,6 @@ internal virtual PipelineMessage CreateListFilesInVectorStoreBatchRequest(string } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); - request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } diff --git a/src/OpenAI.csproj b/src/OpenAI.csproj index d9d0b073b..1eef2d233 100644 --- a/src/OpenAI.csproj +++ b/src/OpenAI.csproj @@ -41,7 +41,7 @@ $(NoWarn),0169 - $(NoWarn),OPENAI001;OPENAI002 + $(NoWarn),OPENAI001;OPENAI002;OPENAICUA001 Debug;Release;Unsigned diff --git a/tests/Assets/files_travis_favorite_food.pdf b/tests/Assets/files_travis_favorite_food.pdf new file mode 100644 index 000000000..40f1dbc4b Binary files /dev/null and b/tests/Assets/files_travis_favorite_food.pdf differ diff --git a/tests/Chat/ChatTests.cs b/tests/Chat/ChatTests.cs index 94368169b..aab533e65 100644 --- a/tests/Chat/ChatTests.cs +++ b/tests/Chat/ChatTests.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel; using NUnit.Framework; using OpenAI.Chat; +using OpenAI.Files; using OpenAI.Tests.Telemetry; using OpenAI.Tests.Utility; using System; @@ -1059,5 +1060,86 @@ public async Task WebSearchWorks() Assert.That(completion.Annotations, Has.Count.GreaterThan(0)); } + [Test] + public async Task FileIdContentWorks() + { + OpenAIFileClient fileClient = GetTestClient(TestScenario.Files); + OpenAIFile testInputFile = await fileClient.UploadFileAsync( + Path.Combine("Assets", "files_travis_favorite_food.pdf"), + FileUploadPurpose.UserData); + Validate(testInputFile); + + ChatMessageContentPart fileIdContentPart + = ChatMessageContentPart.CreateFilePart(testInputFile.Id); + Assert.That(fileIdContentPart.FileId, Is.EqualTo(testInputFile.Id)); + Assert.That(fileIdContentPart.FileBytes, Is.Null); + Assert.That(fileIdContentPart.FileBytesMediaType, Is.Null); + Assert.That(fileIdContentPart.Filename, Is.Null); + + ChatClient client = GetTestClient(); + ChatCompletion completion = await client.CompleteChatAsync( + [ + ChatMessage.CreateUserMessage( + "Based on the following, what food should I order for whom?", + fileIdContentPart) + ]); + Assert.That(completion?.Content, Is.Not.Null.And.Not.Empty); + Assert.That(completion.Content[0].Text?.ToLower(), Does.Contain("pizza")); + } + + [Test] + public async Task FileBinaryContentWorks() + { + ChatMessageContentPart binaryFileContentPart + = ChatMessageContentPart.CreateFilePart( + fileBytes: BinaryData.FromStream( + File.OpenRead( + Path.Combine("Assets", "files_travis_favorite_food.pdf"))), + fileBytesMediaType: "application/pdf", + "test_travis_favorite_food.pdf"); + Assert.That(binaryFileContentPart.FileBytes, Is.Not.Null); + Assert.That(binaryFileContentPart.FileBytesMediaType, Is.EqualTo("application/pdf")); + Assert.That(binaryFileContentPart.Filename, Is.EqualTo("test_travis_favorite_food.pdf")); + Assert.That(binaryFileContentPart.FileId, Is.Null); + + ChatClient client = GetTestClient(); + + ChatCompletion completion = await client.CompleteChatAsync( + [ + ChatMessage.CreateUserMessage( + "Based on the following, what food should I order for whom?", + binaryFileContentPart) + ]); + Assert.That(completion?.Content, Is.Not.Null.And.Not.Empty); + Assert.That(completion.Content[0].Text?.ToLower(), Does.Contain("pizza")); + } + + private List FileIdsToDelete = []; + private void Validate(T item) + { + Assert.IsNotNull(item); + if (item is OpenAIFile file) + { + FileIdsToDelete.Add(file.Id); + } + else + { + Assert.Fail($"Unhandled item type for validation: {item.GetType().Name}"); + } + } + + [OneTimeTearDown] + public void TearDown() + { + OpenAIFileClient fileClient = GetTestClient(TestScenario.Files); + + RequestOptions noThrowOptions = new() { ErrorOptions = ClientErrorBehaviors.NoThrow }; + + foreach (string fileId in FileIdsToDelete) + { + _ = fileClient.DeleteFile(fileId, noThrowOptions); + } + } + private static ChatClient GetTestClient(string overrideModel = null) => GetTestClient(TestScenario.Chat, overrideModel); } diff --git a/tests/Responses/ResponsesSmokeTests.cs b/tests/Responses/ResponsesSmokeTests.cs index 723c3f112..7ae43a973 100644 --- a/tests/Responses/ResponsesSmokeTests.cs +++ b/tests/Responses/ResponsesSmokeTests.cs @@ -1,17 +1,12 @@ using NUnit.Framework; -using OpenAI.Files; using OpenAI.Responses; -using OpenAI.Tests.Utility; using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using static OpenAI.Tests.TestHelpers; namespace OpenAI.Tests.Responses; +#pragma warning disable OPENAICUA001 + [Category("Responses")] [Category("Smoke")] public partial class ResponsesSmokeTests @@ -33,4 +28,132 @@ public void SerializingMessagesWorks() ResponseItem deserializedMessage = ModelReaderWriter.Read(BinaryData.FromString(serializedMessage)); Assert.That(deserializedMessage, Is.Not.Null); } + + [Test] + public void ItemSerialization() + { + foreach (ResponseItem item in new ResponseItem[] + { + ResponseItem.CreateComputerCallItem("call_abcd", ComputerCallAction.CreateScreenshotAction(), []), + ResponseItem.CreateComputerCallOutputItem("call_abcd", [], "file_abcd"), + ResponseItem.CreateFileSearchCallItem(["query1"], []), + ResponseItem.CreateFunctionCallItem("call_abcd", "function_name", BinaryData.Empty), + ResponseItem.CreateFunctionCallOutputItem("call_abcd", "functionOutput"), + ResponseItem.CreateReasoningItem(["summary goes here"]), + ResponseItem.CreateReferenceItem("msg_1234"), + ResponseItem.CreateAssistantMessageItem("Goodbye!", []), + ResponseItem.CreateDeveloperMessageItem("Talk like a pirate"), + ResponseItem.CreateSystemMessageItem("Talk like a ninja"), + ResponseItem.CreateUserMessageItem("Hello, world"), + }) + { + BinaryData serializedItem = ModelReaderWriter.Write(item); + Assert.That(serializedItem?.ToMemory().IsEmpty, Is.False); + ResponseItem deserializedItem = ModelReaderWriter.Read(serializedItem); + Assert.That(deserializedItem?.GetType(), Is.EqualTo(item.GetType())); + } + + AssertSerializationRoundTrip( + @"{""type"":""item_reference"",""id"":""msg_1234""}", + referenceItem => Assert.That(referenceItem.Id, Is.EqualTo("msg_1234"))); + AssertSerializationRoundTrip( + @"{""type"":""message"",""potato_details"":{""cultivar"":""russet""},""role"":""potato""}", + potatoMessage => + { + Assert.That(potatoMessage.Role, Is.EqualTo(MessageRole.Unknown)); + Assert.That(potatoMessage.Content, Has.Count.EqualTo(0)); + }); + } + + [Test] + public void ToolChoiceSerialization() + { + void AssertChoiceEqual(ResponseToolChoice choice, string expected) + { + string serialized = ModelReaderWriter.Write(choice).ToString(); + Assert.That(serialized, Is.EqualTo(expected)); + } + AssertChoiceEqual( + ResponseToolChoice.CreateAutoChoice(), @"""auto"""); + AssertChoiceEqual( + ResponseToolChoice.CreateNoneChoice(), @"""none"""); + AssertChoiceEqual( + ResponseToolChoice.CreateRequiredChoice(), @"""required"""); + AssertChoiceEqual( + ResponseToolChoice.CreateFunctionChoice("foo"), + @"{""type"":""function"",""name"":""foo""}"); + AssertChoiceEqual( + ResponseToolChoice.CreateFileSearchChoice(), + @"{""type"":""file_search""}"); + AssertChoiceEqual( + ResponseToolChoice.CreateComputerChoice(), + @"{""type"":""computer_use_preview""}"); + AssertChoiceEqual( + ResponseToolChoice.CreateWebSearchChoice(), + @"{""type"":""web_search_preview""}"); + + AssertSerializationRoundTrip( + @"{""type"":""something_else""}", + toolChoice => Assert.That(toolChoice.Kind, Is.EqualTo(ResponseToolChoiceKind.Unknown))); + } + + [Test] + public void ToolSerialization() + { + Assert.That( + ModelReaderWriter.Read( + BinaryData.FromString(@"{""type"": ""file_search""}")), + Is.InstanceOf()); + Assert.That( + ModelReaderWriter.Read( + BinaryData.FromString(@"{""type"": ""something_else""}")), + Is.InstanceOf()); + } + + [Test] + public void ContentPartSerialization() + { + AssertSerializationRoundTrip( + @"{""type"":""input_text"",""text"":""hello""}", + textPart => + { + Assert.That(textPart.Kind, Is.EqualTo(ResponseContentPartKind.InputText)); + Assert.That(textPart.Text, Is.EqualTo("hello")); + }); + + + AssertSerializationRoundTrip( + @"{""type"":""potato"",""potato_details"":{""cultivar"":""russet""}}", + potatoPart => + { + Assert.That(potatoPart.Kind, Is.EqualTo(ResponseContentPartKind.Unknown)); + Assert.That(potatoPart.Text, Is.Null); + }); + } + + [Test] + public void TextFormatSerialization() + { + AssertSerializationRoundTrip( + @"{""type"":""text""}", + textFormat => Assert.That(textFormat.Kind == ResponseTextFormatKind.Text)); + } + + private static void AssertSerializationRoundTrip( + string serializedJson, + Action instanceAssertionsAction) + where T : class, IJsonModel + { + BinaryData jsonBytes = BinaryData.FromString(serializedJson); + Assert.That(jsonBytes?.ToMemory().IsEmpty, Is.False); + T deserializedValue = ModelReaderWriter.Read(jsonBytes); + Assert.That(deserializedValue, Is.InstanceOf()); + Assert.Multiple(() => + { + instanceAssertionsAction.Invoke(deserializedValue); + }); + BinaryData reserializedBytes = ModelReaderWriter.Write(deserializedValue); + Assert.That(reserializedBytes.ToMemory().IsEmpty, Is.False); + Assert.That(reserializedBytes.ToString(), Is.EqualTo(serializedJson)); + } } \ No newline at end of file diff --git a/tests/Responses/ResponsesTests.cs b/tests/Responses/ResponsesTests.cs index b924df67d..fe0bd972c 100644 --- a/tests/Responses/ResponsesTests.cs +++ b/tests/Responses/ResponsesTests.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Json; using System.Threading.Tasks; using static OpenAI.Tests.TestHelpers; @@ -125,18 +126,22 @@ public async Task FileSearch() } [Test] - public async Task ChatWithCua() + public async Task ComputerToolWithScreenshotRoundTrip() { OpenAIResponseClient client = GetTestClient("computer-use-preview-2025-03-11"); - ResponseTool computerTool = ResponseTool.CreateComputerTool(1024, 768, ComputerToolEnvironment.Windows); + ResponseCreationOptions responseOptions = new() + { + Tools = { computerTool }, + TruncationMode = ResponseTruncationMode.Auto, + }; OpenAIResponse response = await client.CreateResponseAsync( inputItems: [ ResponseItem.CreateDeveloperMessageItem("Call tools when the user asks to perform computer-related tasks like clicking interface elements."), ResponseItem.CreateUserMessageItem("Click on the Save button.") ], - new ResponseCreationOptions() { Tools = { computerTool } }); + responseOptions); while (true) { @@ -154,13 +159,8 @@ public async Task ChatWithCua() screenshotBytes, "image/png"); - response = await client.CreateResponseAsync( - [screenshotReply], - new ResponseCreationOptions() - { - PreviousResponseId = response.Id, - Tools = { computerTool }, - }); + responseOptions.PreviousResponseId = response.Id; + response = await client.CreateResponseAsync([screenshotReply], responseOptions); } else if (computerCall.Action.Kind == ComputerCallActionKind.Click) { @@ -177,13 +177,10 @@ public async Task ChatWithCua() || assistantText.Contains("could you confirm") || assistantText.Contains("please confirm"))) { + responseOptions.PreviousResponseId = response.Id; response = await client.CreateResponseAsync( "Yes, proceed.", - new ResponseCreationOptions() - { - PreviousResponseId = response.Id, - Tools = { computerTool } - }); + responseOptions); } else { @@ -243,36 +240,39 @@ public async Task WebSearchCallStreaming() await foreach (StreamingResponseUpdate update in client.CreateResponseStreamingAsync(message, responseOptions)) { - if (update is StreamingResponseWebSearchCallUpdate webCallUpdate) + if (update is StreamingResponseWebSearchCallInProgressUpdate searchCallInProgressUpdate) { - Assert.That(webCallUpdate.OutputItemId, Is.Not.Null.And.Not.Empty); - searchItemId ??= webCallUpdate.OutputItemId; - Assert.That(searchItemId, Is.EqualTo(webCallUpdate.OutputItemId)); - Assert.That(webCallUpdate.OutputItemIndex, Is.EqualTo(0)); - if (webCallUpdate.Kind == StreamingResponseUpdateKind.ResponseWebSearchCallInProgress) - { - inProgressCount++; - } - else if (webCallUpdate.Kind == StreamingResponseUpdateKind.ResponseWebSearchCallSearching) - { - searchingCount++; - } - else if (webCallUpdate.Kind == StreamingResponseUpdateKind.ResponseWebSearchCallCompleted) - { - completedCount++; - } + Assert.That(searchCallInProgressUpdate.ItemId, Is.Not.Null.And.Not.Empty); + searchItemId ??= searchCallInProgressUpdate.ItemId; + Assert.That(searchItemId, Is.EqualTo(searchCallInProgressUpdate.ItemId)); + Assert.That(searchCallInProgressUpdate.OutputIndex, Is.EqualTo(0)); + inProgressCount++; } - else if (update is StreamingResponseItemUpdate itemUpdate - && itemUpdate.Kind == StreamingResponseUpdateKind.ResponseOutputItemDone) + else if (update is StreamingResponseWebSearchCallSearchingUpdate searchCallSearchingUpdate) { - if (itemUpdate.Item is WebSearchCallResponseItem finishedWebSearchCall) + Assert.That(searchCallSearchingUpdate.ItemId, Is.Not.Null.And.Not.Empty); + searchItemId ??= searchCallSearchingUpdate.ItemId; + Assert.That(searchItemId, Is.EqualTo(searchCallSearchingUpdate.ItemId)); + Assert.That(searchCallSearchingUpdate.OutputIndex, Is.EqualTo(0)); + searchingCount++; + } + else if (update is StreamingResponseWebSearchCallCompletedUpdate searchCallCompletedUpdate) + { + Assert.That(searchCallCompletedUpdate.ItemId, Is.Not.Null.And.Not.Empty); + searchItemId ??= searchCallCompletedUpdate.ItemId; + Assert.That(searchItemId, Is.EqualTo(searchCallCompletedUpdate.ItemId)); + Assert.That(searchCallCompletedUpdate.OutputIndex, Is.EqualTo(0)); + completedCount++; + } + else if (update is StreamingResponseOutputItemDoneUpdate outputItemDoneUpdate) + { + if (outputItemDoneUpdate.Item is WebSearchCallResponseItem webSearchCallItem) { - Assert.That(finishedWebSearchCall.Status, Is.EqualTo(WebSearchCallStatus.Completed)); - Assert.That(finishedWebSearchCall.Id, Is.EqualTo(searchItemId)); + Assert.That(webSearchCallItem.Status, Is.EqualTo(WebSearchCallStatus.Completed)); + Assert.That(webSearchCallItem.Id, Is.EqualTo(searchItemId)); gotFinishedSearchItem = true; } } - // Console.WriteLine(ModelReaderWriter.Write(update).ToString()); } Assert.Multiple(() => { @@ -290,26 +290,24 @@ public async Task StreamingResponses() OpenAIResponseClient client = GetTestClient("gpt-4o-mini"); // "computer-use-alpha"); List inputItems = [ResponseItem.CreateUserMessageItem("Hello, world!")]; + List deltaTextSegments = []; + string finalResponseText = null; await foreach (StreamingResponseUpdate update in client.CreateResponseStreamingAsync(inputItems)) { Console.WriteLine(ModelReaderWriter.Write(update)); - if (update is StreamingResponseContentPartDeltaUpdate deltaUpdate) + if (update is StreamingResponseOutputTextDeltaUpdate outputTextDeltaUpdate) + { + deltaTextSegments.Add(outputTextDeltaUpdate.Delta); + Console.Write(outputTextDeltaUpdate.Delta); + } + else if (update is StreamingResponseCompletedUpdate responseCompletedUpdate) { - Console.Write(deltaUpdate.Text); + finalResponseText = responseCompletedUpdate.Response.GetOutputText(); } } - } - - [Test] - [Category("Smoke")] - public void DeserializeStreamingWrapper() - { - string serializedEvent = """ - {"type":"response.output_text.delta","item_id":"msg_67cbd19634ac8190a8d1fe7d421960e0","output_index":0,"content_index":0,"delta":"Hello"} - """; - StreamingResponseContentPartDeltaUpdate deltaUpdate = ModelReaderWriter.Read(BinaryData.FromString(serializedEvent)); - Assert.That(deltaUpdate, Is.Not.Null); - Assert.That(deltaUpdate.Text, Is.EqualTo("Hello")); + Assert.That(deltaTextSegments, Has.Count.GreaterThan(0)); + Assert.That(finalResponseText, Is.Not.Null.And.Not.Empty); + Assert.That(string.Join(string.Empty, deltaTextSegments), Is.EqualTo(finalResponseText)); } [Test] @@ -339,6 +337,7 @@ public async Task ResponsesHelloWorldWithTool(string model) """), functionSchemaIsStrict: false), }, + TruncationMode = ResponseTruncationMode.Auto, }; OpenAIResponse response = await client.CreateResponseAsync( @@ -382,7 +381,7 @@ public async Task ResponsesWithReasoning() Assert.That(response, Is.Not.Null); Assert.That(response.Id, Is.Not.Null); Assert.That(response.CreatedAt, Is.GreaterThan(new DateTimeOffset(2025, 1, 1, 0, 0, 0, TimeSpan.Zero))); - Assert.That(response.TruncationMode, Is.EqualTo(ResponseTruncationMode.Auto)); + Assert.That(response.TruncationMode, Is.EqualTo(ResponseTruncationMode.Disabled)); Assert.That(response.MaxOutputTokenCount, Is.Null); Assert.That(response.Model, Does.StartWith("o3-mini")); Assert.That(response.Usage, Is.Not.Null); @@ -399,22 +398,25 @@ public async Task ResponsesWithReasoning() } [Test] - [TestCase("computer-use-preview-2025-02-04")] + [TestCase("computer-use-preview-2025-03-11")] [TestCase("gpt-4o-mini")] public async Task HelloWorldStreaming(string model) { OpenAIResponseClient client = GetTestClient(model); - ResponseContentPart contentPart = ResponseContentPart.CreateInputTextPart("Hello, responses!"); + ResponseContentPart contentPart + = ResponseContentPart.CreateInputTextPart("Hello, responses!"); ResponseItem inputItem = ResponseItem.CreateUserMessageItem([contentPart]); - await foreach (StreamingResponseUpdate update in client.CreateResponseStreamingAsync([inputItem])) + await foreach (StreamingResponseUpdate update + in client.CreateResponseStreamingAsync( + [inputItem], + new ResponseCreationOptions() + { + TruncationMode = ResponseTruncationMode.Auto, + })) { Console.WriteLine(ModelReaderWriter.Write(update)); - //if (update is ResponsesItemStreamingPartDeltaUpdate partDeltaUpdate) - //{ - // Console.Write(partDeltaUpdate.Text); - //} } } @@ -456,7 +458,28 @@ public async Task CanOptOutOfStorage() } [Test] - [Ignore("Assistant message needs an ID.")] + public async Task OutputTextMethod() + { + OpenAIResponseClient client = GetTestClient(); + OpenAIResponse response = await client.CreateResponseAsync( + "Respond with only the word hello."); + Assert.That(response?.GetOutputText()?.Length, Is.GreaterThan(0).And.LessThan(7)); + Assert.That(response?.GetOutputText()?.ToLower(), Does.Contain("hello")); + + response.OutputItems.Add(ResponseItem.CreateAssistantMessageItem("More text!")); + Assert.That(response?.GetOutputText()?.ToLower(), Does.EndWith("more text!")); + + response = await client.CreateResponseAsync( + "How's the weather?", + new ResponseCreationOptions() + { + Tools = { ResponseTool.CreateFunctionTool("get_weather", "gets the weather", BinaryData.FromString("{}")) }, + ToolChoice = ResponseToolChoice.CreateRequiredChoice(), + }); + Assert.That(response.GetOutputText(), Is.Null); + } + + [Test] public async Task MessageHistoryWorks() { OpenAIResponseClient client = GetTestClient(); @@ -465,7 +488,7 @@ public async Task MessageHistoryWorks() [ ResponseItem.CreateDeveloperMessageItem("You are a helpful assistant."), ResponseItem.CreateUserMessageItem("Hello, Assistant, my name is Bob!"), - ResponseItem.CreateAssistantMessageItem("1", "Hello, Bob. It's a nice, sunny day!"), + ResponseItem.CreateAssistantMessageItem("Hello, Bob. It's a nice, sunny day!"), ResponseItem.CreateUserMessageItem("What's my name and what did you tell me the weather was like?"), ]); @@ -584,6 +607,55 @@ public async Task TwoTurnCrossModel() }); } + [Test] + [TestCase("gpt-4o-mini")] + [TestCase("computer-use-preview", Ignore = "Not yet supported with computer-use-preview")] + public async Task StructuredOutputs(string modelName) + { + OpenAIResponseClient client = GetTestClient(modelName); + + OpenAIResponse response = await client.CreateResponseAsync( + "Write a JSON document with a list of five animals", + new ResponseCreationOptions() + { + TextOptions = new ResponseTextOptions() + { + TextFormat = ResponseTextFormat.CreateJsonSchemaFormat( + "data_list", + BinaryData.FromString(""" + { + "type": "object", + "properties": { + "animal_data_list": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["animal_data_list"], + "additionalProperties": false + } + """)), + } + }); + + Assert.That( + response?.TextOptions?.TextFormat?.Kind, + Is.EqualTo(ResponseTextFormatKind.JsonSchema)); + Assert.That(response?.OutputItems, Has.Count.EqualTo(1)); + MessageResponseItem message = response.OutputItems[0] as MessageResponseItem; + Assert.That(message?.Content, Has.Count.EqualTo(1)); + Assert.That(message.Content[0].Text, Is.Not.Null.And.Not.Empty); + + Assert.DoesNotThrow(() => + { + using JsonDocument document = JsonDocument.Parse(message.Content[0].Text); + bool hasListElement = document.RootElement.TryGetProperty("animal_data_list", out JsonElement listElement); + Assert.That(hasListElement, Is.True); + }); + } + [Test] public async Task FunctionCall() { @@ -605,6 +677,12 @@ public async Task FunctionCall() Assert.That(functionCall.FunctionName, Is.EqualTo("get_weather_at_location")); Assert.That(functionCall.FunctionArguments, Is.Not.Null); + Assert.DoesNotThrow(() => + { + using JsonDocument document = JsonDocument.Parse(functionCall.FunctionArguments); + _ = document.RootElement.GetProperty("location"); + }); + ResponseCreationOptions turn2Options = new() { PreviousResponseId = response.Id, @@ -623,6 +701,26 @@ public async Task FunctionCall() Assert.That(turn2Message.Content[0].Text, Does.Contain("22")); } + [Test] + public async Task MaxTokens() + { + OpenAIResponseClient client = GetTestClient(); + + OpenAIResponse response = await client.CreateResponseAsync( + "Write three haikus about tropical fruit", + new ResponseCreationOptions() + { + MaxOutputTokenCount = 20, + }); + + Assert.That( + response?.IncompleteStatusDetails?.Reason, + Is.EqualTo(ResponseIncompleteStatusReason.MaxOutputTokens)); + MessageResponseItem message = response?.OutputItems?.FirstOrDefault() as MessageResponseItem; ; + Assert.That(message?.Content?.FirstOrDefault(), Is.Not.Null); + Assert.That(message?.Status, Is.EqualTo(MessageStatus.Incomplete)); + } + [Test] public async Task FunctionCallStreaming() { @@ -633,19 +731,47 @@ in client.CreateResponseStreamingAsync( "What should I wear for the weather in San Francisco right now?", new ResponseCreationOptions() { Tools = { s_GetWeatherAtLocationTool } })) { - if (update is StreamingResponseStatusUpdate statusUpdate) + Console.WriteLine(ModelReaderWriter.Write(update).ToString()); + if (update is StreamingResponseCreatedUpdate responseCreatedUpdate) { - Console.WriteLine($"{statusUpdate.Kind}: {statusUpdate.Response.Id}"); + Console.WriteLine($"response.created: {responseCreatedUpdate.Response.Id}"); } - else if (update is StreamingResponseContentPartDeltaUpdate deltaUpdate) + else if (update is StreamingResponseFunctionCallArgumentsDeltaUpdate functionCallArgumentsDeltaUpdate) { - Console.Write(deltaUpdate.FunctionArguments); + Console.Write(functionCallArgumentsDeltaUpdate.Delta); } } } - private static string s_GetWeatherAtLocationToolName = "get_weather_at_location"; - private static ResponseTool s_GetWeatherAtLocationTool = ResponseTool.CreateFunctionTool( + [Test] + public async Task FunctionToolChoiceWorks() + { + OpenAIResponseClient client = GetTestClient(); + + ResponseToolChoice toolChoice + = ResponseToolChoice.CreateFunctionChoice(s_GetWeatherAtLocationToolName); + + ResponseCreationOptions options = new() + { + Tools = { s_GetWeatherAtLocationTool }, + ToolChoice = toolChoice, + }; + + OpenAIResponse response = await client.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("What should I wear for the weather in San Francisco, CA?")], + options); + + Assert.That(response.ToolChoice, Is.Not.Null); + Assert.That(response.ToolChoice.Kind, Is.EqualTo(ResponseToolChoiceKind.Function)); + Assert.That(response.ToolChoice.FunctionName, Is.EqualTo(toolChoice.FunctionName)); + + FunctionCallResponseItem functionCall = response.OutputItems.FirstOrDefault() as FunctionCallResponseItem; + Assert.That(functionCall, Is.Not.Null); + Assert.That(functionCall.FunctionName, Is.EqualTo(toolChoice.FunctionName)); + } + + private static readonly string s_GetWeatherAtLocationToolName = "get_weather_at_location"; + private static readonly ResponseTool s_GetWeatherAtLocationTool = ResponseTool.CreateFunctionTool( s_GetWeatherAtLocationToolName, "Gets the weather at a specified location, optionally specifying units for temperature", BinaryData.FromString("""