diff --git a/CHANGELOG.md b/CHANGELOG.md index d91e5d57..5290cba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,16 +4,23 @@ ### Features Added +- Added the following model factory (a static class that can be used to instantiate OpenAI models for mocking in non-live test scenarios): + - `OpenAIChatModelFactory` in the `OpenAI.Chat` namespace + ### Breaking Changes - Updated fine-tuning pagination methods `GetJobs`, `GetEvents`, and `GetJobCheckpoints` to return `IEnumerable` instead of `ClientResult`. (commit_hash) - Updated the batching pagination method `GetBatches` to return `IEnumerable` instead of `ClientResult`. (commit_hash) +- Changed `GeneratedSpeechVoice` from an enum to an "extensible enum". (commit_hash) ### Bugs Fixed ### Other Changes - Reverted the removal of the version path parameter "v1" from the default endpoint URL. (commit_hash) +- Added the `Experimental` attribute to all public APIs in the `OpenAI.Assistants` namespace. (commit_hash) +- Added the `Experimental` attribute to all public APIs in the `OpenAI.VectorStores` namespace. (commit_hash) + ## 2.0.0-beta.10 (2024-08-26) diff --git a/api/OpenAI.netstandard2.0.cs b/api/OpenAI.netstandard2.0.cs index 9db98764..87abb883 100644 --- a/api/OpenAI.netstandard2.0.cs +++ b/api/OpenAI.netstandard2.0.cs @@ -1092,13 +1092,25 @@ public enum GeneratedSpeechFormat { Wav = 4, Pcm = 5 } - public enum GeneratedSpeechVoice { - Alloy = 0, - Echo = 1, - Fable = 2, - Onyx = 3, - Nova = 4, - Shimmer = 5 + public readonly partial struct GeneratedSpeechVoice : IEquatable { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public GeneratedSpeechVoice(string value); + public static GeneratedSpeechVoice Alloy { get; } + public static GeneratedSpeechVoice Echo { get; } + public static GeneratedSpeechVoice Fable { get; } + public static GeneratedSpeechVoice Nova { get; } + public static GeneratedSpeechVoice Onyx { get; } + public static GeneratedSpeechVoice Shimmer { get; } + public readonly bool Equals(GeneratedSpeechVoice other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(GeneratedSpeechVoice left, GeneratedSpeechVoice right); + public static implicit operator GeneratedSpeechVoice(string value); + public static bool operator !=(GeneratedSpeechVoice left, GeneratedSpeechVoice right); + public override readonly string ToString(); } public static class OpenAIAudioModelFactory { public static AudioTranscription AudioTranscription(string language = null, TimeSpan? duration = null, string text = null, IEnumerable words = null, IEnumerable segments = null); @@ -1517,6 +1529,15 @@ public class FunctionChatMessage : ChatMessage, IJsonModel, public static bool operator !=(ImageChatMessageContentPartDetail left, ImageChatMessageContentPartDetail right); public override readonly string ToString(); } + public static class OpenAIChatModelFactory { + public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, IEnumerable content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null); + public static ChatTokenLogProbabilityInfo ChatTokenLogProbabilityInfo(string token = null, float logProbability = 0, IEnumerable utf8ByteValues = null, IEnumerable topLogProbabilities = null); + public static ChatTokenTopLogProbabilityInfo ChatTokenTopLogProbabilityInfo(string token = null, float logProbability = 0, IEnumerable utf8ByteValues = null); + public static ChatTokenUsage ChatTokenUsage(int outputTokens = 0, int inputTokens = 0, int totalTokens = 0); + public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string id = null, IEnumerable contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null); + public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionArgumentsUpdate = null, string functionName = null); + public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = 0, string id = null, ChatToolCallKind kind = default, string functionName = null, string functionArgumentsUpdate = null); + } public class StreamingChatCompletionUpdate : IJsonModel, IPersistableModel { public IReadOnlyList ContentTokenLogProbabilities { get; } public IReadOnlyList ContentUpdate { get; } diff --git a/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs b/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs index 6d9117e9..d947896c 100644 --- a/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs +++ b/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs @@ -15,7 +15,6 @@ public partial class AssistantExamples public void Example01_RetrievalAugmentedGeneration() { // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 OpenAIClient openAIClient = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); FileClient fileClient = openAIClient.GetFileClient(); AssistantClient assistantClient = openAIClient.GetAssistantClient(); @@ -99,7 +98,7 @@ public void Example01_RetrievalAugmentedGeneration() // Finally, we'll print out the full history for the thread that includes the augmented generation PageCollection messagePages - = assistantClient.GetMessages(threadRun.ThreadId, new MessageCollectionOptions() { Order = ListOrder.OldestFirst }); + = assistantClient.GetMessages(threadRun.ThreadId, new MessageCollectionOptions() { Order = ListOrder.OldestFirst }); IEnumerable messages = messagePages.GetAllValues(); foreach (ThreadMessage message in messages) diff --git a/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs b/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs index 13b49145..52f66a01 100644 --- a/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs +++ b/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs @@ -16,7 +16,6 @@ public partial class AssistantExamples public async Task Example01_RetrievalAugmentedGenerationAsync() { // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 OpenAIClient openAIClient = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); FileClient fileClient = openAIClient.GetFileClient(); AssistantClient assistantClient = openAIClient.GetAssistantClient(); diff --git a/examples/Assistants/Example02_FunctionCalling.cs b/examples/Assistants/Example02_FunctionCalling.cs index a0eb0563..da0a1668 100644 --- a/examples/Assistants/Example02_FunctionCalling.cs +++ b/examples/Assistants/Example02_FunctionCalling.cs @@ -61,7 +61,6 @@ string GetCurrentWeather(string location, string unit = "celsius") #endregion // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 AssistantClient client = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); #region diff --git a/examples/Assistants/Example02_FunctionCallingAsync.cs b/examples/Assistants/Example02_FunctionCallingAsync.cs index 2ee924c5..6619172f 100644 --- a/examples/Assistants/Example02_FunctionCallingAsync.cs +++ b/examples/Assistants/Example02_FunctionCallingAsync.cs @@ -61,7 +61,6 @@ string GetCurrentWeather(string location, string unit = "celsius") #endregion // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 AssistantClient client = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); #region diff --git a/examples/Assistants/Example02b_FunctionCallingStreaming.cs b/examples/Assistants/Example02b_FunctionCallingStreaming.cs index 9c3e0adf..d4499015 100644 --- a/examples/Assistants/Example02b_FunctionCallingStreaming.cs +++ b/examples/Assistants/Example02b_FunctionCallingStreaming.cs @@ -63,7 +63,6 @@ public async Task Example02b_FunctionCallingStreaming() #endregion // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 AssistantClient client = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); #region Create a new assistant with function tools diff --git a/examples/Assistants/Example03_ListAssistantsWithPagination.cs b/examples/Assistants/Example03_ListAssistantsWithPagination.cs index 83776d7a..ace0608f 100644 --- a/examples/Assistants/Example03_ListAssistantsWithPagination.cs +++ b/examples/Assistants/Example03_ListAssistantsWithPagination.cs @@ -12,7 +12,6 @@ public partial class AssistantExamples public void Example03_ListAssistantsWithPagination() { // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 AssistantClient client = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); int count = 0; diff --git a/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs b/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs index 1f4d8218..57696ddb 100644 --- a/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs +++ b/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs @@ -13,7 +13,6 @@ public partial class AssistantExamples public async Task Example03_ListAssistantsWithPaginationAsync() { // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 AssistantClient client = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); int count = 0; diff --git a/examples/Assistants/Example04_AllTheTools.cs b/examples/Assistants/Example04_AllTheTools.cs index 5a894305..e1d62db8 100644 --- a/examples/Assistants/Example04_AllTheTools.cs +++ b/examples/Assistants/Example04_AllTheTools.cs @@ -14,8 +14,6 @@ public partial class AssistantExamples [Test] public void Example04_AllTheTools() { -#pragma warning disable OPENAI001 - #region Define a function tool static string GetNameOfFamilyMember(string relation) => relation switch diff --git a/examples/Assistants/Example05_AssistantsWithVision.cs b/examples/Assistants/Example05_AssistantsWithVision.cs index 99315cdf..d7af0620 100644 --- a/examples/Assistants/Example05_AssistantsWithVision.cs +++ b/examples/Assistants/Example05_AssistantsWithVision.cs @@ -12,7 +12,6 @@ public partial class AssistantExamples public void Example05_AssistantsWithVision() { // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 OpenAIClient openAIClient = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); FileClient fileClient = openAIClient.GetFileClient(); AssistantClient assistantClient = openAIClient.GetAssistantClient(); diff --git a/examples/Assistants/Example05_AssistantsWithVisionAsync.cs b/examples/Assistants/Example05_AssistantsWithVisionAsync.cs index db23818d..1e1e521f 100644 --- a/examples/Assistants/Example05_AssistantsWithVisionAsync.cs +++ b/examples/Assistants/Example05_AssistantsWithVisionAsync.cs @@ -13,7 +13,6 @@ public partial class AssistantExamples public async Task Example05_AssistantsWithVisionAsync() { // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. -#pragma warning disable OPENAI001 OpenAIClient openAIClient = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); FileClient fileClient = openAIClient.GetFileClient(); AssistantClient assistantClient = openAIClient.GetAssistantClient(); diff --git a/examples/Chat/Example01_SimpleChat_Cancellations.cs b/examples/Chat/Example01_SimpleChat_Cancellations.cs index aaf13df0..dbeb05e6 100644 --- a/examples/Chat/Example01_SimpleChat_Cancellations.cs +++ b/examples/Chat/Example01_SimpleChat_Cancellations.cs @@ -18,9 +18,10 @@ public void Example01_SimpleChat_Cancellations() RequestOptions options = new() { CancellationToken = ct.Token }; ChatMessage message = ChatMessage.CreateUserMessage("Say 'this is a test.'"); - var body = new { + var body = new + { model = "gpt-4o", - messages = new[] { + messages = new[] { new { role = "user", @@ -28,7 +29,7 @@ public void Example01_SimpleChat_Cancellations() } } }; - + BinaryData json = BinaryData.FromObjectAsJson(body); ClientResult result = client.CompleteChat(BinaryContent.Create(json), options); diff --git a/examples/Chat/Example07_StructuredOutputs.cs b/examples/Chat/Example07_StructuredOutputs.cs index 52669ebe..4e433522 100644 --- a/examples/Chat/Example07_StructuredOutputs.cs +++ b/examples/Chat/Example07_StructuredOutputs.cs @@ -46,7 +46,7 @@ public void Example07_StructuredOutputs() options); using JsonDocument structuredJson = JsonDocument.Parse(chatCompletion.ToString()); - + Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}"); Console.WriteLine("Reasoning steps:"); diff --git a/examples/Chat/Example07_StructuredOutputsAsync.cs b/examples/Chat/Example07_StructuredOutputsAsync.cs index 280b67bc..5f2732d8 100644 --- a/examples/Chat/Example07_StructuredOutputsAsync.cs +++ b/examples/Chat/Example07_StructuredOutputsAsync.cs @@ -47,7 +47,7 @@ public async Task Example07_StructuredOutputsAsync() options); using JsonDocument structuredJson = JsonDocument.Parse(chatCompletion.ToString()); - + Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}"); Console.WriteLine("Reasoning steps:"); diff --git a/examples/ClientExamples.cs b/examples/ClientExamples.cs index dff74f11..18947925 100644 --- a/examples/ClientExamples.cs +++ b/examples/ClientExamples.cs @@ -42,8 +42,6 @@ public void CreateAssistantAndFileClients() { OpenAIClient openAIClient = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); FileClient fileClient = openAIClient.GetFileClient(); -#pragma warning disable OPENAI001 AssistantClient assistantClient = openAIClient.GetAssistantClient(); -#pragma warning restore OPENAI001 } } diff --git a/examples/Embeddings/Example04_SimpleEmbeddingProtocol.cs b/examples/Embeddings/Example04_SimpleEmbeddingProtocol.cs index ea0992be..d23112e8 100644 --- a/examples/Embeddings/Example04_SimpleEmbeddingProtocol.cs +++ b/examples/Embeddings/Example04_SimpleEmbeddingProtocol.cs @@ -17,11 +17,12 @@ public void Example04_SimpleEmbeddingProtocol() + " and a really helpful concierge. The location is perfect -- right downtown, close to all the tourist" + " attractions. We highly recommend this hotel."; - BinaryData input = BinaryData.FromObjectAsJson(new { - model = "text-embedding-3-small", - input = description, - encoding_format = "float" - }); + BinaryData input = BinaryData.FromObjectAsJson(new + { + model = "text-embedding-3-small", + input = description, + encoding_format = "float" + }); using BinaryContent content = BinaryContent.Create(input); ClientResult result = client.GenerateEmbeddings(content); diff --git a/examples/OpenAI.Examples.csproj b/examples/OpenAI.Examples.csproj index b33b036e..74bf8c48 100644 --- a/examples/OpenAI.Examples.csproj +++ b/examples/OpenAI.Examples.csproj @@ -1,8 +1,13 @@ net8.0 - - $(NoWarn);CS1591 + + + $(NoWarn);CS1591; + + + $(NoWarn);OPENAI001; + latest diff --git a/src/Custom/Assistants/Assistant.cs b/src/Custom/Assistants/Assistant.cs index 34ee4016..db714f55 100644 --- a/src/Custom/Assistants/Assistant.cs +++ b/src/Custom/Assistants/Assistant.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("AssistantObject")] public partial class Assistant { diff --git a/src/Custom/Assistants/AssistantClient.Convenience.cs b/src/Custom/Assistants/AssistantClient.Convenience.cs index 5eb15133..cc6f19ee 100644 --- a/src/Custom/Assistants/AssistantClient.Convenience.cs +++ b/src/Custom/Assistants/AssistantClient.Convenience.cs @@ -152,7 +152,7 @@ public virtual AsyncPageCollection GetMessagesAsync( /// page of values, call . /// A collection of pages of . public virtual PageCollection GetMessages( - AssistantThread thread, + AssistantThread thread, MessageCollectionOptions options = default) { Argument.AssertNotNull(thread, nameof(thread)); diff --git a/src/Custom/Assistants/AssistantCollectionOptions.cs b/src/Custom/Assistants/AssistantCollectionOptions.cs index c7baa96d..7791e3be 100644 --- a/src/Custom/Assistants/AssistantCollectionOptions.cs +++ b/src/Custom/Assistants/AssistantCollectionOptions.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// Represents addition options available when requesting a collection of instances. /// +[Experimental("OPENAI001")] public class AssistantCollectionOptions { /// diff --git a/src/Custom/Assistants/AssistantCreationOptions.cs b/src/Custom/Assistants/AssistantCreationOptions.cs index c00b6e82..1072600c 100644 --- a/src/Custom/Assistants/AssistantCreationOptions.cs +++ b/src/Custom/Assistants/AssistantCreationOptions.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; /// /// Represents additional options available when creating a new . /// +[Experimental("OPENAI001")] [CodeGenModel("CreateAssistantRequest")] [CodeGenSuppress(nameof(AssistantCreationOptions), typeof(string))] public partial class AssistantCreationOptions @@ -36,7 +38,7 @@ public partial class AssistantCreationOptions /// [CodeGenMember("TopP")] public float? NucleusSamplingFactor { get; set; } - + internal AssistantCreationOptions(InternalCreateAssistantRequestModel model) : this() { @@ -51,4 +53,4 @@ public AssistantCreationOptions() Metadata = new ChangeTrackingDictionary(); Tools = new ChangeTrackingList(); } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/AssistantModificationOptions.cs b/src/Custom/Assistants/AssistantModificationOptions.cs index bbd8b2ef..6d254498 100644 --- a/src/Custom/Assistants/AssistantModificationOptions.cs +++ b/src/Custom/Assistants/AssistantModificationOptions.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; /// /// Represents additional options available when modifying an existing . /// +[Experimental("OPENAI001")] [CodeGenModel("ModifyAssistantRequest")] public partial class AssistantModificationOptions { @@ -40,4 +42,4 @@ public partial class AssistantModificationOptions /// [CodeGenMember("TopP")] public float? NucleusSamplingFactor { get; set; } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/AssistantResponseFormat.cs b/src/Custom/Assistants/AssistantResponseFormat.cs index c87b9b07..597bbb6b 100644 --- a/src/Custom/Assistants/AssistantResponseFormat.cs +++ b/src/Custom/Assistants/AssistantResponseFormat.cs @@ -2,9 +2,11 @@ using System; using System.ClientModel.Primitives; using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("AssistantResponseFormat")] public partial class AssistantResponseFormat : IEquatable, IEquatable { @@ -106,4 +108,4 @@ public override string ToString() return ModelReaderWriter.Write(this).ToString(); } } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/AssistantThread.cs b/src/Custom/Assistants/AssistantThread.cs index 37676666..ea5e65f7 100644 --- a/src/Custom/Assistants/AssistantThread.cs +++ b/src/Custom/Assistants/AssistantThread.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("ThreadObject")] public partial class AssistantThread { diff --git a/src/Custom/Assistants/CodeInterpreterToolDefinition.Serialization.cs b/src/Custom/Assistants/CodeInterpreterToolDefinition.Serialization.cs index 6318e87c..eae645a6 100644 --- a/src/Custom/Assistants/CodeInterpreterToolDefinition.Serialization.cs +++ b/src/Custom/Assistants/CodeInterpreterToolDefinition.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; @@ -23,4 +20,4 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options); writer.WriteEndObject(); } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/CodeInterpreterToolResources.cs b/src/Custom/Assistants/CodeInterpreterToolResources.cs index 82f35492..6b763dc6 100644 --- a/src/Custom/Assistants/CodeInterpreterToolResources.cs +++ b/src/Custom/Assistants/CodeInterpreterToolResources.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; /// The AssistantObjectToolResourcesCodeInterpreter. +[Experimental("OPENAI001")] [CodeGenModel("AssistantObjectToolResourcesCodeInterpreter")] public partial class CodeInterpreterToolResources { diff --git a/src/Custom/Assistants/FileSearchToolDefinition.Serialization.cs b/src/Custom/Assistants/FileSearchToolDefinition.Serialization.cs index 19cd9807..36968d79 100644 --- a/src/Custom/Assistants/FileSearchToolDefinition.Serialization.cs +++ b/src/Custom/Assistants/FileSearchToolDefinition.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; diff --git a/src/Custom/Assistants/FileSearchToolDefinition.cs b/src/Custom/Assistants/FileSearchToolDefinition.cs index 2bc8efff..1fb69bec 100644 --- a/src/Custom/Assistants/FileSearchToolDefinition.cs +++ b/src/Custom/Assistants/FileSearchToolDefinition.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("AssistantToolsFileSearch")] [CodeGenSuppress(nameof(FileSearchToolDefinition))] public partial class FileSearchToolDefinition : ToolDefinition diff --git a/src/Custom/Assistants/FileSearchToolResources.cs b/src/Custom/Assistants/FileSearchToolResources.cs index 53e0d6bc..8c199b06 100644 --- a/src/Custom/Assistants/FileSearchToolResources.cs +++ b/src/Custom/Assistants/FileSearchToolResources.cs @@ -1,9 +1,11 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("ToolResourcesFileSearch")] [CodeGenSerialization(nameof(NewVectorStores), "vector_stores", SerializationValueHook = nameof(SerializeNewVectorStores))] public partial class FileSearchToolResources diff --git a/src/Custom/Assistants/FunctionToolDefinition.Serialization.cs b/src/Custom/Assistants/FunctionToolDefinition.Serialization.cs index 70172567..37506d83 100644 --- a/src/Custom/Assistants/FunctionToolDefinition.Serialization.cs +++ b/src/Custom/Assistants/FunctionToolDefinition.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; @@ -14,7 +11,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader internal static void SerializeFunctionToolDefinition(FunctionToolDefinition instance, Utf8JsonWriter writer, ModelReaderWriterOptions options) => instance.WriteCore(writer, options); - + protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -25,4 +22,4 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options); writer.WriteEndObject(); } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/FunctionToolDefinition.cs b/src/Custom/Assistants/FunctionToolDefinition.cs index 70e2ba16..7ceaa643 100644 --- a/src/Custom/Assistants/FunctionToolDefinition.cs +++ b/src/Custom/Assistants/FunctionToolDefinition.cs @@ -4,6 +4,7 @@ namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("AssistantToolsFunction")] [CodeGenSuppress(nameof(FunctionToolDefinition), typeof(InternalFunctionDefinition))] public partial class FunctionToolDefinition : ToolDefinition diff --git a/src/Custom/Assistants/GeneratorStubs.cs b/src/Custom/Assistants/GeneratorStubs.cs index 9efb3dfb..93223b65 100644 --- a/src/Custom/Assistants/GeneratorStubs.cs +++ b/src/Custom/Assistants/GeneratorStubs.cs @@ -1,51 +1,67 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /* * This file stubs and performs minimal customization to generated public types for the OpenAI.Assistants namespace * that are not otherwise attributed elsewhere. */ - +[Experimental("OPENAI001")] [CodeGenModel("AssistantToolsCode")] public partial class CodeInterpreterToolDefinition : ToolDefinition { } +[Experimental("OPENAI001")] [CodeGenModel("MessageObjectStatus")] public readonly partial struct MessageStatus { } +[Experimental("OPENAI001")] [CodeGenModel("MessageObjectIncompleteDetails")] public partial class MessageFailureDetails { } +[Experimental("OPENAI001")] [CodeGenModel("MessageObjectIncompleteDetailsReason")] public readonly partial struct MessageFailureReason { } +[Experimental("OPENAI001")] [CodeGenModel("RunCompletionUsage")] public partial class RunTokenUsage { } +[Experimental("OPENAI001")] [CodeGenModel("RunObjectLastError")] public partial class RunError { } +[Experimental("OPENAI001")] [CodeGenModel("RunObjectLastErrorCode")] public readonly partial struct RunErrorCode { } +[Experimental("OPENAI001")] [CodeGenModel("RunObjectIncompleteDetails")] public partial class RunIncompleteDetails { } +[Experimental("OPENAI001")] [CodeGenModel("RunObjectIncompleteDetailsReason")] public readonly partial struct RunIncompleteReason { } +[Experimental("OPENAI001")] [CodeGenModel("RunStepObjectType")] public readonly partial struct RunStepType { } +[Experimental("OPENAI001")] [CodeGenModel("RunStepObjectStatus")] public readonly partial struct RunStepStatus { } +[Experimental("OPENAI001")] [CodeGenModel("RunStepObjectLastError")] public partial class RunStepError { } +[Experimental("OPENAI001")] [CodeGenModel("RunStepObjectLastErrorCode")] public readonly partial struct RunStepErrorCode { } +[Experimental("OPENAI001")] [CodeGenModel("RunStepCompletionUsage")] public partial class RunStepTokenUsage { } +[Experimental("OPENAI001")] [CodeGenModel("RunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject")] public partial class RunStepCodeInterpreterOutput { } diff --git a/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs b/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs index 08f753db..ef35a416 100644 --- a/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs +++ b/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs @@ -154,31 +154,31 @@ internal partial class InternalRunToolCallObjectFunction { } internal partial class InternalListAssistantsResponse : IInternalListResponse { } [CodeGenModel("ListAssistantsResponseObject")] -internal readonly partial struct InternalListAssistantsResponseObject {} +internal readonly partial struct InternalListAssistantsResponseObject { } [CodeGenModel("ListThreadsResponse")] internal partial class InternalListThreadsResponse : IInternalListResponse { } [CodeGenModel("ListThreadsResponseObject")] -internal readonly partial struct InternalListThreadsResponseObject {} +internal readonly partial struct InternalListThreadsResponseObject { } [CodeGenModel("ListMessagesResponse")] internal partial class InternalListMessagesResponse : IInternalListResponse { } [CodeGenModel("ListMessagesResponseObject")] -internal readonly partial struct InternalListMessagesResponseObject {} +internal readonly partial struct InternalListMessagesResponseObject { } [CodeGenModel("ListRunsResponse")] internal partial class InternalListRunsResponse : IInternalListResponse { } [CodeGenModel("ListRunsResponseObject")] -internal readonly partial struct InternalListRunsResponseObject {} +internal readonly partial struct InternalListRunsResponseObject { } [CodeGenModel("ListRunStepsResponse")] internal partial class InternalListRunStepsResponse : IInternalListResponse { } [CodeGenModel("ListRunStepsResponseObject")] -internal readonly partial struct InternalListRunStepsResponseObject {} +internal readonly partial struct InternalListRunStepsResponseObject { } [CodeGenModel("RunStepDetailsToolCallsFileSearchObject")] internal partial class InternalRunStepFileSearchToolCallDetails { } diff --git a/src/Custom/Assistants/Internal/InternalMessageImageFileContent.Serialization.cs b/src/Custom/Assistants/Internal/InternalMessageImageFileContent.Serialization.cs index c6dd038a..1aeb34fb 100644 --- a/src/Custom/Assistants/Internal/InternalMessageImageFileContent.Serialization.cs +++ b/src/Custom/Assistants/Internal/InternalMessageImageFileContent.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; diff --git a/src/Custom/Assistants/Internal/InternalMessageImageFileContent.cs b/src/Custom/Assistants/Internal/InternalMessageImageFileContent.cs index 222a44dc..1aac69dd 100644 --- a/src/Custom/Assistants/Internal/InternalMessageImageFileContent.cs +++ b/src/Custom/Assistants/Internal/InternalMessageImageFileContent.cs @@ -28,7 +28,7 @@ internal partial class InternalMessageImageFileContent /// Initializes a new instance of . internal InternalMessageImageFileContent(string imageFileId, MessageImageDetail? detail = null) : this(new InternalMessageContentItemFileObjectImageFile(imageFileId, detail?.ToSerialString(), null)) - {} + { } /// Initializes a new instance of . /// diff --git a/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.Serialization.cs b/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.Serialization.cs index 48d0f775..71abe7d8 100644 --- a/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.Serialization.cs +++ b/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; diff --git a/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.cs b/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.cs index f007fec8..76388449 100644 --- a/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.cs +++ b/src/Custom/Assistants/Internal/InternalMessageImageUrlContent.cs @@ -28,7 +28,7 @@ internal partial class InternalMessageImageUrlContent /// Initializes a new instance of . internal InternalMessageImageUrlContent(Uri url, MessageImageDetail? detail = null) : this(new InternalMessageContentImageUrlObjectImageUrl(url, detail?.ToSerialString(), null)) - {} + { } /// Initializes a new instance of . /// diff --git a/src/Custom/Assistants/Internal/InternalMessageRefusalContent.Serialization.cs b/src/Custom/Assistants/Internal/InternalMessageRefusalContent.Serialization.cs index b14bf17a..660fde6e 100644 --- a/src/Custom/Assistants/Internal/InternalMessageRefusalContent.Serialization.cs +++ b/src/Custom/Assistants/Internal/InternalMessageRefusalContent.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; diff --git a/src/Custom/Assistants/Internal/InternalRequestMessageTextContent.Serialization.cs b/src/Custom/Assistants/Internal/InternalRequestMessageTextContent.Serialization.cs index 565c34ee..93f479e8 100644 --- a/src/Custom/Assistants/Internal/InternalRequestMessageTextContent.Serialization.cs +++ b/src/Custom/Assistants/Internal/InternalRequestMessageTextContent.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; diff --git a/src/Custom/Assistants/Internal/InternalRequiredFunctionToolCall.cs b/src/Custom/Assistants/Internal/InternalRequiredFunctionToolCall.cs index 89ed0f09..4bd70fc9 100644 --- a/src/Custom/Assistants/Internal/InternalRequiredFunctionToolCall.cs +++ b/src/Custom/Assistants/Internal/InternalRequiredFunctionToolCall.cs @@ -10,7 +10,7 @@ internal partial class InternalRequiredFunctionToolCall : InternalRequiredToolCa // - 'Type' is hidden, as the object discriminator does not carry additional value to the caller in the context // of a strongly-typed object model // - 'Function' is hidden and its constituent 'Name' and 'Arguments' members are promoted to direct visibility - + [CodeGenMember("Type")] private readonly object _type; [CodeGenMember("Function")] diff --git a/src/Custom/Assistants/Internal/InternalResponseMessageTextContent.Serialization.cs b/src/Custom/Assistants/Internal/InternalResponseMessageTextContent.Serialization.cs index 5cb19bb1..f78582af 100644 --- a/src/Custom/Assistants/Internal/InternalResponseMessageTextContent.Serialization.cs +++ b/src/Custom/Assistants/Internal/InternalResponseMessageTextContent.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; diff --git a/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterToolCallDetails.cs b/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterToolCallDetails.cs index 71f873f0..db9e2eb3 100644 --- a/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterToolCallDetails.cs +++ b/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterToolCallDetails.cs @@ -7,7 +7,7 @@ internal partial class InternalRunStepCodeInterpreterToolCallDetails { /// public string Input => _codeInterpreter.Input; - + /// public IReadOnlyList Outputs => _codeInterpreter.Outputs; diff --git a/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs b/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs index 66019bbb..7fb974d7 100644 --- a/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs +++ b/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs @@ -22,7 +22,7 @@ internal partial class AssistantsPageEnumerator : PageEnumerator private readonly RequestOptions _options; public virtual ClientPipeline Pipeline => _pipeline; - + public AssistantsPageEnumerator( ClientPipeline pipeline, Uri endpoint, diff --git a/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs b/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs index 53e09fec..a5488cc6 100644 --- a/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs +++ b/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs @@ -27,7 +27,7 @@ internal partial class MessagesPageEnumerator : PageEnumerator public MessagesPageEnumerator( ClientPipeline pipeline, Uri endpoint, - string threadId, + string threadId, int? limit, string order, string after, string before, RequestOptions options) { diff --git a/src/Custom/Assistants/Internal/Pagination/MessagesPageToken.cs b/src/Custom/Assistants/Internal/Pagination/MessagesPageToken.cs index ff4bfa9f..974fa40c 100644 --- a/src/Custom/Assistants/Internal/Pagination/MessagesPageToken.cs +++ b/src/Custom/Assistants/Internal/Pagination/MessagesPageToken.cs @@ -65,7 +65,7 @@ public override BinaryData ToBytes() return BinaryData.FromStream(stream); } - + public MessagesPageToken? GetNextPageToken(bool hasMore, string? lastId) { if (!hasMore || lastId is null) diff --git a/src/Custom/Assistants/Internal/Pagination/RunStepsPageToken.cs b/src/Custom/Assistants/Internal/Pagination/RunStepsPageToken.cs index 2579e744..ad9883d0 100644 --- a/src/Custom/Assistants/Internal/Pagination/RunStepsPageToken.cs +++ b/src/Custom/Assistants/Internal/Pagination/RunStepsPageToken.cs @@ -69,7 +69,7 @@ public override BinaryData ToBytes() return BinaryData.FromStream(stream); } - + public RunStepsPageToken? GetNextPageToken(bool hasMore, string? lastId) { if (!hasMore || lastId is null) diff --git a/src/Custom/Assistants/Internal/Pagination/RunsPageToken.cs b/src/Custom/Assistants/Internal/Pagination/RunsPageToken.cs index 28b27f47..06d6878f 100644 --- a/src/Custom/Assistants/Internal/Pagination/RunsPageToken.cs +++ b/src/Custom/Assistants/Internal/Pagination/RunsPageToken.cs @@ -65,7 +65,7 @@ public override BinaryData ToBytes() return BinaryData.FromStream(stream); } - + public RunsPageToken? GetNextPageToken(bool hasMore, string? lastId) { if (!hasMore || lastId is null) diff --git a/src/Custom/Assistants/Internal/UnknownAssistantToolDefinition.Serialization.cs b/src/Custom/Assistants/Internal/UnknownAssistantToolDefinition.Serialization.cs index 3a80df55..b990dcba 100644 --- a/src/Custom/Assistants/Internal/UnknownAssistantToolDefinition.Serialization.cs +++ b/src/Custom/Assistants/Internal/UnknownAssistantToolDefinition.Serialization.cs @@ -1,7 +1,4 @@ -using System; -using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace OpenAI.Assistants; diff --git a/src/Custom/Assistants/MessageCollectionOptions.cs b/src/Custom/Assistants/MessageCollectionOptions.cs index ac4bf221..113ebbf6 100644 --- a/src/Custom/Assistants/MessageCollectionOptions.cs +++ b/src/Custom/Assistants/MessageCollectionOptions.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// Represents addition options available when requesting a collection of instances. /// +[Experimental("OPENAI001")] public class MessageCollectionOptions { /// @@ -30,4 +33,4 @@ public MessageCollectionOptions() { } /// The id of the item following the last item in the collection. /// public string BeforeId { get; set; } -} +} \ No newline at end of file diff --git a/src/Custom/Assistants/MessageContent.cs b/src/Custom/Assistants/MessageContent.cs index 8043d79c..f8b9840e 100644 --- a/src/Custom/Assistants/MessageContent.cs +++ b/src/Custom/Assistants/MessageContent.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("MessageContent")] public abstract partial class MessageContent { diff --git a/src/Custom/Assistants/MessageCreationAttachment.cs b/src/Custom/Assistants/MessageCreationAttachment.cs index 46827002..d3409532 100644 --- a/src/Custom/Assistants/MessageCreationAttachment.cs +++ b/src/Custom/Assistants/MessageCreationAttachment.cs @@ -1,9 +1,11 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("CreateMessageRequestAttachment")] [CodeGenSerialization(nameof(Tools), "tools", SerializationValueHook = nameof(SerializeTools), DeserializationValueHook = nameof(DeserializeTools))] public partial class MessageCreationAttachment @@ -42,4 +44,4 @@ private static void DeserializeTools(JsonProperty property, ref IReadOnlyList /// Represents additional options available when creating a new . /// +[Experimental("OPENAI001")] [CodeGenModel("CreateMessageRequest")] [CodeGenSuppress("MessageCreationOptions", typeof(MessageRole), typeof(IEnumerable))] -[CodeGenSerialization(nameof(Content), SerializationValueHook=nameof(SerializeContent))] +[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContent))] public partial class MessageCreationOptions { // CUSTOM: role is hidden, as this required property is promoted to a method parameter @@ -32,10 +34,10 @@ public MessageCreationOptions() new ChangeTrackingList(), new ChangeTrackingDictionary(), new ChangeTrackingDictionary()) - {} + { } internal MessageCreationOptions(IEnumerable content) : this() { Content = [.. content]; } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/MessageImageDetail.Serialization.cs b/src/Custom/Assistants/MessageImageDetail.Serialization.cs index 1aa776a8..1fb86853 100644 --- a/src/Custom/Assistants/MessageImageDetail.Serialization.cs +++ b/src/Custom/Assistants/MessageImageDetail.Serialization.cs @@ -1,6 +1,7 @@ using System; namespace OpenAI.Assistants; + internal static partial class MessageImageDetailExtensions { public static string ToSerialString(this MessageImageDetail value) => value switch diff --git a/src/Custom/Assistants/MessageImageDetail.cs b/src/Custom/Assistants/MessageImageDetail.cs index 17cc7827..83768cfc 100644 --- a/src/Custom/Assistants/MessageImageDetail.cs +++ b/src/Custom/Assistants/MessageImageDetail.cs @@ -1,9 +1,12 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// The available detail settings to use when processing an image. /// These settings balance token consumption and the resolution of evaluation performed. /// +[Experimental("OPENAI001")] public enum MessageImageDetail { /// Default. Allows the model to automatically select detail. diff --git a/src/Custom/Assistants/MessageModificationOptions.cs b/src/Custom/Assistants/MessageModificationOptions.cs index 3c43bea3..55cffbb3 100644 --- a/src/Custom/Assistants/MessageModificationOptions.cs +++ b/src/Custom/Assistants/MessageModificationOptions.cs @@ -1,9 +1,12 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// Represents additional options available when modifying an existing . /// +[Experimental("OPENAI001")] [CodeGenModel("ModifyMessageRequest")] public partial class MessageModificationOptions { -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/MessageRole.cs b/src/Custom/Assistants/MessageRole.cs index 6aae4c41..28dce071 100644 --- a/src/Custom/Assistants/MessageRole.cs +++ b/src/Custom/Assistants/MessageRole.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("CreateMessageRequestRole")] public enum MessageRole { @@ -14,4 +17,4 @@ public enum MessageRole /// [CodeGenMember("Assistant")] Assistant, -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/RequiredAction.cs b/src/Custom/Assistants/RequiredAction.cs index 3de39cd4..10e3a0d3 100644 --- a/src/Custom/Assistants/RequiredAction.cs +++ b/src/Custom/Assistants/RequiredAction.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// @@ -11,6 +13,7 @@ namespace OpenAI.Assistants; /// /// /// +[Experimental("OPENAI001")] public abstract partial class RequiredAction { /// diff --git a/src/Custom/Assistants/RunCollectionOptions.cs b/src/Custom/Assistants/RunCollectionOptions.cs index f6448232..c72cb6a6 100644 --- a/src/Custom/Assistants/RunCollectionOptions.cs +++ b/src/Custom/Assistants/RunCollectionOptions.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// Represents addition options available when requesting a collection of instances. /// +[Experimental("OPENAI001")] public class RunCollectionOptions { /// diff --git a/src/Custom/Assistants/RunCreationOptions.cs b/src/Custom/Assistants/RunCreationOptions.cs index bcc45ee2..f4d242f2 100644 --- a/src/Custom/Assistants/RunCreationOptions.cs +++ b/src/Custom/Assistants/RunCreationOptions.cs @@ -1,5 +1,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text.Json; @@ -8,6 +9,7 @@ namespace OpenAI.Assistants; /// /// Represents additional options available when creating a new . /// +[Experimental("OPENAI001")] [CodeGenModel("CreateRunRequest")] [CodeGenSuppress("RunCreationOptions", typeof(string))] [CodeGenSerialization(nameof(ToolConstraint), "tool_choice", SerializationValueHook = nameof(SerializeToolConstraint))] @@ -135,4 +137,4 @@ public RunCreationOptions() private void SerializeToolConstraint(Utf8JsonWriter writer, ModelReaderWriterOptions options) => writer.WriteObjectValue(ToolConstraint, options); -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/RunModificationOptions.cs b/src/Custom/Assistants/RunModificationOptions.cs index 561074b9..8b8a125b 100644 --- a/src/Custom/Assistants/RunModificationOptions.cs +++ b/src/Custom/Assistants/RunModificationOptions.cs @@ -1,9 +1,12 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// Represents additional options available when modifying an existing . /// +[Experimental("OPENAI001")] [CodeGenModel("ModifyRunRequest")] public partial class RunModificationOptions { -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/RunStatus.cs b/src/Custom/Assistants/RunStatus.cs index b2b5da90..6075e746 100644 --- a/src/Custom/Assistants/RunStatus.cs +++ b/src/Custom/Assistants/RunStatus.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("RunObjectStatus")] public readonly partial struct RunStatus { @@ -17,4 +20,4 @@ public bool IsTerminal || _value == FailedValue || _value == IncompleteValue || _value == CancelledValue; -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/RunStep.cs b/src/Custom/Assistants/RunStep.cs index 061cb3cd..568e7bc8 100644 --- a/src/Custom/Assistants/RunStep.cs +++ b/src/Custom/Assistants/RunStep.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("RunStepObject")] public partial class RunStep { diff --git a/src/Custom/Assistants/RunStepCollectionOptions.cs b/src/Custom/Assistants/RunStepCollectionOptions.cs index d8509705..a558c468 100644 --- a/src/Custom/Assistants/RunStepCollectionOptions.cs +++ b/src/Custom/Assistants/RunStepCollectionOptions.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// Represents addition options available when requesting a collection of instances. /// +[Experimental("OPENAI001")] public class RunStepCollectionOptions { /// diff --git a/src/Custom/Assistants/RunStepDetails.cs b/src/Custom/Assistants/RunStepDetails.cs index 8ade16fc..e003f0ec 100644 --- a/src/Custom/Assistants/RunStepDetails.cs +++ b/src/Custom/Assistants/RunStepDetails.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants { + [Experimental("OPENAI001")] [CodeGenModel("RunStepObjectStepDetails")] public abstract partial class RunStepDetails { diff --git a/src/Custom/Assistants/RunStepToolCall.cs b/src/Custom/Assistants/RunStepToolCall.cs index 3cb729b1..8fa52a11 100644 --- a/src/Custom/Assistants/RunStepToolCall.cs +++ b/src/Custom/Assistants/RunStepToolCall.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("RunStepDetailsToolCallsObjectToolCallsObject")] public partial class RunStepToolCall { @@ -31,4 +33,4 @@ private InternalRunStepCodeInterpreterToolCallDetails AsCodeInterpreter => this as InternalRunStepCodeInterpreterToolCallDetails; private InternalRunStepFunctionToolCallDetails AsFunction => this as InternalRunStepFunctionToolCallDetails; private InternalRunStepFileSearchToolCallDetails AsFileSearch => this as InternalRunStepFileSearchToolCallDetails; -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/RunStepToolCallKind.Serialization.cs b/src/Custom/Assistants/RunStepToolCallKind.Serialization.cs index 869a9ad0..5bdf3a34 100644 --- a/src/Custom/Assistants/RunStepToolCallKind.Serialization.cs +++ b/src/Custom/Assistants/RunStepToolCallKind.Serialization.cs @@ -1,6 +1,7 @@ using System; namespace OpenAI.Assistants; + internal static partial class RunStepToolCallKindExtensions { public static string ToSerialString(this RunStepToolCallKind value) => value switch diff --git a/src/Custom/Assistants/RunStepToolCallKind.cs b/src/Custom/Assistants/RunStepToolCallKind.cs index f1d89ab2..6e5011fb 100644 --- a/src/Custom/Assistants/RunStepToolCallKind.cs +++ b/src/Custom/Assistants/RunStepToolCallKind.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] public enum RunStepToolCallKind { Unknown, diff --git a/src/Custom/Assistants/RunTruncationStrategy.cs b/src/Custom/Assistants/RunTruncationStrategy.cs index 324723a0..d4328f34 100644 --- a/src/Custom/Assistants/RunTruncationStrategy.cs +++ b/src/Custom/Assistants/RunTruncationStrategy.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants { /// Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. + [Experimental("OPENAI001")] [CodeGenModel("TruncationObject")] [CodeGenSuppress(nameof(RunTruncationStrategy), typeof(InternalTruncationObjectType))] public partial class RunTruncationStrategy diff --git a/src/Custom/Assistants/Streaming/AsyncStreamingUpdateCollection.cs b/src/Custom/Assistants/Streaming/AsyncStreamingUpdateCollection.cs index 1a44545a..1a50d6d4 100644 --- a/src/Custom/Assistants/Streaming/AsyncStreamingUpdateCollection.cs +++ b/src/Custom/Assistants/Streaming/AsyncStreamingUpdateCollection.cs @@ -53,7 +53,7 @@ private sealed class AsyncStreamingUpdateEnumerator : IAsyncEnumerator> getResultAsync, - AsyncStreamingUpdateCollection enumerable, + AsyncStreamingUpdateCollection enumerable, CancellationToken cancellationToken) { Debug.Assert(getResultAsync is not null); diff --git a/src/Custom/Assistants/Streaming/MessageContentUpdate.cs b/src/Custom/Assistants/Streaming/MessageContentUpdate.cs index ad694461..579a93af 100644 --- a/src/Custom/Assistants/Streaming/MessageContentUpdate.cs +++ b/src/Custom/Assistants/Streaming/MessageContentUpdate.cs @@ -1,5 +1,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; @@ -12,6 +13,7 @@ namespace OpenAI.Assistants; /// and each content subcomponent, such as instances, even if this information /// arrived in the same response chunk. /// +[Experimental("OPENAI001")] public partial class MessageContentUpdate : StreamingUpdate { /// diff --git a/src/Custom/Assistants/Streaming/MessageStatusUpdate.cs b/src/Custom/Assistants/Streaming/MessageStatusUpdate.cs index d6b19cf2..b37fd98e 100644 --- a/src/Custom/Assistants/Streaming/MessageStatusUpdate.cs +++ b/src/Custom/Assistants/Streaming/MessageStatusUpdate.cs @@ -1,5 +1,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; @@ -7,6 +8,7 @@ namespace OpenAI.Assistants; /// /// The update type presented when the status of a message changes. /// +[Experimental("OPENAI001")] public class MessageStatusUpdate : StreamingUpdate { internal MessageStatusUpdate(ThreadMessage message, StreamingUpdateReason updateKind) diff --git a/src/Custom/Assistants/Streaming/RequiredActionUpdate.cs b/src/Custom/Assistants/Streaming/RequiredActionUpdate.cs index 2c189923..bfebfe8b 100644 --- a/src/Custom/Assistants/Streaming/RequiredActionUpdate.cs +++ b/src/Custom/Assistants/Streaming/RequiredActionUpdate.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; @@ -11,6 +12,7 @@ namespace OpenAI.Assistants; /// Distinct instances will generated for each required action, meaning that /// parallel function calling will present multiple updates even if the tool calls arrive at the same time. /// +[Experimental("OPENAI001")] public class RequiredActionUpdate : RunUpdate { /// diff --git a/src/Custom/Assistants/Streaming/RunStepDetailsUpdate.cs b/src/Custom/Assistants/Streaming/RunStepDetailsUpdate.cs index 588d3fd7..0549f7fe 100644 --- a/src/Custom/Assistants/Streaming/RunStepDetailsUpdate.cs +++ b/src/Custom/Assistants/Streaming/RunStepDetailsUpdate.cs @@ -1,6 +1,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; @@ -8,6 +9,7 @@ namespace OpenAI.Assistants; /// /// The update type presented when run step details, including tool call progress, have changed. /// +[Experimental("OPENAI001")] public class RunStepDetailsUpdate : StreamingUpdate { internal readonly InternalRunStepDelta _delta; @@ -18,7 +20,7 @@ public class RunStepDetailsUpdate : StreamingUpdate private readonly InternalRunStepDeltaStepDetailsToolCallsFunctionObject _asFunctionCall; /// - public string StepId => _delta?.Id; + public string StepId => _delta?.Id; /// public string CreatedMessageId => _asMessageCreation?.MessageCreation?.MessageId; diff --git a/src/Custom/Assistants/Streaming/RunStepDetailsUpdateCodeInterpreterOutput.cs b/src/Custom/Assistants/Streaming/RunStepDetailsUpdateCodeInterpreterOutput.cs index c24ea9dd..77c041f1 100644 --- a/src/Custom/Assistants/Streaming/RunStepDetailsUpdateCodeInterpreterOutput.cs +++ b/src/Custom/Assistants/Streaming/RunStepDetailsUpdateCodeInterpreterOutput.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("RunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject")] public partial class RunStepUpdateCodeInterpreterOutput { @@ -16,4 +19,4 @@ private InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject AsLogs => this as InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject; private InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject AsImage => this as InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject; -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/Streaming/RunStepUpdate.cs b/src/Custom/Assistants/Streaming/RunStepUpdate.cs index c34345a8..80e20766 100644 --- a/src/Custom/Assistants/Streaming/RunStepUpdate.cs +++ b/src/Custom/Assistants/Streaming/RunStepUpdate.cs @@ -1,5 +1,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; @@ -7,6 +8,7 @@ namespace OpenAI.Assistants; /// /// The update type presented when the status of a run step changes. /// +[Experimental("OPENAI001")] public class RunStepUpdate : StreamingUpdate { internal RunStepUpdate(RunStep runStep, StreamingUpdateReason updateKind) diff --git a/src/Custom/Assistants/Streaming/RunUpdate.cs b/src/Custom/Assistants/Streaming/RunUpdate.cs index 77df3f67..c94bc01b 100644 --- a/src/Custom/Assistants/Streaming/RunUpdate.cs +++ b/src/Custom/Assistants/Streaming/RunUpdate.cs @@ -1,5 +1,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; @@ -7,6 +8,7 @@ namespace OpenAI.Assistants; /// /// The update type presented when the status of a has changed. /// +[Experimental("OPENAI001")] public class RunUpdate : StreamingUpdate { internal RunUpdate(ThreadRun run, StreamingUpdateReason updateKind) : base(run, updateKind) diff --git a/src/Custom/Assistants/Streaming/StreamingUpdate.cs b/src/Custom/Assistants/Streaming/StreamingUpdate.cs index 7940993d..9f6a362b 100644 --- a/src/Custom/Assistants/Streaming/StreamingUpdate.cs +++ b/src/Custom/Assistants/Streaming/StreamingUpdate.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Net.ServerSentEvents; using System.Text.Json; @@ -21,6 +22,7 @@ namespace OpenAI.Assistants; /// For threads: /// /// +[Experimental("OPENAI001")] public abstract partial class StreamingUpdate { /// @@ -79,6 +81,7 @@ or StreamingUpdateReason.MessageCompleted /// Represents a single item of streamed data that encapsulates an underlying response value type. /// /// The response value type of the "delta" payload. +[Experimental("OPENAI001")] public partial class StreamingUpdate : StreamingUpdate where T : class { diff --git a/src/Custom/Assistants/Streaming/StreamingUpdateCollection.cs b/src/Custom/Assistants/Streaming/StreamingUpdateCollection.cs index d0099d99..cad7ca61 100644 --- a/src/Custom/Assistants/Streaming/StreamingUpdateCollection.cs +++ b/src/Custom/Assistants/Streaming/StreamingUpdateCollection.cs @@ -49,7 +49,7 @@ private sealed class StreamingUpdateEnumerator : IEnumerator private StreamingUpdate? _current; private bool _started; - public StreamingUpdateEnumerator(Func getResult, + public StreamingUpdateEnumerator(Func getResult, StreamingUpdateCollection enumerable) { Debug.Assert(getResult is not null); diff --git a/src/Custom/Assistants/Streaming/StreamingUpdateReason.cs b/src/Custom/Assistants/Streaming/StreamingUpdateReason.cs index e2367334..40dfd76d 100644 --- a/src/Custom/Assistants/Streaming/StreamingUpdateReason.cs +++ b/src/Custom/Assistants/Streaming/StreamingUpdateReason.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// @@ -5,6 +7,7 @@ namespace OpenAI.Assistants; /// expected downcast data type of the as well as to the expected data present in the /// payload. /// +[Experimental("OPENAI001")] public enum StreamingUpdateReason { /// diff --git a/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs b/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs index e7abb403..caab5bf2 100644 --- a/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs +++ b/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs @@ -1,7 +1,9 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] public class TextAnnotationUpdate { /// diff --git a/src/Custom/Assistants/Streaming/ThreadUpdate.cs b/src/Custom/Assistants/Streaming/ThreadUpdate.cs index c839281f..636dc303 100644 --- a/src/Custom/Assistants/Streaming/ThreadUpdate.cs +++ b/src/Custom/Assistants/Streaming/ThreadUpdate.cs @@ -1,6 +1,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; @@ -8,6 +9,7 @@ namespace OpenAI.Assistants; /// /// The update type presented when a streamed event indicates a thread was created. /// +[Experimental("OPENAI001")] public class ThreadUpdate : StreamingUpdate { /// diff --git a/src/Custom/Assistants/TextAnnotation.cs b/src/Custom/Assistants/TextAnnotation.cs index 2a4652b5..3a298083 100644 --- a/src/Custom/Assistants/TextAnnotation.cs +++ b/src/Custom/Assistants/TextAnnotation.cs @@ -1,7 +1,9 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] public class TextAnnotation { internal readonly InternalMessageContentTextObjectAnnotation _internalAnnotation; diff --git a/src/Custom/Assistants/ThreadCreationOptions.cs b/src/Custom/Assistants/ThreadCreationOptions.cs index f0ae040f..82d02e47 100644 --- a/src/Custom/Assistants/ThreadCreationOptions.cs +++ b/src/Custom/Assistants/ThreadCreationOptions.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; namespace OpenAI.Assistants; @@ -6,6 +7,7 @@ namespace OpenAI.Assistants; /// /// Represents additional options available when creating a new . /// +[Experimental("OPENAI001")] [CodeGenModel("CreateThreadRequest")] public partial class ThreadCreationOptions { @@ -48,4 +50,4 @@ private set /// /// public IList InitialMessages { get; } = new ChangeTrackingList(); -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/ThreadInitializationMessage.cs b/src/Custom/Assistants/ThreadInitializationMessage.cs index 60c44397..bcae23ac 100644 --- a/src/Custom/Assistants/ThreadInitializationMessage.cs +++ b/src/Custom/Assistants/ThreadInitializationMessage.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] public partial class ThreadInitializationMessage : MessageCreationOptions { /// diff --git a/src/Custom/Assistants/ThreadMessage.cs b/src/Custom/Assistants/ThreadMessage.cs index 1e831a07..40147944 100644 --- a/src/Custom/Assistants/ThreadMessage.cs +++ b/src/Custom/Assistants/ThreadMessage.cs @@ -1,13 +1,15 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("MessageObject")] public partial class ThreadMessage { // CUSTOM: Made internal. /// The object type, which is always `thread.message`. - [CodeGenMember("Object")] + [CodeGenMember("Object")] internal InternalMessageObjectObject Object { get; } = InternalMessageObjectObject.ThreadMessage; diff --git a/src/Custom/Assistants/ThreadModificationOptions.cs b/src/Custom/Assistants/ThreadModificationOptions.cs index 5216abe2..31c81001 100644 --- a/src/Custom/Assistants/ThreadModificationOptions.cs +++ b/src/Custom/Assistants/ThreadModificationOptions.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; /// /// Represents additional options available when modifying an existing . /// +[Experimental("OPENAI001")] [CodeGenModel("ModifyThreadRequest")] public partial class ThreadModificationOptions { @@ -12,4 +15,4 @@ public partial class ThreadModificationOptions /// [CodeGenMember("ToolResources")] public ToolResources ToolResources { get; set; } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/ThreadRun.cs b/src/Custom/Assistants/ThreadRun.cs index b2a0f3f4..1eb62ecc 100644 --- a/src/Custom/Assistants/ThreadRun.cs +++ b/src/Custom/Assistants/ThreadRun.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; namespace OpenAI.Assistants; @@ -8,6 +9,7 @@ namespace OpenAI.Assistants; // - Required actions are abstracted into a forward-compatible, strongly-typed conceptual // hierarchy and formatted into a more intuitive collection for the consumer. +[Experimental("OPENAI001")] [CodeGenModel("RunObject")] public partial class ThreadRun { diff --git a/src/Custom/Assistants/ToolConstraint.Serialization.cs b/src/Custom/Assistants/ToolConstraint.Serialization.cs index 7d2a335e..ccba3e95 100644 --- a/src/Custom/Assistants/ToolConstraint.Serialization.cs +++ b/src/Custom/Assistants/ToolConstraint.Serialization.cs @@ -94,4 +94,4 @@ internal static ToolConstraint DeserializeToolConstraint(JsonElement element, Mo return new ToolConstraint(plainTextValue, objectType, objectFunctionName, rawDataDictionary); } -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/ToolConstraint.cs b/src/Custom/Assistants/ToolConstraint.cs index dc3de61a..b333236f 100644 --- a/src/Custom/Assistants/ToolConstraint.cs +++ b/src/Custom/Assistants/ToolConstraint.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("AssistantsNamedToolChoice")] public partial class ToolConstraint { diff --git a/src/Custom/Assistants/ToolDefinition.Serialization.cs b/src/Custom/Assistants/ToolDefinition.Serialization.cs index 9894fb1e..629e0f53 100644 --- a/src/Custom/Assistants/ToolDefinition.Serialization.cs +++ b/src/Custom/Assistants/ToolDefinition.Serialization.cs @@ -1,7 +1,4 @@ -using System; using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Text.Json; namespace OpenAI.Assistants; @@ -16,4 +13,4 @@ internal static void WriteCore(ToolDefinition instance, Utf8JsonWriter writer, M => instance.WriteCore(writer, options); protected abstract void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options); -} \ No newline at end of file +} diff --git a/src/Custom/Assistants/ToolDefinition.cs b/src/Custom/Assistants/ToolDefinition.cs index 0b876e1c..cca50418 100644 --- a/src/Custom/Assistants/ToolDefinition.cs +++ b/src/Custom/Assistants/ToolDefinition.cs @@ -1,10 +1,12 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("AssistantToolDefinition")] public abstract partial class ToolDefinition -{ +{ public static CodeInterpreterToolDefinition CreateCodeInterpreter() => new CodeInterpreterToolDefinition(); public static FileSearchToolDefinition CreateFileSearch(int? maxResults = null) diff --git a/src/Custom/Assistants/ToolOutput.cs b/src/Custom/Assistants/ToolOutput.cs index ad32112d..fbdc8c91 100644 --- a/src/Custom/Assistants/ToolOutput.cs +++ b/src/Custom/Assistants/ToolOutput.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("SubmitToolOutputsRunRequestToolOutput")] public partial class ToolOutput { @@ -12,5 +15,5 @@ public partial class ToolOutput /// The output from the specified tool. public ToolOutput(string toolCallId, string output) : this(toolCallId, output, null) - {} -} \ No newline at end of file + { } +} diff --git a/src/Custom/Assistants/ToolResources.cs b/src/Custom/Assistants/ToolResources.cs index 1043eead..0cd83326 100644 --- a/src/Custom/Assistants/ToolResources.cs +++ b/src/Custom/Assistants/ToolResources.cs @@ -1,8 +1,10 @@ using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("AssistantObjectToolResources")] [CodeGenSerialization(nameof(FileSearch), "file_search", SerializationValueHook = nameof(SerializeFileSearch))] public partial class ToolResources @@ -13,7 +15,7 @@ public partial class ToolResources public FileSearchToolResources FileSearch { get; set; } public ToolResources() - {} + { } private void SerializeFileSearch(Utf8JsonWriter writer, ModelReaderWriterOptions options) => writer.WriteObjectValue(FileSearch, options); diff --git a/src/Custom/Assistants/VectorStoreCreationHelper.cs b/src/Custom/Assistants/VectorStoreCreationHelper.cs index cba26fb8..6de65e10 100644 --- a/src/Custom/Assistants/VectorStoreCreationHelper.cs +++ b/src/Custom/Assistants/VectorStoreCreationHelper.cs @@ -1,10 +1,12 @@ using OpenAI.Files; using OpenAI.VectorStores; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; namespace OpenAI.Assistants; +[Experimental("OPENAI001")] [CodeGenModel("ToolResourcesFileSearchVectorStore")] public partial class VectorStoreCreationHelper { @@ -19,5 +21,5 @@ public VectorStoreCreationHelper(IEnumerable fileIds, IDictionary files, IDictionary metadata = null) : this(files?.Select(file => file.Id) ?? [], metadata) - {} + { } } diff --git a/src/Custom/Audio/AudioClient.cs b/src/Custom/Audio/AudioClient.cs index 58c0e49a..3782e7fb 100644 --- a/src/Custom/Audio/AudioClient.cs +++ b/src/Custom/Audio/AudioClient.cs @@ -301,7 +301,7 @@ public virtual async Task> TranslateAudioAsync(st } #endregion - + private void CreateSpeechGenerationOptions(string text, GeneratedSpeechVoice voice, ref SpeechGenerationOptions options) { options.Input = text; diff --git a/src/Custom/Audio/AudioTimestampGranularities.cs b/src/Custom/Audio/AudioTimestampGranularities.cs index 1deac3f0..cab2290a 100644 --- a/src/Custom/Audio/AudioTimestampGranularities.cs +++ b/src/Custom/Audio/AudioTimestampGranularities.cs @@ -12,17 +12,17 @@ public enum AudioTimestampGranularities /// The default value that, when equivalent to a request's flags, specifies no specific audio timestamp granularity /// and defers to the default timestamp behavior. /// - Default = 0, + Default = 0, /// /// The value that, when present in the request's flags, specifies that audio information should include word-level /// timestamp information. /// - Word = 1, + Word = 1, /// /// The value that, when present in the request's flags, specifies that audio information should include /// segment-level timestamp information. /// - Segment = 2, + Segment = 2, } \ No newline at end of file diff --git a/src/Custom/Audio/GeneratedSpeechFormat.cs b/src/Custom/Audio/GeneratedSpeechFormat.cs index 4559bca9..4ee71fef 100644 --- a/src/Custom/Audio/GeneratedSpeechFormat.cs +++ b/src/Custom/Audio/GeneratedSpeechFormat.cs @@ -27,6 +27,6 @@ public enum GeneratedSpeechFormat Wav, /// PCM (pulse-code modulation). /// - [CodeGenMember("Pcm")] + [CodeGenMember("Pcm")] Pcm, } \ No newline at end of file diff --git a/src/Custom/Audio/GeneratedSpeechVoice.cs b/src/Custom/Audio/GeneratedSpeechVoice.cs index d0aa0653..cecbea1b 100644 --- a/src/Custom/Audio/GeneratedSpeechVoice.cs +++ b/src/Custom/Audio/GeneratedSpeechVoice.cs @@ -1,34 +1,11 @@ -using System; - namespace OpenAI.Audio; +// CUSTOM: Renamed. /// -/// Represents the available text-to-speech voices. +/// The voice to use in the generated speech. Previews of the available voices can be found in the +/// text-to-speech guide. /// [CodeGenModel("CreateSpeechRequestVoice")] -public enum GeneratedSpeechVoice +public readonly partial struct GeneratedSpeechVoice { - /// Alloy. - [CodeGenMember("Alloy")] - Alloy, - - /// Echo. - [CodeGenMember("Echo")] - Echo, - - /// Fable. - [CodeGenMember("Fable")] - Fable, - - /// Onyx. - [CodeGenMember("Onyx")] - Onyx, - - /// Nova. - [CodeGenMember("Nova")] - Nova, - - /// Shimmer. - [CodeGenMember("Shimmer")] - Shimmer, } \ No newline at end of file diff --git a/src/Custom/Audio/SpeechGenerationOptions.cs b/src/Custom/Audio/SpeechGenerationOptions.cs index 0edbdc02..7c67060f 100644 --- a/src/Custom/Audio/SpeechGenerationOptions.cs +++ b/src/Custom/Audio/SpeechGenerationOptions.cs @@ -28,7 +28,7 @@ public partial class SpeechGenerationOptions /// `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the /// [Text to speech guide](/docs/guides/text-to-speech/voice-options). /// - internal GeneratedSpeechVoice Voice { get; set; } + internal GeneratedSpeechVoice Voice { get; set; } // CUSTOM: Made public now that there are no required properties. /// Initializes a new instance of . diff --git a/src/Custom/Chat/ChatMessage.cs b/src/Custom/Chat/ChatMessage.cs index 7278d517..bf24f5a1 100644 --- a/src/Custom/Chat/ChatMessage.cs +++ b/src/Custom/Chat/ChatMessage.cs @@ -61,7 +61,7 @@ protected internal ChatMessage(ChatMessageRole role, IEnumerable public static SystemChatMessage CreateSystemMessage(string content) => new(content); diff --git a/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs b/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs index be29738a..c47eebae 100644 --- a/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs +++ b/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs @@ -56,7 +56,7 @@ public InternalChatCompletionRequestMessageContentPartImageImageUrl(BinaryData i internal InternalChatCompletionRequestMessageContentPartImageImageUrl(string url, ImageChatMessageContentPartDetail? detail, IDictionary serializedAdditionalRawData) { Match parsedDataUri = ParseDataUriRegex().Match(url); - + if (parsedDataUri.Success) { _imageBytes = BinaryData.FromBytes(Convert.FromBase64String(parsedDataUri.Groups["data"].Value)); diff --git a/src/Custom/Chat/Internal/UnknownChatMessage.Serialization.cs b/src/Custom/Chat/Internal/UnknownChatMessage.Serialization.cs index 02b8d209..aa3efbb4 100644 --- a/src/Custom/Chat/Internal/UnknownChatMessage.Serialization.cs +++ b/src/Custom/Chat/Internal/UnknownChatMessage.Serialization.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat; internal partial class UnknownChatMessage : IJsonModel { void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, WriteCore, writer, options); + => CustomSerializationHelpers.SerializeInstance(this, WriteCore, writer, options); internal static void WriteCore(UnknownChatMessage instance, Utf8JsonWriter writer, ModelReaderWriterOptions options) { diff --git a/src/Custom/Chat/OpenAIChatModelFactory.cs b/src/Custom/Chat/OpenAIChatModelFactory.cs new file mode 100644 index 00000000..4ba81437 --- /dev/null +++ b/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -0,0 +1,187 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace OpenAI.Chat; + +/// Model factory for models. +public static partial class OpenAIChatModelFactory +{ + /// Initializes a new instance of . + /// A new instance for mocking. + public static ChatCompletion ChatCompletion( + string id = null, + ChatFinishReason finishReason = default, + IEnumerable content = null, + string refusal = null, + IEnumerable toolCalls = null, + ChatMessageRole role = default, + ChatFunctionCall functionCall = null, + IEnumerable contentTokenLogProbabilities = null, + IEnumerable refusalTokenLogProbabilities = null, + DateTimeOffset createdAt = default, + string model = null, + string systemFingerprint = null, + ChatTokenUsage usage = null) + { + content ??= new List(); + toolCalls ??= new List(); + contentTokenLogProbabilities ??= new List(); + refusalTokenLogProbabilities ??= new List(); + + InternalChatCompletionResponseMessage message = new InternalChatCompletionResponseMessage( + content.ToList(), + refusal, + toolCalls.ToList(), + role, + functionCall, + serializedAdditionalRawData: null); + + InternalCreateChatCompletionResponseChoiceLogprobs logprobs = new InternalCreateChatCompletionResponseChoiceLogprobs( + contentTokenLogProbabilities.ToList(), + refusalTokenLogProbabilities.ToList(), + serializedAdditionalRawData: null); + + IReadOnlyList choices = [ + new InternalCreateChatCompletionResponseChoice( + finishReason, + index: 0, + message, + logprobs, + serializedAdditionalRawData: null) + ]; + + return new ChatCompletion( + id, + choices, + createdAt, + model, + serviceTier: null, + systemFingerprint, + InternalCreateChatCompletionResponseObject.ChatCompletion, + usage, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A new instance for mocking. + public static ChatTokenLogProbabilityInfo ChatTokenLogProbabilityInfo(string token = null, float logProbability = default, IEnumerable utf8ByteValues = null, IEnumerable topLogProbabilities = null) + { + utf8ByteValues ??= new List(); + topLogProbabilities ??= new List(); + + return new ChatTokenLogProbabilityInfo( + token, + logProbability, + utf8ByteValues.ToList(), + topLogProbabilities.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A new instance for mocking. + public static ChatTokenTopLogProbabilityInfo ChatTokenTopLogProbabilityInfo(string token = null, float logProbability = default, IEnumerable utf8ByteValues = null) + { + utf8ByteValues ??= new List(); + + return new ChatTokenTopLogProbabilityInfo( + token, + logProbability, + utf8ByteValues.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A new instance for mocking. + public static ChatTokenUsage ChatTokenUsage(int outputTokens = default, int inputTokens = default, int totalTokens = default) + { + return new ChatTokenUsage( + outputTokens, + inputTokens, + totalTokens, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A new instance for mocking. + public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( + string id = null, + IEnumerable contentUpdate = null, + StreamingChatFunctionCallUpdate functionCallUpdate = null, + IEnumerable toolCallUpdates = null, + ChatMessageRole? role = null, + string refusalUpdate = null, + IEnumerable contentTokenLogProbabilities = null, + IEnumerable refusalTokenLogProbabilities = null, + ChatFinishReason? finishReason = null, + DateTimeOffset createdAt = default, + string model = null, + string systemFingerprint = null, + ChatTokenUsage usage = null) + { + contentUpdate ??= new List(); + toolCallUpdates ??= new List(); + contentTokenLogProbabilities ??= new List(); + refusalTokenLogProbabilities ??= new List(); + + InternalChatCompletionStreamResponseDelta delta = new InternalChatCompletionStreamResponseDelta( + contentUpdate.ToList(), + functionCallUpdate, + toolCallUpdates.ToList(), + role, + refusalUpdate, + serializedAdditionalRawData: null); + + InternalCreateChatCompletionStreamResponseChoiceLogprobs logprobs = new InternalCreateChatCompletionStreamResponseChoiceLogprobs( + contentTokenLogProbabilities.ToList(), + refusalTokenLogProbabilities.ToList(), + serializedAdditionalRawData: null); + + IReadOnlyList choices = [ + new InternalCreateChatCompletionStreamResponseChoice( + delta, + logprobs, + finishReason, + index: 0, + serializedAdditionalRawData: null) + ]; + + return new StreamingChatCompletionUpdate( + id, + choices, + createdAt, + model, + serviceTier: null, + systemFingerprint, + InternalCreateChatCompletionStreamResponseObject.ChatCompletionChunk, + usage, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A new instance for mocking. + public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionArgumentsUpdate = null, string functionName = null) + { + return new StreamingChatFunctionCallUpdate( + functionArgumentsUpdate, + functionName, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A new instance for mocking. + public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = default, string id = null, ChatToolCallKind kind = default, string functionName = null, string functionArgumentsUpdate = null) + { + InternalChatCompletionMessageToolCallChunkFunction function = new InternalChatCompletionMessageToolCallChunkFunction( + functionName, + functionArgumentsUpdate, + serializedAdditionalRawData: null); + + return new StreamingChatToolCallUpdate( + index, + id, + kind, + function, + serializedAdditionalRawData: null); + } +} diff --git a/src/Custom/Chat/StreamingChatCompletionUpdate.cs b/src/Custom/Chat/StreamingChatCompletionUpdate.cs index 2ce62bd8..f67deba9 100644 --- a/src/Custom/Chat/StreamingChatCompletionUpdate.cs +++ b/src/Custom/Chat/StreamingChatCompletionUpdate.cs @@ -27,7 +27,7 @@ public partial class StreamingChatCompletionUpdate /// A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the /// last chunk if you set `stream_options: {"include_usage": true}`. /// - [CodeGenMember("Choices")] + [CodeGenMember("Choices")] internal IReadOnlyList Choices { get; } // CUSTOM: Renamed. @@ -46,13 +46,13 @@ public partial class StreamingChatCompletionUpdate // CUSTOM: Made internal. [CodeGenMember("ServiceTier")] internal InternalCreateChatCompletionStreamResponseServiceTier? ServiceTier { get; } - + // CUSTOM: Flattened choice property. /// /// Gets the associated with this update. /// public ChatFinishReason? FinishReason => (Choices.Count > 0) - ? Choices[0].FinishReason + ? Choices[0].FinishReason : null; // CUSTOM: Flattened choice logprobs property. @@ -109,7 +109,7 @@ public partial class StreamingChatCompletionUpdate public StreamingChatFunctionCallUpdate FunctionCallUpdate => (Choices.Count > 0) ? Choices[0].Delta.FunctionCall : null; - + // CUSTOM: Flattened choice delta property. public string RefusalUpdate => (Choices.Count > 0) ? Choices[0].Delta?.Refusal diff --git a/src/Custom/Files/FileClient.Protocol.cs b/src/Custom/Files/FileClient.Protocol.cs index f9784bfe..bc44ac05 100644 --- a/src/Custom/Files/FileClient.Protocol.cs +++ b/src/Custom/Files/FileClient.Protocol.cs @@ -8,7 +8,7 @@ namespace OpenAI.Files; [CodeGenSuppress("CreateFileAsync", typeof(BinaryContent), typeof(string), typeof(RequestOptions))] [CodeGenSuppress("CreateFile", typeof(BinaryContent), typeof(string), typeof(RequestOptions))] -[CodeGenSuppress("GetFilesAsync", typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("GetFilesAsync", typeof(string), typeof(RequestOptions))] [CodeGenSuppress("GetFiles", typeof(string), typeof(RequestOptions))] [CodeGenSuppress("RetrieveFileAsync", typeof(string), typeof(RequestOptions))] [CodeGenSuppress("RetrieveFile", typeof(string), typeof(RequestOptions))] diff --git a/src/Custom/Images/ImageClient.cs b/src/Custom/Images/ImageClient.cs index b7efdd38..b9af9f9b 100644 --- a/src/Custom/Images/ImageClient.cs +++ b/src/Custom/Images/ImageClient.cs @@ -256,7 +256,7 @@ public virtual ClientResult GenerateImageEdit(string imageFilePa Argument.AssertNotNullOrEmpty(prompt, nameof(prompt)); using FileStream imageStream = File.OpenRead(imageFilePath); - return GenerateImageEdit(imageStream, imageFilePath, prompt,options); + return GenerateImageEdit(imageStream, imageFilePath, prompt, options); } /// Generates an edited or extended image based on an original image, a prompt, and a mask. diff --git a/src/Custom/Images/ImageEditOptions.cs b/src/Custom/Images/ImageEditOptions.cs index b8681a3d..47f83609 100644 --- a/src/Custom/Images/ImageEditOptions.cs +++ b/src/Custom/Images/ImageEditOptions.cs @@ -34,7 +34,7 @@ public partial class ImageEditOptions /// /// /// - internal BinaryData Image { get; set; } + internal BinaryData Image { get; set; } // CUSTOM: // - Made internal. This value comes from a parameter on the client method. diff --git a/src/Custom/Internal/CancellationTokenExtensions.cs b/src/Custom/Internal/CancellationTokenExtensions.cs index d0a5bc81..ba7a74e1 100644 --- a/src/Custom/Internal/CancellationTokenExtensions.cs +++ b/src/Custom/Internal/CancellationTokenExtensions.cs @@ -13,7 +13,8 @@ public static RequestOptions ToRequestOptions(this CancellationToken cancellatio return StreamRequestOptions; } - return new RequestOptions() { + return new RequestOptions() + { CancellationToken = cancellationToken, BufferResponse = !streaming, }; diff --git a/src/Custom/LegacyCompletions/Internal/GeneratorStubs.cs b/src/Custom/LegacyCompletions/Internal/GeneratorStubs.cs index b184f9da..43682d98 100644 --- a/src/Custom/LegacyCompletions/Internal/GeneratorStubs.cs +++ b/src/Custom/LegacyCompletions/Internal/GeneratorStubs.cs @@ -18,7 +18,7 @@ internal partial class InternalCreateCompletionResponseChoice { } internal readonly partial struct InternalCreateCompletionResponseChoiceFinishReason { } [CodeGenModel("CreateCompletionResponseChoiceLogprobs")] -internal partial class InternalCreateCompletionResponseChoiceLogprobs { } +internal partial class InternalCreateCompletionResponseChoiceLogprobs { } [CodeGenModel("CreateCompletionResponseObject")] internal readonly partial struct InternalCreateCompletionResponseObject { } \ No newline at end of file diff --git a/src/Custom/VectorStores/FileChunkingStrategy.cs b/src/Custom/VectorStores/FileChunkingStrategy.cs index 0f642d66..3da40dad 100644 --- a/src/Custom/VectorStores/FileChunkingStrategy.cs +++ b/src/Custom/VectorStores/FileChunkingStrategy.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("FileChunkingStrategyResponseParam")] public abstract partial class FileChunkingStrategy -{ +{ /// /// Gets a value representing the default, automatic selection for a file chunking strategy. /// @@ -32,5 +35,5 @@ public static FileChunkingStrategy CreateStaticStrategy( } private static InternalAutoChunkingStrategy _autoValue; - private static InternalUnknownChunkingStrategy _unknownValue; + private static InternalUnknownChunkingStrategy _unknownValue; } diff --git a/src/Custom/VectorStores/Internal/GeneratorStubs.cs b/src/Custom/VectorStores/Internal/GeneratorStubs.cs index 3fa00a75..4ff1a5c7 100644 --- a/src/Custom/VectorStores/Internal/GeneratorStubs.cs +++ b/src/Custom/VectorStores/Internal/GeneratorStubs.cs @@ -6,7 +6,7 @@ namespace OpenAI.VectorStores; internal partial class InternalCreateVectorStoreFileBatchRequest { } [CodeGenModel("CreateVectorStoreFileRequest")] -internal partial class InternalCreateVectorStoreFileRequest {} +internal partial class InternalCreateVectorStoreFileRequest { } [CodeGenModel("DeleteVectorStoreFileResponse")] internal partial class InternalDeleteVectorStoreFileResponse { } diff --git a/src/Custom/VectorStores/Internal/InternalCreateVectorStoreFileRequest.cs b/src/Custom/VectorStores/Internal/InternalCreateVectorStoreFileRequest.cs index 338a848e..7ddc7b78 100644 --- a/src/Custom/VectorStores/Internal/InternalCreateVectorStoreFileRequest.cs +++ b/src/Custom/VectorStores/Internal/InternalCreateVectorStoreFileRequest.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; - namespace OpenAI.VectorStores; internal partial class InternalCreateVectorStoreFileRequest diff --git a/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageToken.cs b/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageToken.cs index 50f80790..3329be77 100644 --- a/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageToken.cs +++ b/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageToken.cs @@ -10,7 +10,7 @@ namespace OpenAI.VectorStores; internal class VectorStoreFileBatchesPageToken : ContinuationToken { - protected VectorStoreFileBatchesPageToken(string vectorStoreId,string batchId, int? limit, string? order, string? after, string? before, string? filter) + protected VectorStoreFileBatchesPageToken(string vectorStoreId, string batchId, int? limit, string? order, string? after, string? before, string? filter) { VectorStoreId = vectorStoreId; BatchId = batchId; diff --git a/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs b/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs index 9a5e9bec..6034ba10 100644 --- a/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs +++ b/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs @@ -28,7 +28,7 @@ internal partial class VectorStoreFilesPageEnumerator : PageEnumerator public StaticFileChunkingStrategy(int maxTokensPerChunk, int overlappingTokenCount) : this(new InternalStaticChunkingStrategyDetails(maxTokensPerChunk, overlappingTokenCount)) - {} + { } } diff --git a/src/Custom/VectorStores/VectorStore.cs b/src/Custom/VectorStores/VectorStore.cs index 04b8c79b..d63612d1 100644 --- a/src/Custom/VectorStores/VectorStore.cs +++ b/src/Custom/VectorStores/VectorStore.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; /// /// A representation of a file storage and indexing container used by the file_search tool for assistants. /// +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreObject")] public partial class VectorStore { diff --git a/src/Custom/VectorStores/VectorStoreBatchFileJob.cs b/src/Custom/VectorStores/VectorStoreBatchFileJob.cs index 507745bb..329a03b5 100644 --- a/src/Custom/VectorStores/VectorStoreBatchFileJob.cs +++ b/src/Custom/VectorStores/VectorStoreBatchFileJob.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; /// /// Represents information about a bulk ingestion job of files into a vector store. /// +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreFileBatchObject")] public partial class VectorStoreBatchFileJob { diff --git a/src/Custom/VectorStores/VectorStoreBatchFileJobStatus.cs b/src/Custom/VectorStores/VectorStoreBatchFileJobStatus.cs index 84eb5e3f..d23f262a 100644 --- a/src/Custom/VectorStores/VectorStoreBatchFileJobStatus.cs +++ b/src/Custom/VectorStores/VectorStoreBatchFileJobStatus.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreFileBatchObjectStatus")] public readonly partial struct VectorStoreBatchFileJobStatus { diff --git a/src/Custom/VectorStores/VectorStoreCollectionOptions.cs b/src/Custom/VectorStores/VectorStoreCollectionOptions.cs index 82dfac7d..5d525bf0 100644 --- a/src/Custom/VectorStores/VectorStoreCollectionOptions.cs +++ b/src/Custom/VectorStores/VectorStoreCollectionOptions.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; /// /// Represents addition options available when requesting a collection of instances. /// +[Experimental("OPENAI001")] public class VectorStoreCollectionOptions { /// diff --git a/src/Custom/VectorStores/VectorStoreCreationOptions.cs b/src/Custom/VectorStores/VectorStoreCreationOptions.cs index 97514c9f..066fb619 100644 --- a/src/Custom/VectorStores/VectorStoreCreationOptions.cs +++ b/src/Custom/VectorStores/VectorStoreCreationOptions.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("CreateVectorStoreRequest")] public partial class VectorStoreCreationOptions { diff --git a/src/Custom/VectorStores/VectorStoreExpirationAnchor.cs b/src/Custom/VectorStores/VectorStoreExpirationAnchor.cs index 482276c4..98882c6f 100644 --- a/src/Custom/VectorStores/VectorStoreExpirationAnchor.cs +++ b/src/Custom/VectorStores/VectorStoreExpirationAnchor.cs @@ -1,10 +1,12 @@ using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.VectorStores; /// /// Represents the available timestamps to which the duration in a will apply. /// +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreExpirationAfterAnchor")] public enum VectorStoreExpirationAnchor { diff --git a/src/Custom/VectorStores/VectorStoreExpirationPolicy.cs b/src/Custom/VectorStores/VectorStoreExpirationPolicy.cs index 4357959e..8b437809 100644 --- a/src/Custom/VectorStores/VectorStoreExpirationPolicy.cs +++ b/src/Custom/VectorStores/VectorStoreExpirationPolicy.cs @@ -7,6 +7,7 @@ namespace OpenAI.VectorStores; /// /// Represents the the configuration that controls when a vector store will be automatically deleted. /// +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreExpirationAfter")] [CodeGenSuppress(nameof(VectorStoreExpirationPolicy))] [CodeGenSuppress(nameof(VectorStoreExpirationPolicy), typeof(int))] @@ -22,14 +23,14 @@ public partial class VectorStoreExpirationPolicy /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. public required VectorStoreExpirationAnchor Anchor - { + { get => _anchor; set => _anchor = value; } /// The number of days after the anchor time that the vector store will expire. public required int Days - { + { get => _days; set => _days = value; } diff --git a/src/Custom/VectorStores/VectorStoreFileAssociation.cs b/src/Custom/VectorStores/VectorStoreFileAssociation.cs index 9c680ab4..4ab1114e 100644 --- a/src/Custom/VectorStores/VectorStoreFileAssociation.cs +++ b/src/Custom/VectorStores/VectorStoreFileAssociation.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; /// /// A representation of a file association between an uploaded file and a vector store. /// +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreFileObject")] public partial class VectorStoreFileAssociation { diff --git a/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOptions.cs b/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOptions.cs index 9880b0af..69dbd7fe 100644 --- a/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOptions.cs +++ b/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOptions.cs @@ -1,8 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; /// /// Represents addition options available when requesting a collection of instances. /// +[Experimental("OPENAI001")] public class VectorStoreFileAssociationCollectionOptions { /// diff --git a/src/Custom/VectorStores/VectorStoreFileAssociationError.cs b/src/Custom/VectorStores/VectorStoreFileAssociationError.cs index a682fe28..c46e71fc 100644 --- a/src/Custom/VectorStores/VectorStoreFileAssociationError.cs +++ b/src/Custom/VectorStores/VectorStoreFileAssociationError.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreFileObjectLastError")] public partial class VectorStoreFileAssociationError { diff --git a/src/Custom/VectorStores/VectorStoreFileAssociationErrorCode.cs b/src/Custom/VectorStores/VectorStoreFileAssociationErrorCode.cs index 8246d94f..82df53e3 100644 --- a/src/Custom/VectorStores/VectorStoreFileAssociationErrorCode.cs +++ b/src/Custom/VectorStores/VectorStoreFileAssociationErrorCode.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreFileObjectLastErrorCode")] public readonly partial struct VectorStoreFileAssociationErrorCode { diff --git a/src/Custom/VectorStores/VectorStoreFileAssociationStatus.cs b/src/Custom/VectorStores/VectorStoreFileAssociationStatus.cs index a1bd0c55..2056ca2e 100644 --- a/src/Custom/VectorStores/VectorStoreFileAssociationStatus.cs +++ b/src/Custom/VectorStores/VectorStoreFileAssociationStatus.cs @@ -1,10 +1,12 @@ using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.VectorStores; /// /// Represents the possible states for a vector store file association. /// +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreFileObjectStatus")] public enum VectorStoreFileAssociationStatus { diff --git a/src/Custom/VectorStores/VectorStoreFileCounts.cs b/src/Custom/VectorStores/VectorStoreFileCounts.cs index 049de235..058d618b 100644 --- a/src/Custom/VectorStores/VectorStoreFileCounts.cs +++ b/src/Custom/VectorStores/VectorStoreFileCounts.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreObjectFileCounts")] public partial class VectorStoreFileCounts { diff --git a/src/Custom/VectorStores/VectorStoreFileStatusFilter.cs b/src/Custom/VectorStores/VectorStoreFileStatusFilter.cs index 24f9fb96..93e9b9b7 100644 --- a/src/Custom/VectorStores/VectorStoreFileStatusFilter.cs +++ b/src/Custom/VectorStores/VectorStoreFileStatusFilter.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("ListVectorStoreFilesFilter")] public readonly partial struct VectorStoreFileStatusFilter { diff --git a/src/Custom/VectorStores/VectorStoreModificationOptions.cs b/src/Custom/VectorStores/VectorStoreModificationOptions.cs index 964a1a86..193ab8fa 100644 --- a/src/Custom/VectorStores/VectorStoreModificationOptions.cs +++ b/src/Custom/VectorStores/VectorStoreModificationOptions.cs @@ -1,7 +1,8 @@ -using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.VectorStores; +[Experimental("OPENAI001")] [CodeGenModel("UpdateVectorStoreRequest")] public partial class VectorStoreModificationOptions { diff --git a/src/Custom/VectorStores/VectorStoreStatus.cs b/src/Custom/VectorStores/VectorStoreStatus.cs index 0f482a94..5cd98b5d 100644 --- a/src/Custom/VectorStores/VectorStoreStatus.cs +++ b/src/Custom/VectorStores/VectorStoreStatus.cs @@ -1,10 +1,12 @@ using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; namespace OpenAI.VectorStores; /// /// Represents the possible states for a vector store. /// +[Experimental("OPENAI001")] [CodeGenModel("VectorStoreObjectStatus")] public enum VectorStoreStatus { diff --git a/src/Generated/Models/GeneratedSpeechVoice.Serialization.cs b/src/Generated/Models/GeneratedSpeechVoice.Serialization.cs deleted file mode 100644 index b28f7c0d..00000000 --- a/src/Generated/Models/GeneratedSpeechVoice.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; - -namespace OpenAI.Audio -{ - internal static partial class GeneratedSpeechVoiceExtensions - { - public static string ToSerialString(this GeneratedSpeechVoice value) => value switch - { - GeneratedSpeechVoice.Alloy => "alloy", - GeneratedSpeechVoice.Echo => "echo", - GeneratedSpeechVoice.Fable => "fable", - GeneratedSpeechVoice.Onyx => "onyx", - GeneratedSpeechVoice.Nova => "nova", - GeneratedSpeechVoice.Shimmer => "shimmer", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedSpeechVoice value.") - }; - - public static GeneratedSpeechVoice ToGeneratedSpeechVoice(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "alloy")) return GeneratedSpeechVoice.Alloy; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "echo")) return GeneratedSpeechVoice.Echo; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "fable")) return GeneratedSpeechVoice.Fable; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "onyx")) return GeneratedSpeechVoice.Onyx; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "nova")) return GeneratedSpeechVoice.Nova; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "shimmer")) return GeneratedSpeechVoice.Shimmer; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedSpeechVoice value."); - } - } -} diff --git a/src/Generated/Models/GeneratedSpeechVoice.cs b/src/Generated/Models/GeneratedSpeechVoice.cs new file mode 100644 index 00000000..14fad742 --- /dev/null +++ b/src/Generated/Models/GeneratedSpeechVoice.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace OpenAI.Audio +{ + public readonly partial struct GeneratedSpeechVoice : IEquatable + { + private readonly string _value; + + public GeneratedSpeechVoice(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AlloyValue = "alloy"; + private const string EchoValue = "echo"; + private const string FableValue = "fable"; + private const string OnyxValue = "onyx"; + private const string NovaValue = "nova"; + private const string ShimmerValue = "shimmer"; + + public static GeneratedSpeechVoice Alloy { get; } = new GeneratedSpeechVoice(AlloyValue); + public static GeneratedSpeechVoice Echo { get; } = new GeneratedSpeechVoice(EchoValue); + public static GeneratedSpeechVoice Fable { get; } = new GeneratedSpeechVoice(FableValue); + public static GeneratedSpeechVoice Onyx { get; } = new GeneratedSpeechVoice(OnyxValue); + public static GeneratedSpeechVoice Nova { get; } = new GeneratedSpeechVoice(NovaValue); + public static GeneratedSpeechVoice Shimmer { get; } = new GeneratedSpeechVoice(ShimmerValue); + public static bool operator ==(GeneratedSpeechVoice left, GeneratedSpeechVoice right) => left.Equals(right); + public static bool operator !=(GeneratedSpeechVoice left, GeneratedSpeechVoice right) => !left.Equals(right); + public static implicit operator GeneratedSpeechVoice(string value) => new GeneratedSpeechVoice(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GeneratedSpeechVoice other && Equals(other); + public bool Equals(GeneratedSpeechVoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; + } +} diff --git a/src/Generated/Models/SpeechGenerationOptions.Serialization.cs b/src/Generated/Models/SpeechGenerationOptions.Serialization.cs index 1bd30130..9b2c260b 100644 --- a/src/Generated/Models/SpeechGenerationOptions.Serialization.cs +++ b/src/Generated/Models/SpeechGenerationOptions.Serialization.cs @@ -34,7 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade if (SerializedAdditionalRawData?.ContainsKey("voice") != true) { writer.WritePropertyName("voice"u8); - writer.WriteStringValue(Voice.ToSerialString()); + writer.WriteStringValue(Voice.ToString()); } if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) { @@ -109,7 +109,7 @@ internal static SpeechGenerationOptions DeserializeSpeechGenerationOptions(JsonE } if (property.NameEquals("voice"u8)) { - voice = property.Value.GetString().ToGeneratedSpeechVoice(); + voice = new GeneratedSpeechVoice(property.Value.GetString()); continue; } if (property.NameEquals("response_format"u8)) diff --git a/src/OpenAI.csproj b/src/OpenAI.csproj index 2a1dd21b..3abe4d9b 100644 --- a/src/OpenAI.csproj +++ b/src/OpenAI.csproj @@ -36,6 +36,9 @@ $(NoWarn),0169 + + $(NoWarn),OPENAI001; + Debug;Release;Unsigned diff --git a/src/Utility/CustomSerializationHelpers.cs b/src/Utility/CustomSerializationHelpers.cs index 9badd726..bcf1ae80 100644 --- a/src/Utility/CustomSerializationHelpers.cs +++ b/src/Utility/CustomSerializationHelpers.cs @@ -9,7 +9,7 @@ namespace OpenAI; internal static partial class CustomSerializationHelpers { - internal static TOutput DeserializeNewInstance( + internal static TOutput DeserializeNewInstance( UInstanceInput existingInstance, Func deserializationFunc, ref Utf8JsonReader reader, @@ -27,7 +27,7 @@ internal static TOutput DeserializeNewInstance( return deserializationFunc.Invoke(document.RootElement, options); } - internal static TOutput DeserializeNewInstance( + internal static TOutput DeserializeNewInstance( UInstanceInput existingInstance, Func deserializationFunc, BinaryData data, @@ -49,9 +49,9 @@ internal static TOutput DeserializeNewInstance( } } - internal static void SerializeInstance( + internal static void SerializeInstance( UInstanceInput instance, - Action serializationFunc, + Action serializationFunc, Utf8JsonWriter writer, ModelReaderWriterOptions options) where UInstanceInput : IJsonModel @@ -87,7 +87,7 @@ internal static void AssertSupportedJsonWriteFormat(T instance, ModelReaderWr where T : IJsonModel => AssertSupportedJsonWriteFormat(instance, options); - internal static void AssertSupportedJsonWriteFormat(UInstanceInput instance, ModelReaderWriterOptions options) + internal static void AssertSupportedJsonWriteFormat(UInstanceInput instance, ModelReaderWriterOptions options) where UInstanceInput : IJsonModel { var format = options.Format == "W" ? ((IJsonModel)instance).GetFormatFromOptions(options) : options.Format; @@ -101,7 +101,7 @@ internal static void AssertSupportedPersistableWriteFormat(T instance, ModelR where T : IPersistableModel => AssertSupportedPersistableWriteFormat(instance, options); - internal static void AssertSupportedPersistableWriteFormat(UInstanceInput instance, ModelReaderWriterOptions options) + internal static void AssertSupportedPersistableWriteFormat(UInstanceInput instance, ModelReaderWriterOptions options) where UInstanceInput : IPersistableModel { var format = options.Format == "W" ? ((IPersistableModel)instance).GetFormatFromOptions(options) : options.Format; diff --git a/tests/Audio/OpenAIAudioModelFactoryTests.cs b/tests/Audio/OpenAIAudioModelFactoryTests.cs index 717509f3..39cdcbbc 100644 --- a/tests/Audio/OpenAIAudioModelFactoryTests.cs +++ b/tests/Audio/OpenAIAudioModelFactoryTests.cs @@ -265,7 +265,7 @@ public void TranscribedSegmentWithTextWorks() [Test] public void TranscribedSegmentWithTokenIdsWorks() { - IEnumerable tokenIds = [ 9000000000, 9000000010 ]; + IEnumerable tokenIds = [9000000000, 9000000010]; TranscribedSegment transcribedSegment = OpenAIAudioModelFactory.TranscribedSegment(tokenIds: tokenIds); Assert.That(transcribedSegment.Id, Is.EqualTo(default(int))); diff --git a/tests/Batch/BatchTests.cs b/tests/Batch/BatchTests.cs index 8e51201a..0d3efef7 100644 --- a/tests/Batch/BatchTests.cs +++ b/tests/Batch/BatchTests.cs @@ -94,7 +94,7 @@ public async Task ListBatchesProtocolAsync() public async Task CreateGetAndCancelBatchProtocol() { using MemoryStream testFileStream = new(); - using StreamWriter streamWriter = new (testFileStream); + using StreamWriter streamWriter = new(testFileStream); string input = @"{""custom_id"": ""request-1"", ""method"": ""POST"", ""url"": ""/v1/chat/completions"", ""body"": {""model"": ""gpt-4o-mini"", ""messages"": [{""role"": ""system"", ""content"": ""You are a helpful assistant.""}, {""role"": ""user"", ""content"": ""What is 2+2?""}]}}"; streamWriter.WriteLine(input); streamWriter.Flush(); diff --git a/tests/Chat/ChatTests.cs b/tests/Chat/ChatTests.cs index 9712c5bf..62d84287 100644 --- a/tests/Chat/ChatTests.cs +++ b/tests/Chat/ChatTests.cs @@ -214,7 +214,7 @@ public async Task TokenLogProbabilities(bool includeLogProbabilities) ChatClient client = GetTestClient(TestScenario.Chat); IList messages = [new UserChatMessage("What are the best pizza toppings? Give me a breakdown on the reasons.")]; ChatCompletionOptions options; - + if (includeLogProbabilities) { options = new() diff --git a/tests/Chat/OpenAIChatModelFactoryTests.cs b/tests/Chat/OpenAIChatModelFactoryTests.cs new file mode 100644 index 00000000..2255c8d5 --- /dev/null +++ b/tests/Chat/OpenAIChatModelFactoryTests.cs @@ -0,0 +1,876 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using OpenAI.Chat; + +namespace OpenAI.Tests.Chat; + +[Parallelizable(ParallelScope.All)] +[Category("Smoke")] +public partial class OpenAIChatModelFactoryTests +{ + [Test] + public void ChatCompletionWithNoPropertiesWorks() + { + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithIdWorks() + { + string id = "chat_completion_id"; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(id: id); + + Assert.That(chatCompletion.Id, Is.EqualTo(id)); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithFinishReasonWorks() + { + ChatFinishReason finishReason = ChatFinishReason.ToolCalls; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(finishReason: finishReason); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(finishReason)); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithContentWorks() + { + IEnumerable content = [ + ChatMessageContentPart.CreateTextMessageContentPart("first part"), + ChatMessageContentPart.CreateTextMessageContentPart("second part") + ]; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(content: content); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content.SequenceEqual(content), Is.True); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithRefusalWorks() + { + string refusal = "This is a refusal."; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(refusal: refusal); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.EqualTo(refusal)); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithToolCallsWorks() + { + IEnumerable toolCalls = [ + ChatToolCall.CreateFunctionToolCall("id1", "get_recipe", string.Empty), + ChatToolCall.CreateFunctionToolCall("id2", "get_location", string.Empty) + ]; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(toolCalls: toolCalls); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls.SequenceEqual(toolCalls), Is.True); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithRoleWorks() + { + ChatMessageRole role = ChatMessageRole.Tool; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(role: role); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(role)); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithFunctionCallWorks() + { + ChatFunctionCall functionCall = new ChatFunctionCall("get_recipe", string.Empty); + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(functionCall: functionCall); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.EqualTo(functionCall)); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithContentTokenLogProbabilitiesWorks() + { + IEnumerable contentTokenLogProbabilities = [ + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 1f), + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 2f) + ]; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(contentTokenLogProbabilities: contentTokenLogProbabilities); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities.SequenceEqual(contentTokenLogProbabilities), Is.True); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithRefusalTokenLogProbabilitiesWorks() + { + IEnumerable refusalTokenLogProbabilities = [ + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 1f), + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 2f) + ]; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(refusalTokenLogProbabilities: refusalTokenLogProbabilities); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities.SequenceEqual(refusalTokenLogProbabilities), Is.True); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithCreatedAtWorks() + { + DateTimeOffset createdAt = DateTimeOffset.UtcNow; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(createdAt: createdAt); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(createdAt)); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithModelWorks() + { + string model = "topmodel"; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(model: model); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.EqualTo(model)); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithSystemFingerprintWorks() + { + string systemFingerprint = "footprint"; + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(systemFingerprint: systemFingerprint); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.EqualTo(systemFingerprint)); + Assert.That(chatCompletion.Usage, Is.Null); + } + + [Test] + public void ChatCompletionWithUsageWorks() + { + ChatTokenUsage usage = OpenAIChatModelFactory.ChatTokenUsage(outputTokens: 20); + ChatCompletion chatCompletion = OpenAIChatModelFactory.ChatCompletion(usage: usage); + + Assert.That(chatCompletion.Id, Is.Null); + Assert.That(chatCompletion.FinishReason, Is.EqualTo(default(ChatFinishReason))); + Assert.That(chatCompletion.Content, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Refusal, Is.Null); + Assert.That(chatCompletion.ToolCalls, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.Role, Is.EqualTo(default(ChatMessageRole))); + Assert.That(chatCompletion.FunctionCall, Is.Null); + Assert.That(chatCompletion.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(chatCompletion.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(chatCompletion.Model, Is.Null); + Assert.That(chatCompletion.SystemFingerprint, Is.Null); + Assert.That(chatCompletion.Usage, Is.EqualTo(usage)); + } + + [Test] + public void ChatTokenLogProbabilityInfoWithNoPropertiesWorks() + { + ChatTokenLogProbabilityInfo chatTokenLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(); + + Assert.That(chatTokenLogProbabilityInfo.Token, Is.Null); + Assert.That(chatTokenLogProbabilityInfo.LogProbability, Is.EqualTo(0f)); + Assert.That(chatTokenLogProbabilityInfo.Utf8ByteValues, Is.Not.Null.And.Empty); + Assert.That(chatTokenLogProbabilityInfo.TopLogProbabilities, Is.Not.Null.And.Empty); + } + + [Test] + public void ChatTokenLogProbabilityInfoWithTokenWorks() + { + string token = "a_token_of_appreciation"; + ChatTokenLogProbabilityInfo chatTokenLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(token: token); + + Assert.That(chatTokenLogProbabilityInfo.Token, Is.EqualTo(token)); + Assert.That(chatTokenLogProbabilityInfo.LogProbability, Is.EqualTo(0f)); + Assert.That(chatTokenLogProbabilityInfo.Utf8ByteValues, Is.Not.Null.And.Empty); + Assert.That(chatTokenLogProbabilityInfo.TopLogProbabilities, Is.Not.Null.And.Empty); + } + + [Test] + public void ChatTokenLogProbabilityInfoWithLogProbabilityWorks() + { + float logProbability = 3.14f; + ChatTokenLogProbabilityInfo chatTokenLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: logProbability); + + Assert.That(chatTokenLogProbabilityInfo.Token, Is.Null); + Assert.That(chatTokenLogProbabilityInfo.LogProbability, Is.EqualTo(logProbability)); + Assert.That(chatTokenLogProbabilityInfo.Utf8ByteValues, Is.Not.Null.And.Empty); + Assert.That(chatTokenLogProbabilityInfo.TopLogProbabilities, Is.Not.Null.And.Empty); + } + + [Test] + public void ChatTokenLogProbabilityInfoWithUtf8ByteValuesWorks() + { + IEnumerable utf8ByteValues = [104, 101, 108, 108, 111]; + ChatTokenLogProbabilityInfo chatTokenLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(utf8ByteValues: utf8ByteValues); + + Assert.That(chatTokenLogProbabilityInfo.Token, Is.Null); + Assert.That(chatTokenLogProbabilityInfo.LogProbability, Is.EqualTo(0f)); + Assert.That(chatTokenLogProbabilityInfo.Utf8ByteValues.SequenceEqual(utf8ByteValues), Is.True); + Assert.That(chatTokenLogProbabilityInfo.TopLogProbabilities, Is.Not.Null.And.Empty); + } + + [Test] + public void ChatTokenLogProbabilityInfoWithTopLogProbabilitiesWorks() + { + IEnumerable topLogProbabilities = [ + OpenAIChatModelFactory.ChatTokenTopLogProbabilityInfo(token: "firstToken"), + OpenAIChatModelFactory.ChatTokenTopLogProbabilityInfo(token: "secondToken") + ]; + ChatTokenLogProbabilityInfo chatTokenLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(topLogProbabilities: topLogProbabilities); + + Assert.That(chatTokenLogProbabilityInfo.Token, Is.Null); + Assert.That(chatTokenLogProbabilityInfo.LogProbability, Is.EqualTo(0f)); + Assert.That(chatTokenLogProbabilityInfo.Utf8ByteValues, Is.Not.Null.And.Empty); + Assert.That(chatTokenLogProbabilityInfo.TopLogProbabilities.SequenceEqual(topLogProbabilities), Is.True); + } + + [Test] + public void ChatTokenTopLogProbabilityInfoWithNoPropertiesWorks() + { + ChatTokenTopLogProbabilityInfo chatTokenTopLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenTopLogProbabilityInfo(); + + Assert.That(chatTokenTopLogProbabilityInfo.Token, Is.Null); + Assert.That(chatTokenTopLogProbabilityInfo.LogProbability, Is.EqualTo(0f)); + Assert.That(chatTokenTopLogProbabilityInfo.Utf8ByteValues, Is.Not.Null.And.Empty); + } + + [Test] + public void ChatTokenTopLogProbabilityInfoWithTokenWorks() + { + string token = "a_token_of_appreciation"; + ChatTokenTopLogProbabilityInfo chatTokenTopLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenTopLogProbabilityInfo(token: token); + + Assert.That(chatTokenTopLogProbabilityInfo.Token, Is.EqualTo(token)); + Assert.That(chatTokenTopLogProbabilityInfo.LogProbability, Is.EqualTo(0f)); + Assert.That(chatTokenTopLogProbabilityInfo.Utf8ByteValues, Is.Not.Null.And.Empty); + } + + [Test] + public void ChatTokenTopLogProbabilityInfoWithLogProbabilityWorks() + { + float logProbability = 3.14f; + ChatTokenTopLogProbabilityInfo chatTokenTopLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenTopLogProbabilityInfo(logProbability: logProbability); + + Assert.That(chatTokenTopLogProbabilityInfo.Token, Is.Null); + Assert.That(chatTokenTopLogProbabilityInfo.LogProbability, Is.EqualTo(logProbability)); + Assert.That(chatTokenTopLogProbabilityInfo.Utf8ByteValues, Is.Not.Null.And.Empty); + } + + [Test] + public void ChatTokenTopLogProbabilityInfoWithUtf8ByteValuesWorks() + { + IEnumerable utf8ByteValues = [104, 101, 108, 108, 111]; + ChatTokenTopLogProbabilityInfo chatTokenTopLogProbabilityInfo = OpenAIChatModelFactory.ChatTokenTopLogProbabilityInfo(utf8ByteValues: utf8ByteValues); + + Assert.That(chatTokenTopLogProbabilityInfo.Token, Is.Null); + Assert.That(chatTokenTopLogProbabilityInfo.LogProbability, Is.EqualTo(0f)); + Assert.That(chatTokenTopLogProbabilityInfo.Utf8ByteValues.SequenceEqual(utf8ByteValues), Is.True); + } + + [Test] + public void ChatTokenUsageWithNoPropertiesWorks() + { + ChatTokenUsage chatTokenUsage = OpenAIChatModelFactory.ChatTokenUsage(); + + Assert.That(chatTokenUsage.OutputTokens, Is.EqualTo(0)); + Assert.That(chatTokenUsage.InputTokens, Is.EqualTo(0)); + Assert.That(chatTokenUsage.TotalTokens, Is.EqualTo(0)); + } + + [Test] + public void ChatTokenUsageWithOutputTokensWorks() + { + int outputTokens = 271828; + ChatTokenUsage chatTokenUsage = OpenAIChatModelFactory.ChatTokenUsage(outputTokens: outputTokens); + + Assert.That(chatTokenUsage.OutputTokens, Is.EqualTo(outputTokens)); + Assert.That(chatTokenUsage.InputTokens, Is.EqualTo(0)); + Assert.That(chatTokenUsage.TotalTokens, Is.EqualTo(0)); + } + + [Test] + public void ChatTokenUsageWithInputTokensWorks() + { + int inputTokens = 271828; + ChatTokenUsage chatTokenUsage = OpenAIChatModelFactory.ChatTokenUsage(inputTokens: inputTokens); + + Assert.That(chatTokenUsage.OutputTokens, Is.EqualTo(0)); + Assert.That(chatTokenUsage.InputTokens, Is.EqualTo(inputTokens)); + Assert.That(chatTokenUsage.TotalTokens, Is.EqualTo(0)); + } + + [Test] + public void ChatTokenUsageWithTotalTokensWorks() + { + int totalTokens = 271828; + ChatTokenUsage chatTokenUsage = OpenAIChatModelFactory.ChatTokenUsage(totalTokens: totalTokens); + + Assert.That(chatTokenUsage.OutputTokens, Is.EqualTo(0)); + Assert.That(chatTokenUsage.InputTokens, Is.EqualTo(0)); + Assert.That(chatTokenUsage.TotalTokens, Is.EqualTo(totalTokens)); + } + + [Test] + public void StreamingChatCompletionUpdateWithNoPropertiesWorks() + { + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithIdWorks() + { + string id = "chat_completion_id"; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(id: id); + + Assert.That(streamingChatCompletionUpdate.Id, Is.EqualTo(id)); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithContentUpdateWorks() + { + IEnumerable contentUpdate = [ + ChatMessageContentPart.CreateTextMessageContentPart("first part"), + ChatMessageContentPart.CreateTextMessageContentPart("second part") + ]; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(contentUpdate: contentUpdate); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate.SequenceEqual(contentUpdate), Is.True); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithFunctionCallUpdateWorks() + { + StreamingChatFunctionCallUpdate functionCallUpdate = OpenAIChatModelFactory.StreamingChatFunctionCallUpdate(functionName: "get_recipte"); + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(functionCallUpdate: functionCallUpdate); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.EqualTo(functionCallUpdate)); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithToolCallUpdatesWorks() + { + IEnumerable toolCallUpdates = [ + OpenAIChatModelFactory.StreamingChatToolCallUpdate(id: "id1"), + OpenAIChatModelFactory.StreamingChatToolCallUpdate(id: "id2") + ]; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(toolCallUpdates: toolCallUpdates); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates.SequenceEqual(toolCallUpdates), Is.True); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithRoleWorks() + { + ChatMessageRole role = ChatMessageRole.Tool; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(role: role); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.EqualTo(role)); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithRefusalUpdateWorks() + { + string refusalUpdate = "This is a refusal update."; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(refusalUpdate: refusalUpdate); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.EqualTo(refusalUpdate)); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithContentTokenLogProbabilitiesWorks() + { + IEnumerable contentTokenLogProbabilities = [ + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 1f), + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 2f) + ]; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(contentTokenLogProbabilities: contentTokenLogProbabilities); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities.SequenceEqual(contentTokenLogProbabilities), Is.True); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithRefusalTokenLogProbabilitiesWorks() + { + IEnumerable refusalTokenLogProbabilities = [ + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 1f), + OpenAIChatModelFactory.ChatTokenLogProbabilityInfo(logProbability: 2f) + ]; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(refusalTokenLogProbabilities: refusalTokenLogProbabilities); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities.SequenceEqual(refusalTokenLogProbabilities), Is.True); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithFinishReasonWorks() + { + ChatFinishReason finishReason = ChatFinishReason.ToolCalls; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(finishReason: finishReason); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.EqualTo(finishReason)); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithCreatedAtWorks() + { + DateTimeOffset createdAt = DateTimeOffset.UtcNow; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(createdAt: createdAt); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(createdAt)); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithModelWorks() + { + string model = "topmodel"; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(model: model); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.EqualTo(model)); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithSystemFingerprintWorks() + { + string systemFingerprint = "footprint"; + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(systemFingerprint: systemFingerprint); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.EqualTo(systemFingerprint)); + Assert.That(streamingChatCompletionUpdate.Usage, Is.Null); + } + + [Test] + public void StreamingChatCompletionUpdateWithUsageWorks() + { + ChatTokenUsage usage = OpenAIChatModelFactory.ChatTokenUsage(outputTokens: 20); + StreamingChatCompletionUpdate streamingChatCompletionUpdate = OpenAIChatModelFactory.StreamingChatCompletionUpdate(usage: usage); + + Assert.That(streamingChatCompletionUpdate.Id, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentUpdate, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FunctionCallUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ToolCallUpdates, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.Role, Is.Null); + Assert.That(streamingChatCompletionUpdate.RefusalUpdate, Is.Null); + Assert.That(streamingChatCompletionUpdate.ContentTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.RefusalTokenLogProbabilities, Is.Not.Null.And.Empty); + Assert.That(streamingChatCompletionUpdate.FinishReason, Is.Null); + Assert.That(streamingChatCompletionUpdate.CreatedAt, Is.EqualTo(default(DateTimeOffset))); + Assert.That(streamingChatCompletionUpdate.Model, Is.Null); + Assert.That(streamingChatCompletionUpdate.SystemFingerprint, Is.Null); + Assert.That(streamingChatCompletionUpdate.Usage, Is.EqualTo(usage)); + } + + [Test] + public void StreamingChatFunctionCallUpdateWithNoPropertiesWorks() + { + StreamingChatFunctionCallUpdate streamingChatFunctionCallUpdate = OpenAIChatModelFactory.StreamingChatFunctionCallUpdate(); + + Assert.That(streamingChatFunctionCallUpdate.FunctionName, Is.Null); + Assert.That(streamingChatFunctionCallUpdate.FunctionArgumentsUpdate, Is.Null); + } + + [Test] + public void StreamingChatFunctionCallUpdateWithFunctionNameWorks() + { + string functionName = "Margaret"; + StreamingChatFunctionCallUpdate streamingChatFunctionCallUpdate = OpenAIChatModelFactory.StreamingChatFunctionCallUpdate(functionName: functionName); + + Assert.That(streamingChatFunctionCallUpdate.FunctionName, Is.EqualTo(functionName)); + Assert.That(streamingChatFunctionCallUpdate.FunctionArgumentsUpdate, Is.Null); + } + + [Test] + public void StreamingChatFunctionCallUpdateWithFunctionArgumentsUpdateWorks() + { + string functionArgumentsUpdate = "arguments_update"; + StreamingChatFunctionCallUpdate streamingChatFunctionCallUpdate = OpenAIChatModelFactory.StreamingChatFunctionCallUpdate(functionArgumentsUpdate: functionArgumentsUpdate); + + Assert.That(streamingChatFunctionCallUpdate.FunctionName, Is.Null); + Assert.That(streamingChatFunctionCallUpdate.FunctionArgumentsUpdate, Is.EqualTo(functionArgumentsUpdate)); + } + + [Test] + public void StreamingChatToolCallUpdateWithNoPropertiesWorks() + { + StreamingChatToolCallUpdate streamingChatToolCallUpdate = OpenAIChatModelFactory.StreamingChatToolCallUpdate(); + + Assert.That(streamingChatToolCallUpdate.Index, Is.EqualTo(0)); + Assert.That(streamingChatToolCallUpdate.Id, Is.Null); + Assert.That(streamingChatToolCallUpdate.Kind, Is.EqualTo(default(ChatToolCallKind))); + Assert.That(streamingChatToolCallUpdate.FunctionName, Is.Null); + Assert.That(streamingChatToolCallUpdate.FunctionArgumentsUpdate, Is.Null); + } + + [Test] + public void StreamingChatToolCallUpdateWithIndexWorks() + { + int index = 31415; + StreamingChatToolCallUpdate streamingChatToolCallUpdate = OpenAIChatModelFactory.StreamingChatToolCallUpdate(index: index); + + Assert.That(streamingChatToolCallUpdate.Index, Is.EqualTo(index)); + Assert.That(streamingChatToolCallUpdate.Id, Is.Null); + Assert.That(streamingChatToolCallUpdate.Kind, Is.EqualTo(default(ChatToolCallKind))); + Assert.That(streamingChatToolCallUpdate.FunctionName, Is.Null); + Assert.That(streamingChatToolCallUpdate.FunctionArgumentsUpdate, Is.Null); + } + + [Test] + public void StreamingChatToolCallUpdateWithIdWorks() + { + string id = "tool_call_id"; + StreamingChatToolCallUpdate streamingChatToolCallUpdate = OpenAIChatModelFactory.StreamingChatToolCallUpdate(id: id); + + Assert.That(streamingChatToolCallUpdate.Index, Is.EqualTo(0)); + Assert.That(streamingChatToolCallUpdate.Id, Is.EqualTo(id)); + Assert.That(streamingChatToolCallUpdate.Kind, Is.EqualTo(default(ChatToolCallKind))); + Assert.That(streamingChatToolCallUpdate.FunctionName, Is.Null); + Assert.That(streamingChatToolCallUpdate.FunctionArgumentsUpdate, Is.Null); + } + + [Test] + public void StreamingChatToolCallUpdateWithKindWorks() + { + ChatToolCallKind kind = ChatToolCallKind.Function; + StreamingChatToolCallUpdate streamingChatToolCallUpdate = OpenAIChatModelFactory.StreamingChatToolCallUpdate(kind: kind); + + Assert.That(streamingChatToolCallUpdate.Index, Is.EqualTo(0)); + Assert.That(streamingChatToolCallUpdate.Id, Is.Null); + Assert.That(streamingChatToolCallUpdate.Kind, Is.EqualTo(kind)); + Assert.That(streamingChatToolCallUpdate.FunctionName, Is.Null); + Assert.That(streamingChatToolCallUpdate.FunctionArgumentsUpdate, Is.Null); + } + + [Test] + public void StreamingChatToolCallUpdateWithFunctionNameWorks() + { + string functionName = "Margaret"; + StreamingChatToolCallUpdate streamingChatToolCallUpdate = OpenAIChatModelFactory.StreamingChatToolCallUpdate(functionName: functionName); + + Assert.That(streamingChatToolCallUpdate.Index, Is.EqualTo(0)); + Assert.That(streamingChatToolCallUpdate.Id, Is.Null); + Assert.That(streamingChatToolCallUpdate.Kind, Is.EqualTo(default(ChatToolCallKind))); + Assert.That(streamingChatToolCallUpdate.FunctionName, Is.EqualTo(functionName)); + Assert.That(streamingChatToolCallUpdate.FunctionArgumentsUpdate, Is.Null); + } + + [Test] + public void StreamingChatToolCallUpdateWithFunctionArgumentsUpdateWorks() + { + string functionArgumentsUpdate = "arguments_update"; + StreamingChatToolCallUpdate streamingChatToolCallUpdate = OpenAIChatModelFactory.StreamingChatToolCallUpdate(functionArgumentsUpdate: functionArgumentsUpdate); + + Assert.That(streamingChatToolCallUpdate.Index, Is.EqualTo(0)); + Assert.That(streamingChatToolCallUpdate.Id, Is.Null); + Assert.That(streamingChatToolCallUpdate.Kind, Is.EqualTo(default(ChatToolCallKind))); + Assert.That(streamingChatToolCallUpdate.FunctionName, Is.Null); + Assert.That(streamingChatToolCallUpdate.FunctionArgumentsUpdate, Is.EqualTo(functionArgumentsUpdate)); + } +} diff --git a/tests/Embeddings/EmbeddingTests.cs b/tests/Embeddings/EmbeddingTests.cs index 94ebfe8b..d69719e2 100644 --- a/tests/Embeddings/EmbeddingTests.cs +++ b/tests/Embeddings/EmbeddingTests.cs @@ -39,7 +39,7 @@ public async Task GenerateSingleEmbedding() Assert.That(embedding.Index, Is.EqualTo(0)); Assert.That(embedding.Vector, Is.Not.Null); Assert.That(embedding.Vector.Span.Length, Is.EqualTo(1536)); - + float[] array = embedding.Vector.ToArray(); Assert.That(array.Length, Is.EqualTo(1536)); } diff --git a/tests/Embeddings/OpenAIEmbeddingsModelFactoryTests.cs b/tests/Embeddings/OpenAIEmbeddingsModelFactoryTests.cs index b57e80f5..9a43a9e5 100644 --- a/tests/Embeddings/OpenAIEmbeddingsModelFactoryTests.cs +++ b/tests/Embeddings/OpenAIEmbeddingsModelFactoryTests.cs @@ -31,7 +31,7 @@ public void EmbeddingWithIndexWorks() [Test] public void EmbeddingWithVectorWorks() { - IEnumerable vector = [ 1f, 2f, 3f ]; + IEnumerable vector = [1f, 2f, 3f]; Embedding embedding = OpenAIEmbeddingsModelFactory.Embedding(vector: vector); Assert.That(embedding.Index, Is.EqualTo(default(int))); diff --git a/tests/Telemetry/ChatTelemetryTests.cs b/tests/Telemetry/ChatTelemetryTests.cs index d3b043a7..58d4cd64 100644 --- a/tests/Telemetry/ChatTelemetryTests.cs +++ b/tests/Telemetry/ChatTelemetryTests.cs @@ -186,7 +186,7 @@ public async Task ChatTracingAndMetricsMultiple() var tasks = new Task[5]; int numberOfSuccessfulResponses = 3; int totalPromptTokens = 0, totalCompletionTokens = 0; - for (int i = 0; i < tasks.Length; i ++) + for (int i = 0; i < tasks.Length; i++) { int t = i; // don't let Activity.Current escape the scope diff --git a/tests/Telemetry/TestMeterListener.cs b/tests/Telemetry/TestMeterListener.cs index b918beb7..a8a5cdc0 100644 --- a/tests/Telemetry/TestMeterListener.cs +++ b/tests/Telemetry/TestMeterListener.cs @@ -11,8 +11,8 @@ internal class TestMeterListener : IDisposable { public record TestMeasurement(object value, Dictionary tags); - private readonly ConcurrentDictionary> _measurements = new (); - private readonly ConcurrentDictionary _instruments = new (); + private readonly ConcurrentDictionary> _measurements = new(); + private readonly ConcurrentDictionary _instruments = new(); private readonly MeterListener _listener; public TestMeterListener(string meterName) { @@ -46,8 +46,8 @@ private void OnMeasurementRecorded(Instrument instrument, T measurement, Read _instruments.TryAdd(instrument.Name, instrument); var testMeasurement = new TestMeasurement(measurement, new Dictionary(tags.ToArray())); - _measurements.AddOrUpdate(instrument.Name, - k => new() { testMeasurement }, + _measurements.AddOrUpdate(instrument.Name, + k => new() { testMeasurement }, (k, l) => { l.Add(testMeasurement); diff --git a/tests/Utility/TestHelpers.cs b/tests/Utility/TestHelpers.cs index 9fb30f47..cb563a77 100644 --- a/tests/Utility/TestHelpers.cs +++ b/tests/Utility/TestHelpers.cs @@ -57,7 +57,7 @@ public static T GetTestClient(TestScenario scenario, string overrideModel = n TestScenario.Batch => new BatchClient(credential, options), TestScenario.Chat => new ChatClient(overrideModel ?? "gpt-4o-mini", credential, options), TestScenario.Embeddings => new EmbeddingClient(overrideModel ?? "text-embedding-3-small", credential, options), - TestScenario.Files => new FileClient(credential,options), + TestScenario.Files => new FileClient(credential, options), TestScenario.Images => new ImageClient(overrideModel ?? "dall-e-3", credential, options), TestScenario.Models => new ModelClient(credential, options), TestScenario.Moderations => new ModerationClient(overrideModel ?? "text-moderation-stable", credential, options),