From cd267b39eb50838961cf34d9ec9e0f517439d0b9 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 27 Mar 2024 18:33:15 -0700 Subject: [PATCH 1/4] port smaller set of feedback changes --- .dotnet/src/Custom/Assistants/Assistant.cs | 16 ++++++--- .../src/Custom/Assistants/AssistantClient.cs | 12 +++---- .../Assistants/AssistantCreationOptions.cs | 9 ++--- .../AssistantModificationOptions.cs | 11 +++---- .../src/Custom/Assistants/AssistantThread.cs | 2 +- .../Assistants/CodeInterpreterToolInfo.cs | 1 - .../Assistants/FunctionToolDefinition.cs | 14 +++----- .../src/Custom/Assistants/FunctionToolInfo.cs | 10 ++---- .../MessageContent.Serialization.cs | 3 -- .../Assistants/MessageCreationOptions.cs | 3 -- .../Assistants/MessageImageFileContent.cs | 1 - .../Custom/Assistants/MessageTextContent.cs | 3 +- .../Assistants/RequiredFunctionToolCall.cs | 5 ++- .../src/Custom/Assistants/RequiredToolCall.cs | 1 - .../Assistants/RetrievalToolDefinition.cs | 1 - .../Custom/Assistants/RetrievalToolInfo.cs | 1 - .../Custom/Assistants/RunCreationOptions.cs | 15 +++------ .dotnet/src/Custom/Assistants/RunError.cs | 2 -- .../Assistants/RunModificationOptions.cs | 3 -- .../RunRequiredAction.Serialization.cs | 3 -- .../TextContentAnnotation.Serialization.cs | 3 -- .../TextContentFileCitationAnnotation.cs | 1 - .../TextContentFilePathAnnotation.cs | 1 - .../Assistants/ThreadCreationOptions.cs | 3 -- .../Assistants/ThreadInitializationMessage.cs | 3 -- .../src/Custom/Assistants/ThreadMessage.cs | 4 +-- .dotnet/src/Custom/Assistants/ThreadRun.cs | 13 ++++---- .../Assistants/ToolInfo.Serialization.cs | 3 -- .../Assistants/ToolOutput.Serialization.cs | 4 --- .dotnet/src/Custom/Assistants/ToolOutput.cs | 6 ++-- .dotnet/src/Custom/Audio/AudioClient.cs | 2 +- .dotnet/src/Custom/Audio/AudioDataFormat.cs | 5 +++ .../src/Custom/Audio/AudioTranscription.cs | 12 +++---- .../Custom/Audio/AudioTranscriptionFormat.cs | 3 -- .../Custom/Audio/AudioTranscriptionOptions.cs | 12 +++---- .../Custom/Audio/AudioTranslationOptions.cs | 6 ++-- .../src/Custom/Audio/TextToSpeechOptions.cs | 4 +-- ...iptionSegment.cs => TranscribedSegment.cs} | 11 +++---- .dotnet/src/Custom/Chat/ChatCompletion.cs | 10 ++---- .../src/Custom/Chat/ChatCompletionOptions.cs | 32 +++++++++--------- .../Chat/ChatFunctionCall.Serialization.cs | 4 --- .../src/Custom/Chat/ChatFunctionDefinition.cs | 10 +++--- .../src/Custom/Chat/ChatFunctionToolCall.cs | 2 -- .../Custom/Chat/ChatFunctionToolDefinition.cs | 10 +++--- .../Chat/ChatLogProbabilityCollection.cs | 2 +- .dotnet/src/Custom/Chat/ChatMessageContent.cs | 10 ++++-- .../Chat/ChatRequestAssistantMessage.cs | 6 ++-- .../Custom/Chat/ChatRequestFunctionMessage.cs | 3 +- .../Chat/ChatRequestMessage.Serialization.cs | 5 --- .dotnet/src/Custom/Chat/ChatRequestMessage.cs | 3 -- .../Custom/Chat/ChatRequestSystemMessage.cs | 13 ++------ .../src/Custom/Chat/ChatRequestToolMessage.cs | 8 +---- .../src/Custom/Chat/ChatRequestUserMessage.cs | 16 +++------ .dotnet/src/Custom/Chat/ChatResponseFormat.cs | 2 -- .../Custom/Chat/ChatToolCall.Serialization.cs | 3 -- .dotnet/src/Custom/Chat/ChatToolCall.cs | 2 +- .dotnet/src/Custom/Chat/ChatToolConstraint.cs | 2 +- .../src/Custom/Chat/StreamingChatUpdate.cs | 2 +- .../Chat/StreamingFunctionToolCallUpdate.cs | 4 +-- .../src/Custom/Embeddings/EmbeddingOptions.cs | 4 +-- .dotnet/src/Custom/Files/OpenAIFileInfo.cs | 12 ++++--- .../FineTuning/FineTuningManagementClient.cs | 3 +- .../Custom/Images/GeneratedImageCollection.cs | 13 ++++++-- ...ageQuality.cs => GeneratedImageQuality.cs} | 2 +- ...cs => GeneratedImageSize.Serialization.cs} | 14 ++++---- .../src/Custom/Images/GeneratedImageSize.cs | 10 +++--- .../{ImageStyle.cs => GeneratedImageStyle.cs} | 2 +- .dotnet/src/Custom/Images/ImageClient.cs | 33 ++++++------------- .dotnet/src/Custom/Images/ImageEditOptions.cs | 10 +++--- .../Custom/Images/ImageGenerationOptions.cs | 18 +++++----- .../Custom/Images/ImageVariationOptions.cs | 6 ++-- .../Custom/Models/ModelManagementClient.cs | 2 -- .dotnet/src/Custom/OpenAIClient.cs | 13 -------- .dotnet/src/Custom/OpenAIClientConnector.cs | 3 -- .dotnet/src/Custom/OpenAIClientOptions.cs | 5 +-- .../Assistants/Sample03_FunctionCalling.cs | 6 ++-- .../Sample03_FunctionCallingAsync.cs | 2 +- .../Samples/Chat/Sample03_FunctionCalling.cs | 4 +-- .dotnet/tests/Samples/CombinationSamples.cs | 12 +++---- .../Samples/Images/Sample01_SimpleImage.cs | 4 +-- .../Images/Sample01_SimpleImageAsync.cs | 4 +-- .dotnet/tests/TestScenarios/AssistantTests.cs | 2 +- .../TestScenarios/ChatToolConstraints.cs | 16 ++++----- .dotnet/tests/TestScenarios/ChatToolTests.cs | 8 ++--- .../TestScenarios/ImageGenerationTests.cs | 4 +-- .../tests/TestScenarios/LegacyCompletions.cs | 2 -- .../tests/TestScenarios/TextToSpeechTests.cs | 6 +--- .dotnet/tests/Utility/TestHelpers.cs | 1 - 88 files changed, 229 insertions(+), 353 deletions(-) rename .dotnet/src/Custom/Audio/{TranscriptionSegment.cs => TranscribedSegment.cs} (83%) rename .dotnet/src/Custom/Images/{ImageQuality.cs => GeneratedImageQuality.cs} (96%) rename .dotnet/src/Custom/Images/{ImageSize.Serialization.cs => GeneratedImageSize.Serialization.cs} (80%) rename .dotnet/src/Custom/Images/{ImageStyle.cs => GeneratedImageStyle.cs} (95%) diff --git a/.dotnet/src/Custom/Assistants/Assistant.cs b/.dotnet/src/Custom/Assistants/Assistant.cs index 02dcede78..9bfee0a6c 100644 --- a/.dotnet/src/Custom/Assistants/Assistant.cs +++ b/.dotnet/src/Custom/Assistants/Assistant.cs @@ -33,16 +33,22 @@ internal Assistant(Internal.Models.AssistantObject internalAssistant) Description = internalAssistant.Description; DefaultModel = internalAssistant.Model; DefaultInstructions = internalAssistant.Instructions; - Metadata = internalAssistant.Metadata; + DefaultTools = GetToolsFromInternalTools(internalAssistant.Tools); + Metadata = internalAssistant.Metadata ?? new Dictionary(); + } - if (internalAssistant.Tools != null) + private static IReadOnlyList GetToolsFromInternalTools(IReadOnlyList? internalTools) + { + if (internalTools is not null) { List tools = []; - foreach (BinaryData unionToolDefinitionData in internalAssistant.Tools) + foreach (BinaryData unionToolDefinitionData in internalTools) { - tools.Add(ToolDefinition.DeserializeToolDefinition(JsonDocument.Parse(unionToolDefinitionData).RootElement)); + using JsonDocument toolDocument = JsonDocument.Parse(unionToolDefinitionData); + tools.Add(ToolDefinition.DeserializeToolDefinition(toolDocument.RootElement)); } - DefaultTools = tools; + return tools; } + return []; } } diff --git a/.dotnet/src/Custom/Assistants/AssistantClient.cs b/.dotnet/src/Custom/Assistants/AssistantClient.cs index 7543c0330..9cef5a52e 100644 --- a/.dotnet/src/Custom/Assistants/AssistantClient.cs +++ b/.dotnet/src/Custom/Assistants/AssistantClient.cs @@ -626,10 +626,10 @@ internal static Internal.Models.CreateRunRequest CreateInternalCreateRunRequest( options ??= new(); return new( assistantId, - options.OverrideModel, - options.OverrideInstructions, + options.ModelOverride, + options.InstructionsOverride, options.AdditionalInstructions, - ToInternalBinaryDataList(options.OverrideTools), + ToInternalBinaryDataList(options.ToolsOverride), options.Metadata, serializedAdditionalRawData: null); } @@ -645,9 +645,9 @@ internal static Internal.Models.CreateThreadAndRunRequest CreateInternalCreateTh return new Internal.Models.CreateThreadAndRunRequest( assistantId, internalThreadOptions, - runOptions?.OverrideModel, - runOptions.OverrideInstructions, - ToInternalBinaryDataList(runOptions?.OverrideTools), + runOptions?.ModelOverride, + runOptions.InstructionsOverride, + ToInternalBinaryDataList(runOptions?.ToolsOverride), runOptions?.Metadata, serializedAdditionalRawData: null); } diff --git a/.dotnet/src/Custom/Assistants/AssistantCreationOptions.cs b/.dotnet/src/Custom/Assistants/AssistantCreationOptions.cs index 527a1eb77..c9fc98897 100644 --- a/.dotnet/src/Custom/Assistants/AssistantCreationOptions.cs +++ b/.dotnet/src/Custom/Assistants/AssistantCreationOptions.cs @@ -1,6 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System.ClientModel.Internal; - using System.Collections.Generic; namespace OpenAI.Assistants; @@ -13,16 +10,16 @@ public partial class AssistantCreationOptions /// /// An optional display name for the assistant. /// - public string Name { get; set; } + public string Name { get; init; } /// /// A description to associate with the assistant. /// - public string Description { get; set; } + public string Description { get; init; } /// /// Default instructions for the assistant to use when creating messages. /// - public string Instructions { get; set; } + public string Instructions { get; init; } /// /// A collection of default tool definitions to enable for the assistant. Available tools include: diff --git a/.dotnet/src/Custom/Assistants/AssistantModificationOptions.cs b/.dotnet/src/Custom/Assistants/AssistantModificationOptions.cs index c8c3bbe01..e02bde1e0 100644 --- a/.dotnet/src/Custom/Assistants/AssistantModificationOptions.cs +++ b/.dotnet/src/Custom/Assistants/AssistantModificationOptions.cs @@ -1,6 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System.ClientModel.Internal; - using System.Collections.Generic; namespace OpenAI.Assistants; @@ -13,22 +10,22 @@ public partial class AssistantModificationOptions /// /// The new model that the assistant should use when creating messages. /// - public string Model { get; } + public string Model { get; init; } /// /// A new, friendly name for the assistant. Its will remain unchanged. /// - public string Name { get; } + public string Name { get; init; } /// /// A new description to associate with the assistant. /// - public string Description { get; } + public string Description { get; init; } /// /// New, default instructions for the assistant to use when creating messages. /// - public string Instructions { get; } + public string Instructions { get; init; } /// /// A new collection of default tool definitions to enable for the assistant. Available tools include: diff --git a/.dotnet/src/Custom/Assistants/AssistantThread.cs b/.dotnet/src/Custom/Assistants/AssistantThread.cs index f6c85c9ad..2ed33a4b7 100644 --- a/.dotnet/src/Custom/Assistants/AssistantThread.cs +++ b/.dotnet/src/Custom/Assistants/AssistantThread.cs @@ -24,7 +24,7 @@ public partial class AssistantThread internal AssistantThread(Internal.Models.ThreadObject internalThread) { Id = internalThread.Id; - Metadata = internalThread.Metadata; + Metadata = internalThread.Metadata ?? new Dictionary(); CreatedAt = internalThread.CreatedAt; } diff --git a/.dotnet/src/Custom/Assistants/CodeInterpreterToolInfo.cs b/.dotnet/src/Custom/Assistants/CodeInterpreterToolInfo.cs index b464fd2f3..d82bbb88f 100644 --- a/.dotnet/src/Custom/Assistants/CodeInterpreterToolInfo.cs +++ b/.dotnet/src/Custom/Assistants/CodeInterpreterToolInfo.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/FunctionToolDefinition.cs b/.dotnet/src/Custom/Assistants/FunctionToolDefinition.cs index d6687feec..e07733ddf 100644 --- a/.dotnet/src/Custom/Assistants/FunctionToolDefinition.cs +++ b/.dotnet/src/Custom/Assistants/FunctionToolDefinition.cs @@ -1,24 +1,20 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Diagnostics.CodeAnalysis; using System.Text.Json; -using OpenAI.ClientShared.Internal; namespace OpenAI.Assistants; public partial class FunctionToolDefinition : ToolDefinition { - public required string Name { get; set; } - public string Description { get; set; } - public BinaryData Parameters { get; set; } + public required string FunctionName { get; init; } + public string Description { get; init; } + public BinaryData Parameters { get; init; } [SetsRequiredMembers] public FunctionToolDefinition(string name, string description = null, BinaryData parameters = null) { - Name = name; + FunctionName = name; Description = description; Parameters = parameters; } @@ -74,7 +70,7 @@ internal override void WriteDerived(Utf8JsonWriter writer, ModelReaderWriterOpti writer.WriteString("type"u8, "function"u8); writer.WritePropertyName("function"u8); writer.WriteStartObject(); - writer.WriteString("name"u8, Name); + writer.WriteString("name"u8, FunctionName); if (Optional.IsDefined(Description)) { writer.WriteString("description"u8, Description); diff --git a/.dotnet/src/Custom/Assistants/FunctionToolInfo.cs b/.dotnet/src/Custom/Assistants/FunctionToolInfo.cs index b6edc1fc5..2ed22a59b 100644 --- a/.dotnet/src/Custom/Assistants/FunctionToolInfo.cs +++ b/.dotnet/src/Custom/Assistants/FunctionToolInfo.cs @@ -1,22 +1,18 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; -using OpenAI.ClientShared.Internal; namespace OpenAI.Assistants; public partial class FunctionToolInfo : ToolInfo { - public string Name { get; } + public string FunctionName { get; } public string Description { get; } public BinaryData Parameters { get; } internal FunctionToolInfo(string name, string description, BinaryData parameters) { - Name = name; + FunctionName = name; Description = description; Parameters = parameters; } @@ -68,7 +64,7 @@ internal override void WriteDerived(Utf8JsonWriter writer, ModelReaderWriterOpti writer.WriteString("type"u8, "function"u8); writer.WritePropertyName("function"u8); writer.WriteStartObject(); - writer.WriteString("name"u8, Name); + writer.WriteString("name"u8, FunctionName); if (Optional.IsDefined(Description)) { writer.WriteString("description"u8, Description); diff --git a/.dotnet/src/Custom/Assistants/MessageContent.Serialization.cs b/.dotnet/src/Custom/Assistants/MessageContent.Serialization.cs index 4d88129b3..200eeebe8 100644 --- a/.dotnet/src/Custom/Assistants/MessageContent.Serialization.cs +++ b/.dotnet/src/Custom/Assistants/MessageContent.Serialization.cs @@ -1,7 +1,4 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/MessageCreationOptions.cs b/.dotnet/src/Custom/Assistants/MessageCreationOptions.cs index b11119fa3..9f6e230f8 100644 --- a/.dotnet/src/Custom/Assistants/MessageCreationOptions.cs +++ b/.dotnet/src/Custom/Assistants/MessageCreationOptions.cs @@ -1,6 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System.ClientModel.Internal; - using System.Collections.Generic; namespace OpenAI.Assistants; diff --git a/.dotnet/src/Custom/Assistants/MessageImageFileContent.cs b/.dotnet/src/Custom/Assistants/MessageImageFileContent.cs index 68997b045..9460d4bea 100644 --- a/.dotnet/src/Custom/Assistants/MessageImageFileContent.cs +++ b/.dotnet/src/Custom/Assistants/MessageImageFileContent.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/MessageTextContent.cs b/.dotnet/src/Custom/Assistants/MessageTextContent.cs index 43c0433ad..025a47aab 100644 --- a/.dotnet/src/Custom/Assistants/MessageTextContent.cs +++ b/.dotnet/src/Custom/Assistants/MessageTextContent.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; @@ -18,7 +17,7 @@ public class MessageTextContent : MessageContent internal MessageTextContent(string text, IReadOnlyList annotations) { Text = text; - Annotations = annotations; + Annotations = annotations ?? []; } internal override void WriteDerived(Utf8JsonWriter writer, ModelReaderWriterOptions options) diff --git a/.dotnet/src/Custom/Assistants/RequiredFunctionToolCall.cs b/.dotnet/src/Custom/Assistants/RequiredFunctionToolCall.cs index f0807495c..b3f6197c6 100644 --- a/.dotnet/src/Custom/Assistants/RequiredFunctionToolCall.cs +++ b/.dotnet/src/Custom/Assistants/RequiredFunctionToolCall.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; @@ -6,13 +5,13 @@ namespace OpenAI.Assistants; public partial class RequiredFunctionToolCall : RequiredToolCall { - public string Name { get; } + public string FunctionName { get; } public string Arguments { get; } internal RequiredFunctionToolCall(string id, string name, string arguments) : base(id) { - Name = name; + FunctionName = name; Arguments = arguments; } diff --git a/.dotnet/src/Custom/Assistants/RequiredToolCall.cs b/.dotnet/src/Custom/Assistants/RequiredToolCall.cs index 19e951d2c..2d8587e34 100644 --- a/.dotnet/src/Custom/Assistants/RequiredToolCall.cs +++ b/.dotnet/src/Custom/Assistants/RequiredToolCall.cs @@ -1,5 +1,4 @@ using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/RetrievalToolDefinition.cs b/.dotnet/src/Custom/Assistants/RetrievalToolDefinition.cs index f18579c87..8ad2222c4 100644 --- a/.dotnet/src/Custom/Assistants/RetrievalToolDefinition.cs +++ b/.dotnet/src/Custom/Assistants/RetrievalToolDefinition.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/RetrievalToolInfo.cs b/.dotnet/src/Custom/Assistants/RetrievalToolInfo.cs index 1b58f35a4..c806f7d2c 100644 --- a/.dotnet/src/Custom/Assistants/RetrievalToolInfo.cs +++ b/.dotnet/src/Custom/Assistants/RetrievalToolInfo.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/RunCreationOptions.cs b/.dotnet/src/Custom/Assistants/RunCreationOptions.cs index b584aafa3..f1b66cf3d 100644 --- a/.dotnet/src/Custom/Assistants/RunCreationOptions.cs +++ b/.dotnet/src/Custom/Assistants/RunCreationOptions.cs @@ -1,6 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System.ClientModel.Internal; - using System.Collections.Generic; namespace OpenAI.Assistants; @@ -10,26 +7,24 @@ namespace OpenAI.Assistants; /// public partial class RunCreationOptions { - - /// /// A run-specific model name that will override the assistant's defined model. If not provided, the assistant's /// selection will be used. /// - public string OverrideModel { get; set; } + public string ModelOverride { get; init; } /// /// A run specific replacement for the assistant's default instructions that will override the assistant-level /// instructions. If not specified, the assistant's instructions will be used. /// - public string OverrideInstructions { get; set; } + public string InstructionsOverride { get; init; } /// /// Run-specific additional instructions that will be appended to the assistant-level instructions solely for this - /// run. Unlike , the assistant's instructions are preserved and these additional + /// run. Unlike , the assistant's instructions are preserved and these additional /// instructions are concatenated. /// - public string AdditionalInstructions { get; set; } + public string AdditionalInstructions { get; init; } /// /// A run-specific collection of tool definitions that will override the assistant-level defaults. If not provided, @@ -51,7 +46,7 @@ public partial class RunCreationOptions /// /// /// - public IList OverrideTools { get; } = new ChangeTrackingList(); + public IList ToolsOverride { get; } = new ChangeTrackingList(); /// /// An optional key/value mapping of additional, supplemental data items to attach to the . diff --git a/.dotnet/src/Custom/Assistants/RunError.cs b/.dotnet/src/Custom/Assistants/RunError.cs index b53777c3d..acd16bf68 100644 --- a/.dotnet/src/Custom/Assistants/RunError.cs +++ b/.dotnet/src/Custom/Assistants/RunError.cs @@ -1,5 +1,3 @@ -using OpenAI.Chat; - namespace OpenAI.Assistants; public partial class RunError diff --git a/.dotnet/src/Custom/Assistants/RunModificationOptions.cs b/.dotnet/src/Custom/Assistants/RunModificationOptions.cs index 3142669f0..f1e5f3de2 100644 --- a/.dotnet/src/Custom/Assistants/RunModificationOptions.cs +++ b/.dotnet/src/Custom/Assistants/RunModificationOptions.cs @@ -1,6 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System.ClientModel.Internal; - using System.Collections.Generic; namespace OpenAI.Assistants; diff --git a/.dotnet/src/Custom/Assistants/RunRequiredAction.Serialization.cs b/.dotnet/src/Custom/Assistants/RunRequiredAction.Serialization.cs index e9ba0d3ac..bbb8447d1 100644 --- a/.dotnet/src/Custom/Assistants/RunRequiredAction.Serialization.cs +++ b/.dotnet/src/Custom/Assistants/RunRequiredAction.Serialization.cs @@ -1,7 +1,4 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/TextContentAnnotation.Serialization.cs b/.dotnet/src/Custom/Assistants/TextContentAnnotation.Serialization.cs index b7ba4eedb..24d6158a6 100644 --- a/.dotnet/src/Custom/Assistants/TextContentAnnotation.Serialization.cs +++ b/.dotnet/src/Custom/Assistants/TextContentAnnotation.Serialization.cs @@ -1,7 +1,4 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/TextContentFileCitationAnnotation.cs b/.dotnet/src/Custom/Assistants/TextContentFileCitationAnnotation.cs index 459b91a94..7964ae4c0 100644 --- a/.dotnet/src/Custom/Assistants/TextContentFileCitationAnnotation.cs +++ b/.dotnet/src/Custom/Assistants/TextContentFileCitationAnnotation.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/TextContentFilePathAnnotation.cs b/.dotnet/src/Custom/Assistants/TextContentFilePathAnnotation.cs index 7e716bc6c..d4792c0f0 100644 --- a/.dotnet/src/Custom/Assistants/TextContentFilePathAnnotation.cs +++ b/.dotnet/src/Custom/Assistants/TextContentFilePathAnnotation.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/ThreadCreationOptions.cs b/.dotnet/src/Custom/Assistants/ThreadCreationOptions.cs index 39246b756..44cfc82a1 100644 --- a/.dotnet/src/Custom/Assistants/ThreadCreationOptions.cs +++ b/.dotnet/src/Custom/Assistants/ThreadCreationOptions.cs @@ -1,6 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System.ClientModel.Internal; - using System.Collections.Generic; namespace OpenAI.Assistants; diff --git a/.dotnet/src/Custom/Assistants/ThreadInitializationMessage.cs b/.dotnet/src/Custom/Assistants/ThreadInitializationMessage.cs index 797789a5e..e956de4ba 100644 --- a/.dotnet/src/Custom/Assistants/ThreadInitializationMessage.cs +++ b/.dotnet/src/Custom/Assistants/ThreadInitializationMessage.cs @@ -1,6 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System.ClientModel.Internal; - using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; diff --git a/.dotnet/src/Custom/Assistants/ThreadMessage.cs b/.dotnet/src/Custom/Assistants/ThreadMessage.cs index 01b481b36..3135da0c9 100644 --- a/.dotnet/src/Custom/Assistants/ThreadMessage.cs +++ b/.dotnet/src/Custom/Assistants/ThreadMessage.cs @@ -53,8 +53,8 @@ internal ThreadMessage(Internal.Models.MessageObject internalMessage) AssistantId = internalMessage.AssistantId; ThreadId = internalMessage.ThreadId; RunId = internalMessage.RunId; - Metadata = internalMessage.Metadata; - FileIds = internalMessage.FileIds; + Metadata = internalMessage.Metadata ?? new Dictionary(); + FileIds = internalMessage.FileIds ?? []; CreatedAt = internalMessage.CreatedAt; Role = convertedRole; ContentItems = content; diff --git a/.dotnet/src/Custom/Assistants/ThreadRun.cs b/.dotnet/src/Custom/Assistants/ThreadRun.cs index fa65d9c08..2aaf65ced 100644 --- a/.dotnet/src/Custom/Assistants/ThreadRun.cs +++ b/.dotnet/src/Custom/Assistants/ThreadRun.cs @@ -61,9 +61,8 @@ internal ThreadRun(Internal.Models.RunObject internalRun) "expired" => RunStatus.Expired, _ => throw new ArgumentException(nameof(Status)), }; - Metadata = internalRun.Metadata; - FileIds = internalRun.FileIds; - Metadata = internalRun.Metadata; + Metadata = internalRun.Metadata ?? new Dictionary(); + FileIds = internalRun.FileIds ?? []; Model = internalRun.Model; Instructions = internalRun.Instructions; @@ -77,21 +76,21 @@ internal ThreadRun(Internal.Models.RunObject internalRun) Usage = new(internalRun.Usage); } + List tools = []; if (internalRun.Tools != null) { - List tools = []; foreach (BinaryData unionToolInfo in internalRun.Tools) { tools.Add(ToolInfo.DeserializeToolInfo(JsonDocument.Parse(unionToolInfo).RootElement)); } - Tools = tools; } + Tools = tools; + List actions = []; IReadOnlyList internalFunctionCalls = internalRun.RequiredAction?.SubmitToolOutputs?.ToolCalls; if (internalFunctionCalls != null) { - List actions = []; foreach (Internal.Models.RunToolCallObject internalToolCall in internalFunctionCalls) { actions.Add(new RequiredFunctionToolCall( @@ -99,7 +98,7 @@ internal ThreadRun(Internal.Models.RunObject internalRun) internalToolCall.Function.Name, internalToolCall.Function.Arguments)); } - RequiredActions = actions; } + RequiredActions = actions; } } diff --git a/.dotnet/src/Custom/Assistants/ToolInfo.Serialization.cs b/.dotnet/src/Custom/Assistants/ToolInfo.Serialization.cs index ae8d31b33..ff5ecaed2 100644 --- a/.dotnet/src/Custom/Assistants/ToolInfo.Serialization.cs +++ b/.dotnet/src/Custom/Assistants/ToolInfo.Serialization.cs @@ -1,7 +1,4 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Assistants/ToolOutput.Serialization.cs b/.dotnet/src/Custom/Assistants/ToolOutput.Serialization.cs index 33557cacc..b61ef3b52 100644 --- a/.dotnet/src/Custom/Assistants/ToolOutput.Serialization.cs +++ b/.dotnet/src/Custom/Assistants/ToolOutput.Serialization.cs @@ -1,10 +1,6 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; -using OpenAI.ClientShared.Internal; namespace OpenAI.Assistants; diff --git a/.dotnet/src/Custom/Assistants/ToolOutput.cs b/.dotnet/src/Custom/Assistants/ToolOutput.cs index 623da2461..8b7f064d0 100644 --- a/.dotnet/src/Custom/Assistants/ToolOutput.cs +++ b/.dotnet/src/Custom/Assistants/ToolOutput.cs @@ -5,10 +5,8 @@ namespace OpenAI.Assistants; public partial class ToolOutput { - [JsonPropertyName("tool_call_id")] - public required string Id { get; set; } - [JsonPropertyName("output")] - public string Output { get; set; } + public required string Id { get; init; } + public string Output { get; init; } public ToolOutput() { } diff --git a/.dotnet/src/Custom/Audio/AudioClient.cs b/.dotnet/src/Custom/Audio/AudioClient.cs index 28e3a3ab5..abdb39edc 100644 --- a/.dotnet/src/Custom/Audio/AudioClient.cs +++ b/.dotnet/src/Custom/Audio/AudioClient.cs @@ -3,7 +3,6 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.IO; -using System.Runtime.InteropServices.ComTypes; using System.Text; using System.Threading.Tasks; @@ -314,6 +313,7 @@ private Internal.Models.CreateSpeechRequest CreateInternalTtsRequest( AudioDataFormat.Mpga => "mpga", AudioDataFormat.Ogg => "ogg", AudioDataFormat.Opus => "opus", + AudioDataFormat.Pcm => "pcm", AudioDataFormat.Wav => "wav", AudioDataFormat.Webm => "webm", _ => throw new ArgumentException(nameof(options.ResponseFormat)), diff --git a/.dotnet/src/Custom/Audio/AudioDataFormat.cs b/.dotnet/src/Custom/Audio/AudioDataFormat.cs index b8840ca44..56eb96870 100644 --- a/.dotnet/src/Custom/Audio/AudioDataFormat.cs +++ b/.dotnet/src/Custom/Audio/AudioDataFormat.cs @@ -74,6 +74,11 @@ public enum AudioDataFormat /// Opus, /// + /// PCM, an uncompressed, lossless format that is similar to WAV but uses headerless 24khz audio chunks rather than + /// a header-configured format. + /// + Pcm, + /// /// WAV, an uncompressed, lossless format with maximum quality, highest file size, and minimal decoding. /// /// wav is supported as input into translation and transcription but is not available for diff --git a/.dotnet/src/Custom/Audio/AudioTranscription.cs b/.dotnet/src/Custom/Audio/AudioTranscription.cs index efd5a0e8d..8f16a9687 100644 --- a/.dotnet/src/Custom/Audio/AudioTranscription.cs +++ b/.dotnet/src/Custom/Audio/AudioTranscription.cs @@ -11,15 +11,15 @@ public partial class AudioTranscription public TimeSpan? Duration { get; } public string Text { get; } public IReadOnlyList Words { get; } - public IReadOnlyList Segments { get; } + public IReadOnlyList Segments { get; } - internal AudioTranscription(string language, TimeSpan? duration, string text, IReadOnlyList words, IReadOnlyList segments) + internal AudioTranscription(string language, TimeSpan? duration, string text, IReadOnlyList words, IReadOnlyList segments) { Language = language; Duration = duration; Text = text; - Words = words; - Segments = segments; + Words = words ?? []; + Segments = segments ?? []; } internal static AudioTranscription Deserialize(BinaryData content) @@ -34,7 +34,7 @@ internal static AudioTranscription DeserializeAudioTranscription(JsonElement ele TimeSpan? duration = null; string text = null; List words = null; - List segments = null; + List segments = null; foreach (JsonProperty topLevelProperty in element.EnumerateObject()) { @@ -67,7 +67,7 @@ internal static AudioTranscription DeserializeAudioTranscription(JsonElement ele segments = []; foreach (JsonElement segmentElement in topLevelProperty.Value.EnumerateArray()) { - segments.Add(TranscriptionSegment.DeserializeTranscriptionSegment(segmentElement, options)); + segments.Add(TranscribedSegment.DeserializeTranscriptionSegment(segmentElement, options)); } continue; } diff --git a/.dotnet/src/Custom/Audio/AudioTranscriptionFormat.cs b/.dotnet/src/Custom/Audio/AudioTranscriptionFormat.cs index 73e283ae6..68b02bc34 100644 --- a/.dotnet/src/Custom/Audio/AudioTranscriptionFormat.cs +++ b/.dotnet/src/Custom/Audio/AudioTranscriptionFormat.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; - namespace OpenAI.Audio; public enum AudioTranscriptionFormat diff --git a/.dotnet/src/Custom/Audio/AudioTranscriptionOptions.cs b/.dotnet/src/Custom/Audio/AudioTranscriptionOptions.cs index 40318342f..16c04c007 100644 --- a/.dotnet/src/Custom/Audio/AudioTranscriptionOptions.cs +++ b/.dotnet/src/Custom/Audio/AudioTranscriptionOptions.cs @@ -8,12 +8,12 @@ namespace OpenAI.Audio; public partial class AudioTranscriptionOptions { - public string Language { get; set; } - public string Prompt { get; set; } - public AudioTranscriptionFormat? ResponseFormat { get; set; } - public float? Temperature { get; set; } - public bool? EnableWordTimestamps { get; set; } - public bool? EnableSegmentTimestamps { get; set; } + public string Language { get; init; } + public string Prompt { get; init; } + public AudioTranscriptionFormat? ResponseFormat { get; init; } + public float? Temperature { get; init; } + public bool? EnableWordTimestamps { get; init; } + public bool? EnableSegmentTimestamps { get; init; } internal MultipartFormDataBinaryContent ToMultipartContent(Stream fileStream, string fileName, string model) { diff --git a/.dotnet/src/Custom/Audio/AudioTranslationOptions.cs b/.dotnet/src/Custom/Audio/AudioTranslationOptions.cs index b927043f9..61fcd1cb6 100644 --- a/.dotnet/src/Custom/Audio/AudioTranslationOptions.cs +++ b/.dotnet/src/Custom/Audio/AudioTranslationOptions.cs @@ -6,9 +6,9 @@ namespace OpenAI.Audio; public partial class AudioTranslationOptions { - public string Prompt { get; set; } - public AudioTranscriptionFormat? ResponseFormat { get; set; } - public float? Temperature { get; set; } + public string Prompt { get; init; } + public AudioTranscriptionFormat? ResponseFormat { get; init; } + public float? Temperature { get; init; } internal MultipartFormDataBinaryContent ToMultipartContent(Stream fileStream, string fileName, string model) { diff --git a/.dotnet/src/Custom/Audio/TextToSpeechOptions.cs b/.dotnet/src/Custom/Audio/TextToSpeechOptions.cs index 476d564af..1c74dbbc0 100644 --- a/.dotnet/src/Custom/Audio/TextToSpeechOptions.cs +++ b/.dotnet/src/Custom/Audio/TextToSpeechOptions.cs @@ -19,11 +19,11 @@ public partial class TextToSpeechOptions /// /// /// - public AudioDataFormat? ResponseFormat { get; set; } + public AudioDataFormat? ResponseFormat { get; init; } /// /// A multiplicative speed factor to apply to the generated audio, with 1.0 being the default and valid /// values ranging from 0.25 to 4.0. /// - public float? SpeedMultiplier { get; set; } + public float? SpeedMultiplier { get; init; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Audio/TranscriptionSegment.cs b/.dotnet/src/Custom/Audio/TranscribedSegment.cs similarity index 83% rename from .dotnet/src/Custom/Audio/TranscriptionSegment.cs rename to .dotnet/src/Custom/Audio/TranscribedSegment.cs index a40aba765..6e3aeb5d9 100644 --- a/.dotnet/src/Custom/Audio/TranscriptionSegment.cs +++ b/.dotnet/src/Custom/Audio/TranscribedSegment.cs @@ -2,11 +2,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using System.Threading; namespace OpenAI.Audio; -public readonly partial struct TranscriptionSegment +public readonly partial struct TranscribedSegment { public int Id { get; } public int SeekOffset { get; } @@ -19,21 +18,21 @@ public readonly partial struct TranscriptionSegment public float CompressionRatio { get; } public float NoSpeechProbability { get; } - internal TranscriptionSegment(int id, int seekOffset, TimeSpan start, TimeSpan end, string text, IReadOnlyList tokenIds, float temperature, float averageLogProbability, float compressionRatio, float noSpeechProbability) + internal TranscribedSegment(int id, int seekOffset, TimeSpan start, TimeSpan end, string text, IReadOnlyList tokenIds, float temperature, float averageLogProbability, float compressionRatio, float noSpeechProbability) { Id = id; SeekOffset = seekOffset; Start = start; End = end; Text = text; - TokenIds = tokenIds; + TokenIds = tokenIds ?? []; Temperature = temperature; AverageLogProbability = averageLogProbability; CompressionRatio = compressionRatio; NoSpeechProbability = noSpeechProbability; } - internal static TranscriptionSegment DeserializeTranscriptionSegment(JsonElement element, ModelReaderWriterOptions options = default) + internal static TranscribedSegment DeserializeTranscriptionSegment(JsonElement element, ModelReaderWriterOptions options = default) { int id = 0; int seekOffset = 0; @@ -104,6 +103,6 @@ internal static TranscriptionSegment DeserializeTranscriptionSegment(JsonElement } } - return new TranscriptionSegment(id, seekOffset, start, end, text, tokenIds, temperature, averageLogProbability, compressionRatio, noSpeechProbability); + return new TranscribedSegment(id, seekOffset, start, end, text, tokenIds, temperature, averageLogProbability, compressionRatio, noSpeechProbability); } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatCompletion.cs b/.dotnet/src/Custom/Chat/ChatCompletion.cs index 08c6a75cd..26319c2dd 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletion.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletion.cs @@ -1,4 +1,3 @@ -using OpenAI.ClientShared.Internal; using System; using System.Collections.Generic; @@ -58,9 +57,9 @@ internal ChatCompletion(Internal.Models.CreateChatCompletionResponse internalRes _ => throw new ArgumentException(nameof(internalChoice.FinishReason)), }; Content = internalChoice.Message.Content; + ChangeTrackingList toolCalls = []; if (internalChoice.Message.ToolCalls != null) { - ChangeTrackingList toolCalls = []; foreach (Internal.Models.ChatCompletionMessageToolCall internalToolCall in internalChoice.Message.ToolCalls) { if (internalToolCall.Type == "function") @@ -68,15 +67,12 @@ internal ChatCompletion(Internal.Models.CreateChatCompletionResponse internalRes toolCalls.Add(new ChatFunctionToolCall(internalToolCall.Id, internalToolCall.Function.Name, internalToolCall.Function.Arguments)); } } - ToolCalls = toolCalls; } + ToolCalls = toolCalls; if (internalChoice.Message.FunctionCall != null) { FunctionCall = new(internalChoice.Message.FunctionCall.Name, internalChoice.Message.FunctionCall.Arguments); } - if (internalChoice.Logprobs != null) - { - LogProbabilities = ChatLogProbabilityCollection.FromInternalData(internalChoice.Logprobs); - } + LogProbabilities = ChatLogProbabilityCollection.FromInternalData(internalChoice.Logprobs); } } diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs index 69dfd7e8f..16619acc7 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs @@ -1,6 +1,4 @@ -using OpenAI.ClientShared.Internal; using System; -using System.ClientModel.Internal; using System.Collections.Generic; using System.Text.Json; @@ -13,37 +11,37 @@ namespace OpenAI.Chat; public partial class ChatCompletionOptions { /// - public double? FrequencyPenalty { get; set; } + public double? FrequencyPenalty { get; init; } /// - public IDictionary TokenSelectionBiases { get; set; } = new ChangeTrackingDictionary(); + public IDictionary TokenSelectionBiases { get; init; } = new ChangeTrackingDictionary(); /// - public bool? IncludeLogProbabilities { get; set; } + public bool? IncludeLogProbabilities { get; init; } /// - public int? LogProbabilityCount { get; set; } + public int? LogProbabilityCount { get; init; } /// - public int? MaxTokens { get; set; } + public int? MaxTokens { get; init; } /// - public double? PresencePenalty { get; set; } + public double? PresencePenalty { get; init; } /// - public ChatResponseFormat? ResponseFormat { get; set; } + public ChatResponseFormat? ResponseFormat { get; init; } /// - public int? Seed { get; set; } + public int? Seed { get; init; } /// public IList StopSequences { get; } = new ChangeTrackingList(); /// - public double? Temperature { get; set; } + public double? Temperature { get; init; } /// - public double? NucleusSamplingFactor { get; set; } + public double? NucleusSamplingFactor { get; init; } /// public IList Tools { get; } = new ChangeTrackingList(); /// - public ChatToolConstraint? ToolConstraint { get; set; } + public ChatToolConstraint? ToolConstraint { get; init; } /// - public string User { get; set; } + public string User { get; init; } /// public IList Functions { get; } = new ChangeTrackingList(); /// - public ChatFunctionConstraint? FunctionConstraint { get; set; } + public ChatFunctionConstraint? FunctionConstraint { get; init; } internal BinaryData GetInternalStopSequences() { @@ -73,7 +71,7 @@ internal IDictionary GetInternalLogitBias() { Internal.Models.FunctionObject functionObject = new( functionTool.Description, - functionTool.Name, + functionTool.FunctionName, CreateInternalFunctionParameters(functionTool.Parameters), serializedAdditionalRawData: null); internalTools.Add(new(functionObject)); @@ -89,7 +87,7 @@ internal IDictionary GetInternalLogitBias() { Internal.Models.ChatCompletionFunctions internalFunction = new( function.Description, - function.Name, + function.FunctionName, CreateInternalFunctionParameters(function.Parameters), serializedAdditionalRawData: null); internalFunctions.Add(internalFunction); diff --git a/.dotnet/src/Custom/Chat/ChatFunctionCall.Serialization.cs b/.dotnet/src/Custom/Chat/ChatFunctionCall.Serialization.cs index 8af52a6b0..714ee4edc 100644 --- a/.dotnet/src/Custom/Chat/ChatFunctionCall.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatFunctionCall.Serialization.cs @@ -1,9 +1,5 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Chat; diff --git a/.dotnet/src/Custom/Chat/ChatFunctionDefinition.cs b/.dotnet/src/Custom/Chat/ChatFunctionDefinition.cs index ddcbb6ffa..6b459613e 100644 --- a/.dotnet/src/Custom/Chat/ChatFunctionDefinition.cs +++ b/.dotnet/src/Custom/Chat/ChatFunctionDefinition.cs @@ -11,12 +11,12 @@ public class ChatFunctionDefinition /// /// The name of the function. /// - public required string Name { get; set; } + public required string FunctionName { get; init; } /// - /// A friendly description of the function. This supplements in informing the model about when + /// A friendly description of the function. This supplements in informing the model about when /// it should call the function. /// - public string Description { get; set; } + public string Description { get; init; } /// /// The parameter information for the function, provided in JSON Schema format. /// @@ -39,7 +39,7 @@ public class ChatFunctionDefinition /// }) /// /// - public BinaryData Parameters { get; set; } + public BinaryData Parameters { get; init; } /// /// Creates a new instance of . /// @@ -53,7 +53,7 @@ public ChatFunctionDefinition() { } [SetsRequiredMembers] public ChatFunctionDefinition(string name, string description = null, BinaryData parameters = null) { - Name = name; + FunctionName = name; Description = description; Parameters = parameters; } diff --git a/.dotnet/src/Custom/Chat/ChatFunctionToolCall.cs b/.dotnet/src/Custom/Chat/ChatFunctionToolCall.cs index 5a6a823b6..3a2786e7d 100644 --- a/.dotnet/src/Custom/Chat/ChatFunctionToolCall.cs +++ b/.dotnet/src/Custom/Chat/ChatFunctionToolCall.cs @@ -1,5 +1,3 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Diagnostics.CodeAnalysis; using System.Text.Json; diff --git a/.dotnet/src/Custom/Chat/ChatFunctionToolDefinition.cs b/.dotnet/src/Custom/Chat/ChatFunctionToolDefinition.cs index 313b76aec..a4d37517c 100644 --- a/.dotnet/src/Custom/Chat/ChatFunctionToolDefinition.cs +++ b/.dotnet/src/Custom/Chat/ChatFunctionToolDefinition.cs @@ -11,12 +11,12 @@ public class ChatFunctionToolDefinition : ChatToolDefinition /// /// The name of the function that the tool represents. /// - public required string Name { get; set; } + public required string FunctionName { get; init; } /// - /// A friendly description of the function. This supplements in informing the model about when + /// A friendly description of the function. This supplements in informing the model about when /// it should call the function. /// - public string Description { get; set; } + public string Description { get; init; } /// /// The parameter information for the function, provided in JSON Schema format. /// @@ -39,7 +39,7 @@ public class ChatFunctionToolDefinition : ChatToolDefinition /// }) /// /// - public BinaryData Parameters { get; set; } + public BinaryData Parameters { get; init; } /// /// Creates a new instance of . /// @@ -53,7 +53,7 @@ public ChatFunctionToolDefinition() { } [SetsRequiredMembers] public ChatFunctionToolDefinition(string name, string description = null, BinaryData parameters = null) { - Name = name; + FunctionName = name; Description = description; Parameters = parameters; } diff --git a/.dotnet/src/Custom/Chat/ChatLogProbabilityCollection.cs b/.dotnet/src/Custom/Chat/ChatLogProbabilityCollection.cs index 01accec6c..96d5cd0dd 100644 --- a/.dotnet/src/Custom/Chat/ChatLogProbabilityCollection.cs +++ b/.dotnet/src/Custom/Chat/ChatLogProbabilityCollection.cs @@ -16,7 +16,7 @@ internal static ChatLogProbabilityCollection FromInternalData( { if (internalLogprobs == null) { - return null; + return new([]); } List logProbabilities = []; foreach (Internal.Models.ChatCompletionTokenLogprob internalLogprob in internalLogprobs.Content) diff --git a/.dotnet/src/Custom/Chat/ChatMessageContent.cs b/.dotnet/src/Custom/Chat/ChatMessageContent.cs index 0a4b9d6d8..37ac4ca64 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContent.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContent.cs @@ -96,10 +96,16 @@ public Uri ToUri() public static implicit operator ChatMessageContent(string value) => FromText(value); /// - /// An implicit operator allowing a content item to be treated as a string. + /// An explicit operator allowing a content item to be treated as a string. /// /// - public static implicit operator string(ChatMessageContent content) => content.ToText(); + public static explicit operator string(ChatMessageContent content) => content.ToText(); + + /// + /// An explicit operator allowing a content item to be treated as a URI. + /// + /// + public static explicit operator Uri(ChatMessageContent content) => content.ToUri(); /// public override string ToString() diff --git a/.dotnet/src/Custom/Chat/ChatRequestAssistantMessage.cs b/.dotnet/src/Custom/Chat/ChatRequestAssistantMessage.cs index eb80d71ea..2105b4716 100644 --- a/.dotnet/src/Custom/Chat/ChatRequestAssistantMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatRequestAssistantMessage.cs @@ -17,7 +17,7 @@ public class ChatRequestAssistantMessage : ChatRequestMessage /// An optional name associated with the assistant message. This is typically defined with a system /// message and is used to differentiate between multiple participants of the same role. /// - public string Name { get; set; } + public string ParticipantName { get; init; } /// /// The tool_calls furnished by the model that are needed to continue the logical conversation across chat @@ -105,9 +105,9 @@ public ChatRequestAssistantMessage(ChatCompletion chatCompletion) internal override void WriteDerivedAdditions(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - if (Optional.IsDefined(Name)) + if (Optional.IsDefined(ParticipantName)) { - writer.WriteString("name"u8, Name); + writer.WriteString("name"u8, ParticipantName); } if (Optional.IsCollectionDefined(ToolCalls)) { diff --git a/.dotnet/src/Custom/Chat/ChatRequestFunctionMessage.cs b/.dotnet/src/Custom/Chat/ChatRequestFunctionMessage.cs index f1190771e..c2fbc40cc 100644 --- a/.dotnet/src/Custom/Chat/ChatRequestFunctionMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatRequestFunctionMessage.cs @@ -1,4 +1,3 @@ -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; @@ -15,7 +14,7 @@ public class ChatRequestFunctionMessage : ChatRequestMessage /// /// The name of the called function that this message provides information from. /// - public string FunctionName { get; set; } // JSON "name" + public string FunctionName { get; } // JSON "name" /// /// Creates a new instance of . diff --git a/.dotnet/src/Custom/Chat/ChatRequestMessage.Serialization.cs b/.dotnet/src/Custom/Chat/ChatRequestMessage.Serialization.cs index 96cc4991f..66790a4a8 100644 --- a/.dotnet/src/Custom/Chat/ChatRequestMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatRequestMessage.Serialization.cs @@ -1,11 +1,6 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; -using System.ComponentModel.Design; using System.Text.Json; -using OpenAI.ClientShared.Internal; namespace OpenAI.Chat; diff --git a/.dotnet/src/Custom/Chat/ChatRequestMessage.cs b/.dotnet/src/Custom/Chat/ChatRequestMessage.cs index 38444eb4e..9bb8d9222 100644 --- a/.dotnet/src/Custom/Chat/ChatRequestMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatRequestMessage.cs @@ -1,7 +1,4 @@ using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections; using System.Collections.Generic; namespace OpenAI.Chat; diff --git a/.dotnet/src/Custom/Chat/ChatRequestSystemMessage.cs b/.dotnet/src/Custom/Chat/ChatRequestSystemMessage.cs index 6081118d0..379b5ee2b 100644 --- a/.dotnet/src/Custom/Chat/ChatRequestSystemMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatRequestSystemMessage.cs @@ -1,12 +1,5 @@ -using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; -using System.Dynamic; -using System.Runtime.InteropServices; using System.Text.Json; -using OpenAI.ClientShared.Internal; namespace OpenAI.Chat; @@ -21,7 +14,7 @@ public class ChatRequestSystemMessage : ChatRequestMessage /// /// An optional name for the participant. /// - public string Name { get; set; } // JSON "name" + public string ParticipantName { get; set; } // JSON "name" /// /// Creates a new instance of . @@ -31,9 +24,9 @@ public ChatRequestSystemMessage(string content) : base(ChatRole.System, content) internal override void WriteDerivedAdditions(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - if (Optional.IsDefined(Name)) + if (Optional.IsDefined(ParticipantName)) { - writer.WriteString("name"u8, Name); + writer.WriteString("name"u8, ParticipantName); } } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatRequestToolMessage.cs b/.dotnet/src/Custom/Chat/ChatRequestToolMessage.cs index 4208700ec..a131ad2ef 100644 --- a/.dotnet/src/Custom/Chat/ChatRequestToolMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatRequestToolMessage.cs @@ -1,10 +1,5 @@ -using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; -using System.Diagnostics.CodeAnalysis; namespace OpenAI.Chat; @@ -30,7 +25,7 @@ public class ChatRequestToolMessage : ChatRequestMessage /// /// The id correlating to the prior made by the model. /// - public required string ToolCallId { get; set; } + public string ToolCallId { get; } /// /// Creates a new instance of . @@ -41,7 +36,6 @@ public class ChatRequestToolMessage : ChatRequestMessage /// that resolves the tool call and allows the logical conversation to continue. No format restrictions (e.g. /// JSON) are imposed on the content emitted by tools. /// - [SetsRequiredMembers] public ChatRequestToolMessage(string toolCallId, string content) : base(ChatRole.Tool, content) { diff --git a/.dotnet/src/Custom/Chat/ChatRequestUserMessage.cs b/.dotnet/src/Custom/Chat/ChatRequestUserMessage.cs index 79704394b..1885b5ade 100644 --- a/.dotnet/src/Custom/Chat/ChatRequestUserMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatRequestUserMessage.cs @@ -1,13 +1,7 @@ -using System.ClientModel.Internal; - -using System; -using System.Collections.Generic; -using System.Dynamic; -using System.Text.Json; -using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Linq; -using OpenAI.ClientShared.Internal; +using System.Text.Json; namespace OpenAI.Chat; @@ -21,7 +15,7 @@ public class ChatRequestUserMessage : ChatRequestMessage /// /// An optional name for the participant. /// - public string Name { get; set; } + public string ParticipantName { get; init; } /// /// Creates a new instance of with ordinary text content. @@ -57,9 +51,9 @@ public ChatRequestUserMessage(params ChatMessageContent[] contentItems) internal override void WriteDerivedAdditions(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - if (Optional.IsDefined(Name)) + if (Optional.IsDefined(ParticipantName)) { - writer.WriteString("name"u8, Name); + writer.WriteString("name"u8, ParticipantName); } } } diff --git a/.dotnet/src/Custom/Chat/ChatResponseFormat.cs b/.dotnet/src/Custom/Chat/ChatResponseFormat.cs index b7d539655..be3f374f1 100644 --- a/.dotnet/src/Custom/Chat/ChatResponseFormat.cs +++ b/.dotnet/src/Custom/Chat/ChatResponseFormat.cs @@ -1,5 +1,3 @@ -using System; - namespace OpenAI.Chat; /// diff --git a/.dotnet/src/Custom/Chat/ChatToolCall.Serialization.cs b/.dotnet/src/Custom/Chat/ChatToolCall.Serialization.cs index eff6eec3c..ea61c0a43 100644 --- a/.dotnet/src/Custom/Chat/ChatToolCall.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatToolCall.Serialization.cs @@ -1,7 +1,4 @@ using System; -using System.ClientModel.Internal; - -using System.ClientModel; using System.ClientModel.Primitives; using System.Text.Json; diff --git a/.dotnet/src/Custom/Chat/ChatToolCall.cs b/.dotnet/src/Custom/Chat/ChatToolCall.cs index 9203f4b01..1637d1496 100644 --- a/.dotnet/src/Custom/Chat/ChatToolCall.cs +++ b/.dotnet/src/Custom/Chat/ChatToolCall.cs @@ -11,5 +11,5 @@ public abstract partial class ChatToolCall /// A unique identifier associated with the tool call, used in a subsequent to /// resolve the tool call and continue the logical conversation. /// - public required string Id { get; set; } + public required string Id { get; init; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatToolConstraint.cs b/.dotnet/src/Custom/Chat/ChatToolConstraint.cs index 15622b5be..44418f520 100644 --- a/.dotnet/src/Custom/Chat/ChatToolConstraint.cs +++ b/.dotnet/src/Custom/Chat/ChatToolConstraint.cs @@ -37,7 +37,7 @@ public ChatToolConstraint(ChatToolDefinition toolDefinition) type = "function", function = new { - name = functionToolDefinition.Name, + name = functionToolDefinition.FunctionName, } }); } diff --git a/.dotnet/src/Custom/Chat/StreamingChatUpdate.cs b/.dotnet/src/Custom/Chat/StreamingChatUpdate.cs index c1540897b..d359ea956 100644 --- a/.dotnet/src/Custom/Chat/StreamingChatUpdate.cs +++ b/.dotnet/src/Custom/Chat/StreamingChatUpdate.cs @@ -220,7 +220,7 @@ internal static List DeserializeStreamingChatUpdates(JsonEl int choiceIndex = 0; ChatFinishReason? finishReason = null; List toolCallUpdates = []; - ChatLogProbabilityCollection logProbabilities = null; + ChatLogProbabilityCollection logProbabilities = new([]); foreach (JsonProperty choiceProperty in choiceElement.EnumerateObject()) { diff --git a/.dotnet/src/Custom/Chat/StreamingFunctionToolCallUpdate.cs b/.dotnet/src/Custom/Chat/StreamingFunctionToolCallUpdate.cs index bbae5e5c4..686a4e61b 100644 --- a/.dotnet/src/Custom/Chat/StreamingFunctionToolCallUpdate.cs +++ b/.dotnet/src/Custom/Chat/StreamingFunctionToolCallUpdate.cs @@ -20,7 +20,7 @@ public partial class StreamingFunctionToolCallUpdate : StreamingToolCallUpdate /// parallel tool calls when streaming. /// /// - public string Name { get; } + public string FunctionName { get; } /// /// The next new segment of the function arguments for the function tool called by a streaming tool call. @@ -43,7 +43,7 @@ internal StreamingFunctionToolCallUpdate( string functionArgumentsUpdate) : base("function", id, toolCallIndex) { - Name = functionName; + FunctionName = functionName; ArgumentsUpdate = functionArgumentsUpdate; } diff --git a/.dotnet/src/Custom/Embeddings/EmbeddingOptions.cs b/.dotnet/src/Custom/Embeddings/EmbeddingOptions.cs index da22117b1..3e1190202 100644 --- a/.dotnet/src/Custom/Embeddings/EmbeddingOptions.cs +++ b/.dotnet/src/Custom/Embeddings/EmbeddingOptions.cs @@ -2,7 +2,7 @@ namespace OpenAI.Embeddings; public class EmbeddingOptions { - public string User { get; set; } + public string User { get; init; } - public int? Dimensions { get; set; } + public int? Dimensions { get; init; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Files/OpenAIFileInfo.cs b/.dotnet/src/Custom/Files/OpenAIFileInfo.cs index 3fb799ca4..82a8df617 100644 --- a/.dotnet/src/Custom/Files/OpenAIFileInfo.cs +++ b/.dotnet/src/Custom/Files/OpenAIFileInfo.cs @@ -15,10 +15,12 @@ internal OpenAIFileInfo(Internal.Models.OpenAIFile internalFile) Id = internalFile.Id; Purpose = internalFile.Purpose.ToString() switch { - "fine-tune" => OpenAIFilePurpose.FineTuning, - "fine-tune-results" => OpenAIFilePurpose.FineTuningResults, "assistants" => OpenAIFilePurpose.Assistants, "assistants_output" => OpenAIFilePurpose.AssistantOutputs, + "batch" => OpenAIFilePurpose.BatchInput, + "batch_output" => OpenAIFilePurpose.BatchOutput, + "fine-tune" => OpenAIFilePurpose.FineTuning, + "fine-tune-results" => OpenAIFilePurpose.FineTuningResults, _ => throw new ArgumentException(nameof(internalFile)), }; Filename = internalFile.Filename; @@ -29,8 +31,10 @@ internal OpenAIFileInfo(Internal.Models.OpenAIFile internalFile) public enum OpenAIFilePurpose { - FineTuning, - FineTuningResults, Assistants, AssistantOutputs, + BatchInput, + BatchOutput, + FineTuning, + FineTuningResults, } \ No newline at end of file diff --git a/.dotnet/src/Custom/FineTuning/FineTuningManagementClient.cs b/.dotnet/src/Custom/FineTuning/FineTuningManagementClient.cs index ad12cd2e5..e18cd81f1 100644 --- a/.dotnet/src/Custom/FineTuning/FineTuningManagementClient.cs +++ b/.dotnet/src/Custom/FineTuning/FineTuningManagementClient.cs @@ -1,5 +1,4 @@ -using System; -using System.ClientModel; +using System.ClientModel; namespace OpenAI.FineTuningManagement; diff --git a/.dotnet/src/Custom/Images/GeneratedImageCollection.cs b/.dotnet/src/Custom/Images/GeneratedImageCollection.cs index 9f286e260..51ffc2540 100644 --- a/.dotnet/src/Custom/Images/GeneratedImageCollection.cs +++ b/.dotnet/src/Custom/Images/GeneratedImageCollection.cs @@ -10,7 +10,16 @@ namespace OpenAI.Images; /// public class GeneratedImageCollection : ReadOnlyCollection { - internal GeneratedImageCollection(IList list) : base(list) { } + /// + /// The timestamp at which the result images were generated. + /// + public DateTimeOffset CreatedAt { get; } + + internal GeneratedImageCollection(IList list, DateTimeOffset createdAt) + : base(list) + { + CreatedAt = createdAt; + } internal static GeneratedImageCollection Deserialize(BinaryData content) { @@ -28,6 +37,6 @@ internal static GeneratedImageCollection Deserialize(JsonElement element) images.Add(new GeneratedImage(response, i)); } - return new GeneratedImageCollection(images); + return new GeneratedImageCollection(images, response.Created); } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Images/ImageQuality.cs b/.dotnet/src/Custom/Images/GeneratedImageQuality.cs similarity index 96% rename from .dotnet/src/Custom/Images/ImageQuality.cs rename to .dotnet/src/Custom/Images/GeneratedImageQuality.cs index 41f13b0ff..c6692ee1d 100644 --- a/.dotnet/src/Custom/Images/ImageQuality.cs +++ b/.dotnet/src/Custom/Images/GeneratedImageQuality.cs @@ -11,7 +11,7 @@ namespace OpenAI.Images; /// - hd - Better consistency and finer details, but may be slower. /// /// -public enum ImageQuality +public enum GeneratedImageQuality { /// /// The hd image quality that provides finer details and greater consistency but may be slower. diff --git a/.dotnet/src/Custom/Images/ImageSize.Serialization.cs b/.dotnet/src/Custom/Images/GeneratedImageSize.Serialization.cs similarity index 80% rename from .dotnet/src/Custom/Images/ImageSize.Serialization.cs rename to .dotnet/src/Custom/Images/GeneratedImageSize.Serialization.cs index 77da27dbc..19e50b390 100644 --- a/.dotnet/src/Custom/Images/ImageSize.Serialization.cs +++ b/.dotnet/src/Custom/Images/GeneratedImageSize.Serialization.cs @@ -9,30 +9,30 @@ namespace OpenAI.Images; /// /// Represents the available output dimensions for generated images. /// -public partial class GeneratedImageSize : IJsonModel +public readonly partial struct GeneratedImageSize : IJsonModel { GeneratedImageSize IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IJsonModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(GeneratedImageSize)} does not support '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGeneratedImageSize(document.RootElement, options); + return DeserializeGeneratedImageSize(document.RootElement, options).Value; } GeneratedImageSize IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeGeneratedImageSize(document.RootElement, options); + return DeserializeGeneratedImageSize(document.RootElement, options).Value; } default: throw new FormatException($"The model {nameof(GeneratedImageSize)} does not support '{options.Format}' format."); @@ -43,7 +43,7 @@ GeneratedImageSize IPersistableModel.Create(BinaryData data, void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IJsonModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatCompletionFunctionCallOption)} does not support '{format}' format."); @@ -64,7 +64,7 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - internal static GeneratedImageSize DeserializeGeneratedImageSize(JsonElement element, ModelReaderWriterOptions options = null) + internal static GeneratedImageSize? DeserializeGeneratedImageSize(JsonElement element, ModelReaderWriterOptions options = null) { if (element.ValueKind != JsonValueKind.String) { diff --git a/.dotnet/src/Custom/Images/GeneratedImageSize.cs b/.dotnet/src/Custom/Images/GeneratedImageSize.cs index 3ec49aed5..7c972f6e5 100644 --- a/.dotnet/src/Custom/Images/GeneratedImageSize.cs +++ b/.dotnet/src/Custom/Images/GeneratedImageSize.cs @@ -3,7 +3,7 @@ namespace OpenAI.Images; /// /// Represents the available output dimensions for generated images. /// -public partial class GeneratedImageSize +public readonly partial struct GeneratedImageSize { /// /// Gets the desired width, in pixels, for an image. @@ -71,15 +71,13 @@ public GeneratedImageSize(int width, int height) public static readonly GeneratedImageSize W1792xH1024 = new(1792, 1024); /// - public static bool operator ==(GeneratedImageSize left, GeneratedImageSize right) - => ((left is null) == (right is null)) && (left is null || left.Equals(right)); + public static bool operator ==(GeneratedImageSize left, GeneratedImageSize right) => left.Equals(right); /// - public static bool operator !=(GeneratedImageSize left, GeneratedImageSize right) - => ((left is null) != (right is null)) || (left is not null && !left.Equals(right)); + public static bool operator !=(GeneratedImageSize left, GeneratedImageSize right) => !left.Equals(right); /// - public bool Equals(GeneratedImageSize other) => other?.Width == Width && other?.Height == Height; + public bool Equals(GeneratedImageSize other) => other.Width == Width && other.Height == Height; /// public override bool Equals(object obj) => obj is GeneratedImageSize other && Equals(other); diff --git a/.dotnet/src/Custom/Images/ImageStyle.cs b/.dotnet/src/Custom/Images/GeneratedImageStyle.cs similarity index 95% rename from .dotnet/src/Custom/Images/ImageStyle.cs rename to .dotnet/src/Custom/Images/GeneratedImageStyle.cs index 30616eccd..373b1b339 100644 --- a/.dotnet/src/Custom/Images/ImageStyle.cs +++ b/.dotnet/src/Custom/Images/GeneratedImageStyle.cs @@ -5,7 +5,7 @@ namespace OpenAI.Images; /// generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real /// looking images. This param is only supported for dall-e-3. /// -public enum ImageStyle +public enum GeneratedImageStyle { /// /// The vivid style, with which the model will tend towards hyper-realistic, dramatic imagery. diff --git a/.dotnet/src/Custom/Images/ImageClient.cs b/.dotnet/src/Custom/Images/ImageClient.cs index e93889376..5dd993fd2 100644 --- a/.dotnet/src/Custom/Images/ImageClient.cs +++ b/.dotnet/src/Custom/Images/ImageClient.cs @@ -4,7 +4,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.IO; -using System.Runtime.InteropServices.ComTypes; using System.Text; using System.Threading.Tasks; @@ -83,15 +82,9 @@ public virtual ClientResult GenerateImages( ImageGenerationOptions options = null) { Internal.Models.CreateImageRequest request = CreateInternalImageRequest(prompt, imageCount, options); - ClientResult response = Shim.CreateImage(request); - - List images = []; - for (int i = 0; i < response.Value.Data.Count; i++) - { - images.Add(new GeneratedImage(response.Value, i)); - } - - return ClientResult.FromValue(new GeneratedImageCollection(images), response.GetRawResponse()); + ClientResult response = Shim.CreateImage(BinaryContent.Create(request)); + GeneratedImageCollection resultValue = GeneratedImageCollection.Deserialize(response.GetRawResponse().Content); + return ClientResult.FromValue(resultValue, response.GetRawResponse()); } /// @@ -110,15 +103,9 @@ public virtual async Task> GenerateImages ImageGenerationOptions options = null) { Internal.Models.CreateImageRequest request = CreateInternalImageRequest(prompt, imageCount, options); - ClientResult response = await Shim.CreateImageAsync(request).ConfigureAwait(false); - - List images = []; - for (int i = 0; i < response.Value.Data.Count; i++) - { - images.Add(new GeneratedImage(response.Value, i)); - } - - return ClientResult.FromValue(new GeneratedImageCollection(images), response.GetRawResponse()); + ClientResult response = await Shim.CreateImageAsync(BinaryContent.Create(request)); + GeneratedImageCollection resultValue = GeneratedImageCollection.Deserialize(response.GetRawResponse().Content); + return ClientResult.FromValue(resultValue, response.GetRawResponse()); } // convenience method - sync; Stream overload @@ -352,8 +339,8 @@ private Internal.Models.CreateImageRequest CreateInternalImageRequest( { internalQuality = options.Quality switch { - ImageQuality.Standard => Internal.Models.CreateImageRequestQuality.Standard, - ImageQuality.High => Internal.Models.CreateImageRequestQuality.Hd, + GeneratedImageQuality.Standard => Internal.Models.CreateImageRequestQuality.Standard, + GeneratedImageQuality.High => Internal.Models.CreateImageRequestQuality.Hd, _ => throw new ArgumentException(nameof(options.Quality)), }; } @@ -380,8 +367,8 @@ private Internal.Models.CreateImageRequest CreateInternalImageRequest( { internalStyle = options.Style switch { - ImageStyle.Vivid => Internal.Models.CreateImageRequestStyle.Vivid, - ImageStyle.Natural => Internal.Models.CreateImageRequestStyle.Natural, + GeneratedImageStyle.Vivid => Internal.Models.CreateImageRequestStyle.Vivid, + GeneratedImageStyle.Natural => Internal.Models.CreateImageRequestStyle.Natural, _ => throw new ArgumentException(nameof(options.Style)), }; } diff --git a/.dotnet/src/Custom/Images/ImageEditOptions.cs b/.dotnet/src/Custom/Images/ImageEditOptions.cs index 8e9e8a89c..bff43ed63 100644 --- a/.dotnet/src/Custom/Images/ImageEditOptions.cs +++ b/.dotnet/src/Custom/Images/ImageEditOptions.cs @@ -11,23 +11,23 @@ namespace OpenAI.Images; public partial class ImageEditOptions { /// - public BinaryData MaskBytes { get; set; } + public BinaryData MaskBytes { get; init; } // The generator will need to add file-name to models for properties that // represent files in order to enable setting the header. /// /// TODO /// - public string MaskFileName { get; set; } + public string MaskFileName { get; init; } /// - public ImageResponseFormat? ResponseFormat { get; set; } + public ImageResponseFormat? ResponseFormat { get; init; } /// - public GeneratedImageSize Size { get; set; } + public GeneratedImageSize? Size { get; init; } /// - public string User { get; set; } + public string User { get; init; } internal MultipartFormDataBinaryContent ToMultipartContent(Stream fileStream, string fileName, diff --git a/.dotnet/src/Custom/Images/ImageGenerationOptions.cs b/.dotnet/src/Custom/Images/ImageGenerationOptions.cs index 289653f4b..6956ddfb6 100644 --- a/.dotnet/src/Custom/Images/ImageGenerationOptions.cs +++ b/.dotnet/src/Custom/Images/ImageGenerationOptions.cs @@ -10,15 +10,15 @@ public partial class ImageGenerationOptions /// the dall-e-3 model. /// /// - /// hd - - Finer details, greater consistency, slower, more intensive. + /// hd - - Finer details, greater consistency, slower, more intensive. /// /// - /// standard - - The default quality level that's faster and less + /// standard - - The default quality level that's faster and less /// intensive but may also be less detailed and consistent than hd. /// /// /// - public ImageQuality? Quality { get; set; } + public GeneratedImageQuality? Quality { get; init; } /// /// Specifies the desired output representation of the generated image. /// @@ -33,7 +33,7 @@ public partial class ImageGenerationOptions /// /// /// - public ImageResponseFormat? ResponseFormat { get; set; } + public ImageResponseFormat? ResponseFormat { get; init; } /// /// Specifies the dimensions of the generated image. Larger images take longer to create. /// @@ -53,23 +53,23 @@ public partial class ImageGenerationOptions /// /// /// - public GeneratedImageSize Size { get; set; } + public GeneratedImageSize? Size { get; init; } /// /// The style kind to guide the generation of the image. /// /// - /// vivid - - default, a style that tends towards more realistic, + /// vivid - - default, a style that tends towards more realistic, /// dramatic images. /// /// - /// natural - - a more subdued style with less tendency towards + /// natural - - a more subdued style with less tendency towards /// realism and striking imagery. /// /// /// - public ImageStyle? Style { get; set; } + public GeneratedImageStyle? Style { get; init; } /// /// An optional identifier for the end user that can help OpenAI monitor for and detect abuse. /// - public string User { get; set; } + public string User { get; init; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Images/ImageVariationOptions.cs b/.dotnet/src/Custom/Images/ImageVariationOptions.cs index 0f8a7f4f6..9d40a6a6c 100644 --- a/.dotnet/src/Custom/Images/ImageVariationOptions.cs +++ b/.dotnet/src/Custom/Images/ImageVariationOptions.cs @@ -11,13 +11,13 @@ namespace OpenAI.Images; public partial class ImageVariationOptions { /// - public GeneratedImageSize Size { get; set; } + public GeneratedImageSize? Size { get; init; } /// - public ImageResponseFormat? ResponseFormat { get; set; } + public ImageResponseFormat? ResponseFormat { get; init; } /// - public string User { get; set; } + public string User { get; init; } internal MultipartFormDataBinaryContent ToMultipartContent(Stream fileStream, string fileName, string model, int? imageCount) { diff --git a/.dotnet/src/Custom/Models/ModelManagementClient.cs b/.dotnet/src/Custom/Models/ModelManagementClient.cs index fad3d3615..98c2beabc 100644 --- a/.dotnet/src/Custom/Models/ModelManagementClient.cs +++ b/.dotnet/src/Custom/Models/ModelManagementClient.cs @@ -1,5 +1,3 @@ -using OpenAI.ClientShared.Internal; -using System; using System.ClientModel; using System.Threading.Tasks; diff --git a/.dotnet/src/Custom/OpenAIClient.cs b/.dotnet/src/Custom/OpenAIClient.cs index 0675b193c..cd2219a0b 100644 --- a/.dotnet/src/Custom/OpenAIClient.cs +++ b/.dotnet/src/Custom/OpenAIClient.cs @@ -5,11 +5,9 @@ using OpenAI.Files; using OpenAI.FineTuningManagement; using OpenAI.Images; -using OpenAI.Internal.Models; using OpenAI.LegacyCompletions; using OpenAI.ModelManagement; using OpenAI.Moderations; -using System; using System.ClientModel; using System.Diagnostics.CodeAnalysis; @@ -118,17 +116,6 @@ public OpenAIClient(ApiKeyCredential credential = default, OpenAIClientOptions o /// A new . public ImageClient GetImageClient(string model) => new(model, _cachedCredential, _cachedOptions); - /// - /// Gets a new instance of that reuses the client configuration details provided to - /// the instance. - /// - /// - /// This method is functionally equivalent to using the constructor directly with - /// the same configuration details. - /// - /// A new . - public LegacyCompletionClient GetLegacyCompletionClient() => new(_cachedCredential, _cachedOptions); - /// /// Gets a new instance of that reuses the client configuration details provided to /// the instance. diff --git a/.dotnet/src/Custom/OpenAIClientConnector.cs b/.dotnet/src/Custom/OpenAIClientConnector.cs index 8ee47b1ee..cc476be66 100644 --- a/.dotnet/src/Custom/OpenAIClientConnector.cs +++ b/.dotnet/src/Custom/OpenAIClientConnector.cs @@ -1,7 +1,5 @@ using System; using System.ClientModel; -using System.ClientModel.Internal; - namespace OpenAI; @@ -22,7 +20,6 @@ internal OpenAIClientConnector( ApiKeyCredential credential = null, OpenAIClientOptions options = null) { - if (model is null) throw new ArgumentNullException(nameof(model)); Model = model; Endpoint ??= options?.Endpoint ?? new(Environment.GetEnvironmentVariable(s_OpenAIEndpointEnvironmentVariable) ?? s_defaultOpenAIV1Endpoint); credential ??= new(Environment.GetEnvironmentVariable(s_OpenAIApiKeyEnvironmentVariable) ?? string.Empty); diff --git a/.dotnet/src/Custom/OpenAIClientOptions.cs b/.dotnet/src/Custom/OpenAIClientOptions.cs index 8234691b5..ade7d1f94 100644 --- a/.dotnet/src/Custom/OpenAIClientOptions.cs +++ b/.dotnet/src/Custom/OpenAIClientOptions.cs @@ -1,15 +1,12 @@ using System; -using System.ClientModel; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading; namespace OpenAI; /// /// Client-level options for the OpenAI service. /// -public partial class OpenAIClientOptions : RequestOptions +public partial class OpenAIClientOptions : ClientPipelineOptions { /// /// Gets or sets a non-default base endpoint that clients should use when connecting. diff --git a/.dotnet/tests/Samples/Assistants/Sample03_FunctionCalling.cs b/.dotnet/tests/Samples/Assistants/Sample03_FunctionCalling.cs index 7e5bca6a2..9866ca238 100644 --- a/.dotnet/tests/Samples/Assistants/Sample03_FunctionCalling.cs +++ b/.dotnet/tests/Samples/Assistants/Sample03_FunctionCalling.cs @@ -28,13 +28,13 @@ private static string GetCurrentWeather(string location, string unit = "celsius" private static readonly FunctionToolDefinition getCurrentLocationFunction = new() { - Name = GetCurrentLocationFunctionName, + FunctionName = GetCurrentLocationFunctionName, Description = "Get the user's current location" }; private static readonly FunctionToolDefinition getCurrentWeatherFunction = new() { - Name = GetCurrentWeatherFunctionName, + FunctionName = GetCurrentWeatherFunctionName, Description = "Get the current weather in a given location", Parameters = BinaryData.FromString(""" { @@ -105,7 +105,7 @@ public void Sample03_FunctionCalling() { RequiredFunctionToolCall requiredFunctionToolCall = action as RequiredFunctionToolCall; - switch (requiredFunctionToolCall?.Name) + switch (requiredFunctionToolCall?.FunctionName) { case GetCurrentLocationFunctionName: { diff --git a/.dotnet/tests/Samples/Assistants/Sample03_FunctionCallingAsync.cs b/.dotnet/tests/Samples/Assistants/Sample03_FunctionCallingAsync.cs index 9333f51d0..6da33f8a0 100644 --- a/.dotnet/tests/Samples/Assistants/Sample03_FunctionCallingAsync.cs +++ b/.dotnet/tests/Samples/Assistants/Sample03_FunctionCallingAsync.cs @@ -59,7 +59,7 @@ public async Task Sample03_FunctionCallingAsync() { RequiredFunctionToolCall requiredFunctionToolCall = action as RequiredFunctionToolCall; - switch (requiredFunctionToolCall?.Name) + switch (requiredFunctionToolCall?.FunctionName) { case GetCurrentLocationFunctionName: { diff --git a/.dotnet/tests/Samples/Chat/Sample03_FunctionCalling.cs b/.dotnet/tests/Samples/Chat/Sample03_FunctionCalling.cs index 289fdd473..4258d34b6 100644 --- a/.dotnet/tests/Samples/Chat/Sample03_FunctionCalling.cs +++ b/.dotnet/tests/Samples/Chat/Sample03_FunctionCalling.cs @@ -29,13 +29,13 @@ private static string GetCurrentWeather(string location, string unit = "celsius" private static readonly ChatFunctionToolDefinition getCurrentLocationFunction = new() { - Name = GetCurrentLocationFunctionName, + FunctionName = GetCurrentLocationFunctionName, Description = "Get the user's current location" }; private static readonly ChatFunctionToolDefinition getCurrentWeatherFunction = new() { - Name = GetCurrentWeatherFunctionName, + FunctionName = GetCurrentWeatherFunctionName, Description = "Get the current weather in a given location", Parameters = BinaryData.FromString(""" { diff --git a/.dotnet/tests/Samples/CombinationSamples.cs b/.dotnet/tests/Samples/CombinationSamples.cs index eaac630de..18f368bea 100644 --- a/.dotnet/tests/Samples/CombinationSamples.cs +++ b/.dotnet/tests/Samples/CombinationSamples.cs @@ -21,8 +21,8 @@ public void AlpacaArtAssessor() "a majestic alpaca on a mountain ridge, backed by an expansive blue sky accented with sparse clouds", new() { - Style = ImageStyle.Vivid, - Quality = ImageQuality.High, + Style = GeneratedImageStyle.Vivid, + Quality = GeneratedImageQuality.High, Size = GeneratedImageSize.W1792xH1024, }); GeneratedImage imageGeneration = imageResult.Value; @@ -42,7 +42,7 @@ public void AlpacaArtAssessor() { MaxTokens = 2048, }); - string chatResponseText = chatResult.Value.Content; + string chatResponseText = (string)chatResult.Value.Content; Console.WriteLine($"Art critique of majestic alpaca:\n{chatResponseText}"); // Finally, we'll get some text-to-speech for that critical evaluation using tts-1-hd: @@ -79,7 +79,7 @@ public async Task CuriousCreatureCreator() { MaxTokens = 2048, }); - string description = creativeWriterResult.Value.Content; + string description = creativeWriterResult.Value.Content.ToText(); Console.WriteLine($"Creative helper's creature description:\n{description}"); // Asynchronously, in parallel to the next steps, we'll get the creative description in the voice of Onyx @@ -109,7 +109,7 @@ public async Task CuriousCreatureCreator() new ImageGenerationOptions() { Size = GeneratedImageSize.W1792xH1024, - Quality = ImageQuality.High, + Quality = GeneratedImageQuality.High, }); Uri imageLocation = imageGenerationResult.Value.ImageUri; Console.WriteLine($"Creature image available at:\n{imageLocation.AbsoluteUri}"); @@ -127,7 +127,7 @@ public async Task CuriousCreatureCreator() { MaxTokens = 2048, }); - string appraisal = criticalAppraisalResult.Value.Content; + string appraisal = (string)criticalAppraisalResult.Value.Content; Console.WriteLine($"Critic's appraisal:\n{appraisal}"); // Finally, we'll get that art expert's laudations in the voice of Fable diff --git a/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs b/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs index 5a9dcccbb..2fc2ce225 100644 --- a/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs +++ b/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs @@ -23,9 +23,9 @@ public void Sample01_SimpleImage() ImageGenerationOptions options = new() { - Quality = ImageQuality.High, + Quality = GeneratedImageQuality.High, Size = GeneratedImageSize.W1792xH1024, - Style = ImageStyle.Vivid, + Style = GeneratedImageStyle.Vivid, ResponseFormat = ImageResponseFormat.Bytes }; diff --git a/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs b/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs index 16af4834a..f71341d7b 100644 --- a/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs +++ b/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs @@ -24,9 +24,9 @@ public async Task Sample01_SimpleImageAsync() ImageGenerationOptions options = new() { - Quality = ImageQuality.High, + Quality = GeneratedImageQuality.High, Size = GeneratedImageSize.W1792xH1024, - Style = ImageStyle.Vivid, + Style = GeneratedImageStyle.Vivid, ResponseFormat = ImageResponseFormat.Bytes }; diff --git a/.dotnet/tests/TestScenarios/AssistantTests.cs b/.dotnet/tests/TestScenarios/AssistantTests.cs index 005bf1234..56a8a7516 100644 --- a/.dotnet/tests/TestScenarios/AssistantTests.cs +++ b/.dotnet/tests/TestScenarios/AssistantTests.cs @@ -70,7 +70,7 @@ public async Task BasicFunctionToolWorks() { new FunctionToolDefinition() { - Name = "get_favorite_food_for_day_of_week", + FunctionName = "get_favorite_food_for_day_of_week", Description = "gets the user's favorite food for a given day of the week, like Tuesday", Parameters = BinaryData.FromObjectAsJson(new { diff --git a/.dotnet/tests/TestScenarios/ChatToolConstraints.cs b/.dotnet/tests/TestScenarios/ChatToolConstraints.cs index c6b20d28f..c31993421 100644 --- a/.dotnet/tests/TestScenarios/ChatToolConstraints.cs +++ b/.dotnet/tests/TestScenarios/ChatToolConstraints.cs @@ -16,12 +16,12 @@ public void BasicTypeManipulationWorks() ChatFunctionToolDefinition functionTool = new() { - Name = "test_function_tool", + FunctionName = "test_function_tool", Description = "description isn't applicable", }; ChatToolConstraint constraintFromDefinition = new(functionTool); - Assert.That(constraintFromDefinition.ToString(), Is.EqualTo(@$"{{""type"":""function"",""function"":{{""name"":""{functionTool.Name}""}}}}")); + Assert.That(constraintFromDefinition.ToString(), Is.EqualTo(@$"{{""type"":""function"",""function"":{{""name"":""{functionTool.FunctionName}""}}}}")); ChatToolConstraint otherConstraint = new(new ChatFunctionToolDefinition("test_function_tool")); Assert.That(constraintFromDefinition, Is.EqualTo(otherConstraint)); @@ -32,10 +32,6 @@ public void BasicTypeManipulationWorks() public void ConstraintsWork() { ChatClient client = new("gpt-3.5-turbo"); - ChatCompletionOptions options = new() - { - Tools = { s_numberForWordTool }, - }; foreach (var (constraint, reason) in new (ChatToolConstraint?, ChatFinishReason)[] { @@ -45,7 +41,11 @@ public void ConstraintsWork() (ChatToolConstraint.Auto, ChatFinishReason.ToolCalls), }) { - options.ToolConstraint = constraint; + ChatCompletionOptions options = new() + { + Tools = { s_numberForWordTool }, + ToolConstraint = constraint, + }; ClientResult result = client.CompleteChat("What's the number for the word 'banana'?", options); Assert.That(result.Value.FinishReason, Is.EqualTo(reason)); } @@ -53,7 +53,7 @@ public void ConstraintsWork() private static ChatFunctionToolDefinition s_numberForWordTool = new() { - Name = "get_number_for_word", + FunctionName = "get_number_for_word", Description = "gets an arbitrary number assigned to a given word", Parameters = BinaryData.FromObjectAsJson(new { diff --git a/.dotnet/tests/TestScenarios/ChatToolTests.cs b/.dotnet/tests/TestScenarios/ChatToolTests.cs index a59d789b3..77fa495b1 100644 --- a/.dotnet/tests/TestScenarios/ChatToolTests.cs +++ b/.dotnet/tests/TestScenarios/ChatToolTests.cs @@ -17,7 +17,7 @@ public void NoParameterToolWorks() ChatClient client = new("gpt-3.5-turbo"); ChatFunctionToolDefinition getFavoriteColorTool = new() { - Name = "get_favorite_color", + FunctionName = "get_favorite_color", Description = "gets the favorite color of the caller", }; ChatCompletionOptions options = new() @@ -30,7 +30,7 @@ public void NoParameterToolWorks() var functionToolCall = result.Value.ToolCalls[0] as ChatFunctionToolCall; var toolCallArguments = BinaryData.FromString(functionToolCall.Arguments).ToObjectFromJson>(); Assert.That(functionToolCall, Is.Not.Null); - Assert.That(functionToolCall.Name, Is.EqualTo(getFavoriteColorTool.Name)); + Assert.That(functionToolCall.Name, Is.EqualTo(getFavoriteColorTool.FunctionName)); Assert.That(functionToolCall.Id, Is.Not.Null.Or.Empty); Assert.That(toolCallArguments.Count, Is.EqualTo(0)); @@ -50,7 +50,7 @@ public void ParametersWork() ChatClient client = GetTestClient(TestScenario.Chat); ChatFunctionToolDefinition favoriteColorForMonthTool = new() { - Name = "get_favorite_color_for_month", + FunctionName = "get_favorite_color_for_month", Description = "gets the caller's favorite color for a given month", Parameters = BinaryData.FromString(""" { @@ -77,7 +77,7 @@ public void ParametersWork() Assert.That(result.Value.FinishReason, Is.EqualTo(ChatFinishReason.ToolCalls)); Assert.That(result.Value.ToolCalls?.Count, Is.EqualTo(1)); var functionToolCall = result.Value.ToolCalls[0] as ChatFunctionToolCall; - Assert.That(functionToolCall.Name, Is.EqualTo(favoriteColorForMonthTool.Name)); + Assert.That(functionToolCall.Name, Is.EqualTo(favoriteColorForMonthTool.FunctionName)); JsonObject argumentsJson = JsonSerializer.Deserialize(functionToolCall.Arguments); Assert.That(argumentsJson.Count, Is.EqualTo(1)); Assert.That(argumentsJson.ContainsKey("month_name")); diff --git a/.dotnet/tests/TestScenarios/ImageGenerationTests.cs b/.dotnet/tests/TestScenarios/ImageGenerationTests.cs index 1d8d3304c..de13a707f 100644 --- a/.dotnet/tests/TestScenarios/ImageGenerationTests.cs +++ b/.dotnet/tests/TestScenarios/ImageGenerationTests.cs @@ -26,8 +26,8 @@ public void GenerationWithOptionsWorks() ImageClient client = GetTestClient(); ClientResult result = client.GenerateImage("an isolated stop sign", new ImageGenerationOptions() { - Quality = ImageQuality.Standard, - Style = ImageStyle.Natural, + Quality = GeneratedImageQuality.Standard, + Style = GeneratedImageStyle.Natural, }); Assert.That(result.Value.ImageUri, Is.Not.Null); } diff --git a/.dotnet/tests/TestScenarios/LegacyCompletions.cs b/.dotnet/tests/TestScenarios/LegacyCompletions.cs index 6f5deddc1..825215965 100644 --- a/.dotnet/tests/TestScenarios/LegacyCompletions.cs +++ b/.dotnet/tests/TestScenarios/LegacyCompletions.cs @@ -2,8 +2,6 @@ using OpenAI.LegacyCompletions; using System; using System.ClientModel; -using System.ClientModel; -using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Nodes; diff --git a/.dotnet/tests/TestScenarios/TextToSpeechTests.cs b/.dotnet/tests/TestScenarios/TextToSpeechTests.cs index c880ff864..12ae8b2ee 100644 --- a/.dotnet/tests/TestScenarios/TextToSpeechTests.cs +++ b/.dotnet/tests/TestScenarios/TextToSpeechTests.cs @@ -24,11 +24,7 @@ public void BasicTTSWorks() public void OutputFormatWorks(AudioDataFormat? responseFormat) { AudioClient client = new("tts-1"); - TextToSpeechOptions options = new(); - if (responseFormat != null) - { - options.ResponseFormat = responseFormat; - } + TextToSpeechOptions options = responseFormat == null ? new() : new() { ResponseFormat = responseFormat }; ClientResult result = client.GenerateSpeechFromText("Hello, world!", TextToSpeechVoice.Alloy, options); Assert.That(result.Value, Is.Not.Null); } diff --git a/.dotnet/tests/Utility/TestHelpers.cs b/.dotnet/tests/Utility/TestHelpers.cs index bfc847e42..ec5470f47 100644 --- a/.dotnet/tests/Utility/TestHelpers.cs +++ b/.dotnet/tests/Utility/TestHelpers.cs @@ -33,7 +33,6 @@ public static T GetTestClient(TestScenario scenario, string overrideModel = n { OpenAIClientOptions options = new(); options.AddPolicy(GetDumpPolicy(), PipelinePosition.PerTry); - options.ErrorOptions = throwOnError ? ClientErrorBehaviors.Default : ClientErrorBehaviors.NoThrow; object clientObject = scenario switch { TestScenario.Chat => new ChatClient(overrideModel ?? "gpt-3.5-turbo", credential: null, options), From 6053fb190cfa1d5cb581ff5a32a98fa293341e89 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 27 Mar 2024 18:51:03 -0700 Subject: [PATCH 2/4] pick up generated changes --- .../src/Generated/Models/CreateTranscriptionRequest.cs | 6 +++--- .../src/Generated/Models/CreateTranslationRequest.cs | 6 +++--- .dotnet/src/Generated/Models/OpenAIFilePurpose.cs | 6 ++++++ .dotnet/src/OpenAI.csproj | 1 + audio/models.tsp | 4 ++-- files/models.tsp | 4 +++- tsp-output/@typespec/openapi3/openapi.yaml | 10 ++++++---- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.dotnet/src/Generated/Models/CreateTranscriptionRequest.cs b/.dotnet/src/Generated/Models/CreateTranscriptionRequest.cs index 09a34f48d..87cff8c07 100644 --- a/.dotnet/src/Generated/Models/CreateTranscriptionRequest.cs +++ b/.dotnet/src/Generated/Models/CreateTranscriptionRequest.cs @@ -44,7 +44,7 @@ internal partial class CreateTranscriptionRequest /// Initializes a new instance of . /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, - /// mpeg, mpga, m4a, ogg, wav, or webm. + /// mpeg, mpga, m4a, ogg, pcm, wav, or webm. /// /// /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) @@ -63,7 +63,7 @@ public CreateTranscriptionRequest(BinaryData file, CreateTranscriptionRequestMod /// Initializes a new instance of . /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, - /// mpeg, mpga, m4a, ogg, wav, or webm. + /// mpeg, mpga, m4a, ogg, pcm, wav, or webm. /// /// /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) @@ -114,7 +114,7 @@ internal CreateTranscriptionRequest() /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, - /// mpeg, mpga, m4a, ogg, wav, or webm. + /// mpeg, mpga, m4a, ogg, pcm, wav, or webm. /// /// To assign a byte[] to this property use . /// The byte[] will be serialized to a Base64 encoded string. diff --git a/.dotnet/src/Generated/Models/CreateTranslationRequest.cs b/.dotnet/src/Generated/Models/CreateTranslationRequest.cs index acc2f53f4..e7f16e624 100644 --- a/.dotnet/src/Generated/Models/CreateTranslationRequest.cs +++ b/.dotnet/src/Generated/Models/CreateTranslationRequest.cs @@ -44,7 +44,7 @@ internal partial class CreateTranslationRequest /// Initializes a new instance of . /// /// The audio file object (not file name) to translate, in one of these formats: flac, mp3, mp4, - /// mpeg, mpga, m4a, ogg, wav, or webm. + /// mpeg, mpga, m4a, ogg, pcm, wav, or webm. /// /// /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) @@ -62,7 +62,7 @@ public CreateTranslationRequest(BinaryData file, CreateTranslationRequestModel m /// Initializes a new instance of . /// /// The audio file object (not file name) to translate, in one of these formats: flac, mp3, mp4, - /// mpeg, mpga, m4a, ogg, wav, or webm. + /// mpeg, mpga, m4a, ogg, pcm, wav, or webm. /// /// /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) @@ -100,7 +100,7 @@ internal CreateTranslationRequest() /// /// The audio file object (not file name) to translate, in one of these formats: flac, mp3, mp4, - /// mpeg, mpga, m4a, ogg, wav, or webm. + /// mpeg, mpga, m4a, ogg, pcm, wav, or webm. /// /// To assign a byte[] to this property use . /// The byte[] will be serialized to a Base64 encoded string. diff --git a/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs b/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs index 97d4f29b4..57ebf9188 100644 --- a/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs +++ b/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs @@ -21,6 +21,8 @@ public OpenAIFilePurpose(string value) private const string FineTuneResultsValue = "fine-tune-results"; private const string AssistantsValue = "assistants"; private const string AssistantsOutputValue = "assistants_output"; + private const string BatchValue = "batch"; + private const string BatchOutputValue = "batch_output"; /// fine-tune. public static OpenAIFilePurpose FineTune { get; } = new OpenAIFilePurpose(FineTuneValue); @@ -30,6 +32,10 @@ public OpenAIFilePurpose(string value) public static OpenAIFilePurpose Assistants { get; } = new OpenAIFilePurpose(AssistantsValue); /// assistants_output. public static OpenAIFilePurpose AssistantsOutput { get; } = new OpenAIFilePurpose(AssistantsOutputValue); + /// batch. + public static OpenAIFilePurpose Batch { get; } = new OpenAIFilePurpose(BatchValue); + /// batch_output. + public static OpenAIFilePurpose BatchOutput { get; } = new OpenAIFilePurpose(BatchOutputValue); /// Determines if two values are the same. public static bool operator ==(OpenAIFilePurpose left, OpenAIFilePurpose right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/.dotnet/src/OpenAI.csproj b/.dotnet/src/OpenAI.csproj index cd5fa6d55..0fad9d5de 100644 --- a/.dotnet/src/OpenAI.csproj +++ b/.dotnet/src/OpenAI.csproj @@ -2,6 +2,7 @@ This is the OpenAI client library for developing .NET applications with rich experience. SDK Code Generation OpenAI + 1.0.0-beta.1 OpenAI netstandard2.0 latest diff --git a/audio/models.tsp b/audio/models.tsp index 13d7301ce..9d531c9f8 100644 --- a/audio/models.tsp +++ b/audio/models.tsp @@ -39,7 +39,7 @@ model CreateSpeechRequest { model CreateTranscriptionRequest { /** * The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, - * mpeg, mpga, m4a, ogg, wav, or webm. + * mpeg, mpga, m4a, ogg, pcm, wav, or webm. */ @encode("binary") @extension("x-oaiTypeLabel", "file") @@ -94,7 +94,7 @@ model CreateTranscriptionRequest { model CreateTranslationRequest { /** * The audio file object (not file name) to translate, in one of these formats: flac, mp3, mp4, - * mpeg, mpga, m4a, ogg, wav, or webm. + * mpeg, mpga, m4a, ogg, pcm, wav, or webm. */ @encode("binary") @extension("x-oaiTypeLabel", "file") diff --git a/files/models.tsp b/files/models.tsp index 7cfd02a68..bb013145c 100644 --- a/files/models.tsp +++ b/files/models.tsp @@ -33,7 +33,9 @@ alias FILE_PURPOSE = | "fine-tune" | "fine-tune-results" | "assistants" - | "assistants_output"; + | "assistants_output" + | "batch" + | "batch_output"; /** The `File` object represents a document that has been uploaded to OpenAI. */ model OpenAIFile { diff --git a/tsp-output/@typespec/openapi3/openapi.yaml b/tsp-output/@typespec/openapi3/openapi.yaml index 224f0b7a0..714c7a25c 100644 --- a/tsp-output/@typespec/openapi3/openapi.yaml +++ b/tsp-output/@typespec/openapi3/openapi.yaml @@ -379,8 +379,8 @@ paths: application/json: schema: anyOf: - - $ref: '#/components/schemas/CreateTranscriptionResponseJson' - $ref: '#/components/schemas/CreateTranscriptionResponseVerboseJson' + - $ref: '#/components/schemas/CreateTranscriptionResponseJson' text/plain: schema: type: string @@ -410,8 +410,8 @@ paths: application/json: schema: anyOf: - - $ref: '#/components/schemas/CreateTranslationResponseJson' - $ref: '#/components/schemas/CreateTranslationResponseVerboseJson' + - $ref: '#/components/schemas/CreateTranslationResponseJson' text/plain: schema: type: string @@ -3771,7 +3771,7 @@ components: format: binary description: |- The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, - mpeg, mpga, m4a, ogg, wav, or webm. + mpeg, mpga, m4a, ogg, pcm, wav, or webm. x-oaiTypeLabel: file model: anyOf: @@ -3889,7 +3889,7 @@ components: format: binary description: |- The audio file object (not file name) to translate, in one of these formats: flac, mp3, mp4, - mpeg, mpga, m4a, ogg, wav, or webm. + mpeg, mpga, m4a, ogg, pcm, wav, or webm. x-oaiTypeLabel: file model: anyOf: @@ -4921,6 +4921,8 @@ components: - fine-tune-results - assistants - assistants_output + - batch + - batch_output description: |- The intended purpose of the file. Supported values are `fine-tune`, `fine-tune-results`, `assistants`, and `assistants_output`. From 4dac7b76ac9f700303f9d0d359aee30ad7dd26d3 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 28 Mar 2024 13:54:45 -0700 Subject: [PATCH 3/4] feedback, including restoration of extensible enum for OpenAIFilePurpose --- .dotnet/src/Custom/Files/FileClient.cs | 32 +------------ .dotnet/src/Custom/Files/OpenAIFileInfo.cs | 21 +------- .dotnet/src/Custom/Files/OpenAIFilePurpose.cs | 48 +++++++++++++++++++ .dotnet/src/Custom/Files/UploadFileOptions.cs | 9 +--- .dotnet/src/Custom/Images/GeneratedImage.cs | 4 +- ...ponseFormat.cs => GeneratedImageFormat.cs} | 6 +-- .dotnet/src/Custom/Images/ImageClient.cs | 4 +- .dotnet/src/Custom/Images/ImageEditOptions.cs | 6 +-- .../Custom/Images/ImageGenerationOptions.cs | 6 +-- .../Custom/Images/ImageVariationOptions.cs | 6 +-- .../src/Generated/Models/OpenAIFilePurpose.cs | 6 --- .../Samples/Images/Sample01_SimpleImage.cs | 2 +- .../Images/Sample01_SimpleImageAsync.cs | 2 +- .../Images/Sample02_SimpleImageEdit.cs | 2 +- .../Images/Sample02_SimpleImageEditAsync.cs | 2 +- .../Images/Sample03_SimpleImageVariation.cs | 2 +- .../Sample03_SimpleImageVariationAsync.cs | 2 +- files/models.tsp | 4 +- tsp-output/@typespec/openapi3/openapi.yaml | 2 - 19 files changed, 75 insertions(+), 91 deletions(-) create mode 100644 .dotnet/src/Custom/Files/OpenAIFilePurpose.cs rename .dotnet/src/Custom/Images/{ImageResponseFormat.cs => GeneratedImageFormat.cs} (79%) diff --git a/.dotnet/src/Custom/Files/FileClient.cs b/.dotnet/src/Custom/Files/FileClient.cs index 6dbeb8bf8..5a9e18aa0 100644 --- a/.dotnet/src/Custom/Files/FileClient.cs +++ b/.dotnet/src/Custom/Files/FileClient.cs @@ -91,13 +91,7 @@ public virtual async Task> GetFileInfoAsync(string public virtual ClientResult GetFileInfoList(OpenAIFilePurpose? purpose = null) { - Internal.Models.OpenAIFilePurpose? internalPurpose = ToInternalFilePurpose(purpose); - string internalPurposeText = null; - if (internalPurpose != null) - { - internalPurposeText = internalPurpose.ToString(); - } - ClientResult result = Shim.GetFiles(internalPurposeText); + ClientResult result = Shim.GetFiles(purpose?.ToString()); List infoItems = []; foreach (Internal.Models.OpenAIFile internalFile in result.Value.Data) { @@ -108,13 +102,7 @@ public virtual ClientResult GetFileInfoList(OpenAIFile public virtual async Task> GetFileInfoListAsync(OpenAIFilePurpose? purpose = null) { - Internal.Models.OpenAIFilePurpose? internalPurpose = ToInternalFilePurpose(purpose); - string internalPurposeText = null; - if (internalPurpose != null) - { - internalPurposeText = internalPurpose.ToString(); - } - ClientResult result = await Shim.GetFilesAsync(internalPurposeText).ConfigureAwait(false); + ClientResult result = await Shim.GetFilesAsync(purpose?.ToString()).ConfigureAwait(false); List infoItems = []; foreach (Internal.Models.OpenAIFile internalFile in result.Value.Data) { @@ -204,22 +192,6 @@ private PipelineMessage CreateUploadFileRequest(BinaryContent content, string co return message; } - private static Internal.Models.OpenAIFilePurpose? ToInternalFilePurpose(OpenAIFilePurpose? purpose) - { - if (purpose == null) - { - return null; - } - return purpose switch - { - OpenAIFilePurpose.FineTuning => Internal.Models.OpenAIFilePurpose.FineTune, - OpenAIFilePurpose.FineTuningResults => Internal.Models.OpenAIFilePurpose.FineTuneResults, - OpenAIFilePurpose.Assistants => Internal.Models.OpenAIFilePurpose.Assistants, - OpenAIFilePurpose.AssistantOutputs => Internal.Models.OpenAIFilePurpose.AssistantsOutput, - _ => throw new ArgumentException($"Unsupported file purpose: {purpose}"), - }; - } - private static PipelineMessageClassifier _responseErrorClassifier200; private static PipelineMessageClassifier ResponseErrorClassifier200 => _responseErrorClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); } diff --git a/.dotnet/src/Custom/Files/OpenAIFileInfo.cs b/.dotnet/src/Custom/Files/OpenAIFileInfo.cs index 82a8df617..a47684c13 100644 --- a/.dotnet/src/Custom/Files/OpenAIFileInfo.cs +++ b/.dotnet/src/Custom/Files/OpenAIFileInfo.cs @@ -13,28 +13,9 @@ public partial class OpenAIFileInfo internal OpenAIFileInfo(Internal.Models.OpenAIFile internalFile) { Id = internalFile.Id; - Purpose = internalFile.Purpose.ToString() switch - { - "assistants" => OpenAIFilePurpose.Assistants, - "assistants_output" => OpenAIFilePurpose.AssistantOutputs, - "batch" => OpenAIFilePurpose.BatchInput, - "batch_output" => OpenAIFilePurpose.BatchOutput, - "fine-tune" => OpenAIFilePurpose.FineTuning, - "fine-tune-results" => OpenAIFilePurpose.FineTuningResults, - _ => throw new ArgumentException(nameof(internalFile)), - }; + Purpose = internalFile.Purpose.ToString(); Filename = internalFile.Filename; Size = internalFile.Bytes; CreatedAt = internalFile.CreatedAt; } } - -public enum OpenAIFilePurpose -{ - Assistants, - AssistantOutputs, - BatchInput, - BatchOutput, - FineTuning, - FineTuningResults, -} \ No newline at end of file diff --git a/.dotnet/src/Custom/Files/OpenAIFilePurpose.cs b/.dotnet/src/Custom/Files/OpenAIFilePurpose.cs new file mode 100644 index 000000000..ada9b4887 --- /dev/null +++ b/.dotnet/src/Custom/Files/OpenAIFilePurpose.cs @@ -0,0 +1,48 @@ +using System; +using System.ComponentModel; + +namespace OpenAI.Files; + +public readonly partial struct OpenAIFilePurpose +{ + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIFilePurpose(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + internal OpenAIFilePurpose(Internal.Models.OpenAIFilePurpose internalPurpose) + : this(internalPurpose.ToString()) + { } + + /// fine-tune. + public static OpenAIFilePurpose FineTune { get; } = new OpenAIFilePurpose(Internal.Models.OpenAIFilePurpose.FineTune); + /// fine-tune-results. + public static OpenAIFilePurpose FineTuneResults { get; } = new OpenAIFilePurpose(Internal.Models.OpenAIFilePurpose.FineTuneResults); + /// assistants. + public static OpenAIFilePurpose Assistants { get; } = new OpenAIFilePurpose(Internal.Models.OpenAIFilePurpose.Assistants); + /// assistants_output. + public static OpenAIFilePurpose AssistantsOutput { get; } = new OpenAIFilePurpose(Internal.Models.OpenAIFilePurpose.AssistantsOutput); + + /// Determines if two values are the same. + public static bool operator ==(OpenAIFilePurpose left, OpenAIFilePurpose right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIFilePurpose left, OpenAIFilePurpose right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OpenAIFilePurpose(string value) => new OpenAIFilePurpose(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIFilePurpose other && Equals(other); + /// + public bool Equals(OpenAIFilePurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Files/UploadFileOptions.cs b/.dotnet/src/Custom/Files/UploadFileOptions.cs index bef736831..2cf5b166f 100644 --- a/.dotnet/src/Custom/Files/UploadFileOptions.cs +++ b/.dotnet/src/Custom/Files/UploadFileOptions.cs @@ -12,14 +12,7 @@ internal static MultipartFormDataBinaryContent ToMultipartContent(Stream file, s content.Add(file, "file", fileName); - string purposeValue = purpose switch - { - OpenAIFilePurpose.FineTuning => "fine-tune", - OpenAIFilePurpose.Assistants => "assistants", - _ => throw new ArgumentException($"Unsupported purpose for file upload: {purpose}"), - }; - - content.Add(purposeValue, "\"purpose\""); + content.Add(purpose.ToString(), "\"purpose\""); return content; } diff --git a/.dotnet/src/Custom/Images/GeneratedImage.cs b/.dotnet/src/Custom/Images/GeneratedImage.cs index 4643ffc24..0159e4d83 100644 --- a/.dotnet/src/Custom/Images/GeneratedImage.cs +++ b/.dotnet/src/Custom/Images/GeneratedImage.cs @@ -9,7 +9,7 @@ public class GeneratedImage { /// /// The binary image data received from the response, provided when - /// is set to . + /// is set to . /// /// /// This property is mutually exclusive with and will be null when the other @@ -18,7 +18,7 @@ public class GeneratedImage public BinaryData ImageBytes { get; } /// /// A temporary internet location for an image, provided by default or when - /// is set to . + /// is set to . /// /// /// This property is mutually exclusive with and will be null when the other diff --git a/.dotnet/src/Custom/Images/ImageResponseFormat.cs b/.dotnet/src/Custom/Images/GeneratedImageFormat.cs similarity index 79% rename from .dotnet/src/Custom/Images/ImageResponseFormat.cs rename to .dotnet/src/Custom/Images/GeneratedImageFormat.cs index 8403482c5..3a8c3c851 100644 --- a/.dotnet/src/Custom/Images/ImageResponseFormat.cs +++ b/.dotnet/src/Custom/Images/GeneratedImageFormat.cs @@ -6,17 +6,17 @@ namespace OpenAI.Images; /// Represents the available output methods for generated images. /// /// -/// url - - Default, provides a temporary internet location that +/// url - - Default, provides a temporary internet location that /// the generated image can be retrieved from. /// /// -/// b64_json - - Provides the full image data on the response, +/// b64_json - - Provides the full image data on the response, /// encoded in the result as a base64 string. This offers the fastest round trip time but can drastically /// increase the size of response payloads. /// /// /// -public enum ImageResponseFormat +public enum GeneratedImageFormat { /// /// Instructs the request to return image data directly on the response, encoded as a base64 string in the response diff --git a/.dotnet/src/Custom/Images/ImageClient.cs b/.dotnet/src/Custom/Images/ImageClient.cs index e4b39e807..9180887b4 100644 --- a/.dotnet/src/Custom/Images/ImageClient.cs +++ b/.dotnet/src/Custom/Images/ImageClient.cs @@ -255,8 +255,8 @@ private Internal.Models.CreateImageRequest CreateInternalImageRequest( { internalFormat = options.ResponseFormat switch { - ImageResponseFormat.Bytes => Internal.Models.CreateImageRequestResponseFormat.B64Json, - ImageResponseFormat.Uri => Internal.Models.CreateImageRequestResponseFormat.Url, + GeneratedImageFormat.Bytes => Internal.Models.CreateImageRequestResponseFormat.B64Json, + GeneratedImageFormat.Uri => Internal.Models.CreateImageRequestResponseFormat.Url, _ => throw new ArgumentException(nameof(options.ResponseFormat)), }; } diff --git a/.dotnet/src/Custom/Images/ImageEditOptions.cs b/.dotnet/src/Custom/Images/ImageEditOptions.cs index 15bbdc86e..fd02ec6a6 100644 --- a/.dotnet/src/Custom/Images/ImageEditOptions.cs +++ b/.dotnet/src/Custom/Images/ImageEditOptions.cs @@ -21,7 +21,7 @@ public partial class ImageEditOptions public string MaskFileName { get; init; } /// - public ImageResponseFormat? ResponseFormat { get; init; } + public GeneratedImageFormat? ResponseFormat { get; init; } /// public GeneratedImageSize? Size { get; init; } @@ -55,8 +55,8 @@ internal MultipartFormDataBinaryContent ToMultipartContent(Stream image, { string format = ResponseFormat switch { - ImageResponseFormat.Uri => "url", - ImageResponseFormat.Bytes => "b64_json", + GeneratedImageFormat.Uri => "url", + GeneratedImageFormat.Bytes => "b64_json", _ => throw new ArgumentException(nameof(ResponseFormat)), }; diff --git a/.dotnet/src/Custom/Images/ImageGenerationOptions.cs b/.dotnet/src/Custom/Images/ImageGenerationOptions.cs index 6956ddfb6..3f3b0a3af 100644 --- a/.dotnet/src/Custom/Images/ImageGenerationOptions.cs +++ b/.dotnet/src/Custom/Images/ImageGenerationOptions.cs @@ -23,17 +23,17 @@ public partial class ImageGenerationOptions /// Specifies the desired output representation of the generated image. /// /// - /// url - - Default, provides a temporary internet location that + /// url - - Default, provides a temporary internet location that /// the generated image can be retrieved from. /// /// - /// b64_json - - Provides the full image data on the response, + /// b64_json - - Provides the full image data on the response, /// encoded in the result as a base64 string. This offers the fastest round trip time but can drastically /// increase the size of response payloads. /// /// /// - public ImageResponseFormat? ResponseFormat { get; init; } + public GeneratedImageFormat? ResponseFormat { get; init; } /// /// Specifies the dimensions of the generated image. Larger images take longer to create. /// diff --git a/.dotnet/src/Custom/Images/ImageVariationOptions.cs b/.dotnet/src/Custom/Images/ImageVariationOptions.cs index fba844baf..71db1ec9d 100644 --- a/.dotnet/src/Custom/Images/ImageVariationOptions.cs +++ b/.dotnet/src/Custom/Images/ImageVariationOptions.cs @@ -14,7 +14,7 @@ public partial class ImageVariationOptions public GeneratedImageSize? Size { get; init; } /// - public ImageResponseFormat? ResponseFormat { get; init; } + public GeneratedImageFormat? ResponseFormat { get; init; } /// public string User { get; init; } @@ -35,8 +35,8 @@ internal MultipartFormDataBinaryContent ToMultipartContent(Stream image, string { string format = ResponseFormat switch { - ImageResponseFormat.Uri => "url", - ImageResponseFormat.Bytes => "b64_json", + GeneratedImageFormat.Uri => "url", + GeneratedImageFormat.Bytes => "b64_json", _ => throw new ArgumentException(nameof(ResponseFormat)), }; diff --git a/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs b/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs index 57ebf9188..97d4f29b4 100644 --- a/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs +++ b/.dotnet/src/Generated/Models/OpenAIFilePurpose.cs @@ -21,8 +21,6 @@ public OpenAIFilePurpose(string value) private const string FineTuneResultsValue = "fine-tune-results"; private const string AssistantsValue = "assistants"; private const string AssistantsOutputValue = "assistants_output"; - private const string BatchValue = "batch"; - private const string BatchOutputValue = "batch_output"; /// fine-tune. public static OpenAIFilePurpose FineTune { get; } = new OpenAIFilePurpose(FineTuneValue); @@ -32,10 +30,6 @@ public OpenAIFilePurpose(string value) public static OpenAIFilePurpose Assistants { get; } = new OpenAIFilePurpose(AssistantsValue); /// assistants_output. public static OpenAIFilePurpose AssistantsOutput { get; } = new OpenAIFilePurpose(AssistantsOutputValue); - /// batch. - public static OpenAIFilePurpose Batch { get; } = new OpenAIFilePurpose(BatchValue); - /// batch_output. - public static OpenAIFilePurpose BatchOutput { get; } = new OpenAIFilePurpose(BatchOutputValue); /// Determines if two values are the same. public static bool operator ==(OpenAIFilePurpose left, OpenAIFilePurpose right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs b/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs index 2fc2ce225..7ff7f3f18 100644 --- a/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs +++ b/.dotnet/tests/Samples/Images/Sample01_SimpleImage.cs @@ -26,7 +26,7 @@ public void Sample01_SimpleImage() Quality = GeneratedImageQuality.High, Size = GeneratedImageSize.W1792xH1024, Style = GeneratedImageStyle.Vivid, - ResponseFormat = ImageResponseFormat.Bytes + ResponseFormat = GeneratedImageFormat.Bytes }; GeneratedImage image = client.GenerateImage(prompt, options); diff --git a/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs b/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs index f71341d7b..d8627f76f 100644 --- a/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs +++ b/.dotnet/tests/Samples/Images/Sample01_SimpleImageAsync.cs @@ -27,7 +27,7 @@ public async Task Sample01_SimpleImageAsync() Quality = GeneratedImageQuality.High, Size = GeneratedImageSize.W1792xH1024, Style = GeneratedImageStyle.Vivid, - ResponseFormat = ImageResponseFormat.Bytes + ResponseFormat = GeneratedImageFormat.Bytes }; GeneratedImage image = await client.GenerateImageAsync(prompt, options); diff --git a/.dotnet/tests/Samples/Images/Sample02_SimpleImageEdit.cs b/.dotnet/tests/Samples/Images/Sample02_SimpleImageEdit.cs index 570e44829..cef915c14 100644 --- a/.dotnet/tests/Samples/Images/Sample02_SimpleImageEdit.cs +++ b/.dotnet/tests/Samples/Images/Sample02_SimpleImageEdit.cs @@ -28,7 +28,7 @@ public void Sample02_SimpleImageEdit() Mask = mask, MaskFileName = maskFileName, Size = GeneratedImageSize.W1024xH1024, - ResponseFormat = ImageResponseFormat.Bytes + ResponseFormat = GeneratedImageFormat.Bytes }; GeneratedImageCollection images = client.GenerateImageEdits(inputImage, imageFileName, prompt, 1, options); diff --git a/.dotnet/tests/Samples/Images/Sample02_SimpleImageEditAsync.cs b/.dotnet/tests/Samples/Images/Sample02_SimpleImageEditAsync.cs index e389c339a..e33262753 100644 --- a/.dotnet/tests/Samples/Images/Sample02_SimpleImageEditAsync.cs +++ b/.dotnet/tests/Samples/Images/Sample02_SimpleImageEditAsync.cs @@ -29,7 +29,7 @@ public async Task Sample02_SimpleImageEditAsync() Mask = mask, MaskFileName = maskFileName, Size = GeneratedImageSize.W1024xH1024, - ResponseFormat = ImageResponseFormat.Bytes + ResponseFormat = GeneratedImageFormat.Bytes }; GeneratedImageCollection images = await client.GenerateImageEditsAsync(inputImage, imageFileName, prompt, 1, options); diff --git a/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariation.cs b/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariation.cs index a590123ea..5ccfb3312 100644 --- a/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariation.cs +++ b/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariation.cs @@ -19,7 +19,7 @@ public void Sample03_SimpleImageVariation() ImageVariationOptions options = new() { Size = GeneratedImageSize.W1024xH1024, - ResponseFormat = ImageResponseFormat.Bytes + ResponseFormat = GeneratedImageFormat.Bytes }; GeneratedImageCollection images = client.GenerateImageVariations(inputImage, 1, options); diff --git a/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariationAsync.cs b/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariationAsync.cs index 58f708dde..ad9ee5b73 100644 --- a/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariationAsync.cs +++ b/.dotnet/tests/Samples/Images/Sample03_SimpleImageVariationAsync.cs @@ -20,7 +20,7 @@ public async Task Sample03_SimpleImageVariationAsync() ImageVariationOptions options = new() { Size = GeneratedImageSize.W1024xH1024, - ResponseFormat = ImageResponseFormat.Bytes + ResponseFormat = GeneratedImageFormat.Bytes }; GeneratedImageCollection images = await client.GenerateImageVariationsAsync(inputImage, 1, options); diff --git a/files/models.tsp b/files/models.tsp index bb013145c..7cfd02a68 100644 --- a/files/models.tsp +++ b/files/models.tsp @@ -33,9 +33,7 @@ alias FILE_PURPOSE = | "fine-tune" | "fine-tune-results" | "assistants" - | "assistants_output" - | "batch" - | "batch_output"; + | "assistants_output"; /** The `File` object represents a document that has been uploaded to OpenAI. */ model OpenAIFile { diff --git a/tsp-output/@typespec/openapi3/openapi.yaml b/tsp-output/@typespec/openapi3/openapi.yaml index 714c7a25c..7c8fe2946 100644 --- a/tsp-output/@typespec/openapi3/openapi.yaml +++ b/tsp-output/@typespec/openapi3/openapi.yaml @@ -4921,8 +4921,6 @@ components: - fine-tune-results - assistants - assistants_output - - batch - - batch_output description: |- The intended purpose of the file. Supported values are `fine-tune`, `fine-tune-results`, `assistants`, and `assistants_output`. From 2a9b1f65ef2abd4b536dd49e285be724bb8f79e0 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 28 Mar 2024 17:36:00 -0700 Subject: [PATCH 4/4] remove vestigial 'throw on error' in test (PR feedback) --- .dotnet/tests/Utility/TestHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dotnet/tests/Utility/TestHelpers.cs b/.dotnet/tests/Utility/TestHelpers.cs index ec5470f47..0bd2ff635 100644 --- a/.dotnet/tests/Utility/TestHelpers.cs +++ b/.dotnet/tests/Utility/TestHelpers.cs @@ -29,7 +29,7 @@ public enum TestScenario Moderations, } - public static T GetTestClient(TestScenario scenario, string overrideModel = null, bool throwOnError = true) + public static T GetTestClient(TestScenario scenario, string overrideModel = null) { OpenAIClientOptions options = new(); options.AddPolicy(GetDumpPolicy(), PipelinePosition.PerTry);