diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ac81cfc..660b12e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Release History +## 2.0.0-beta.5 (Unreleased) + +## Features Added + +- API updates, current to [openai/openai-openapi@dd73070b](https://github.com/openai/openai-openapi/commit/dd73070b1d507645d24c249a63ebebd3ec38c0cb) () + - This includes `MaxResults` for Assistants `FileSearchToolDefinition`, `ParallelToolCallsEnabled` for function tools in Assistants and Chat, and `FileChunkingStrategy` for Assistants VectorStores + +## Breaking Changes + +**Assistants**: +- `InputQuote` is removed from Assistants `TextAnnotation` and `TextAnnotationUpdate`, per [openai/openai-openapi@dd73070b](https://github.com/openai/openai-openapi/commit/dd73070b1d507645d24c249a63ebebd3ec38c0cb) () + ## 2.0.0-beta.4 (2024-06-10) ## Features Added diff --git a/api/api.md b/api/api.md index ab555406..3cf12f0d 100644 --- a/api/api.md +++ b/api/api.md @@ -229,6 +229,7 @@ namespace OpenAI.Assistants { public IDictionary Metadata { get; } public string ModelOverride { get; init; } public float? NucleusSamplingFactor { get; init; } + public bool? ParallelToolCallsEnabled { get; init; } public AssistantResponseFormat ResponseFormat { get; init; } public float? Temperature { get; init; } public ToolConstraint ToolConstraint { get; init; } @@ -292,6 +293,7 @@ namespace OpenAI.Assistants { } public class FileSearchToolDefinition : ToolDefinition { public FileSearchToolDefinition(); + public int? MaxResults { get; init; } } public class FileSearchToolResources { public FileSearchToolResources(); @@ -368,7 +370,6 @@ namespace OpenAI.Assistants { public class MessageTextContentAnnotation { public int EndIndex { get; } public string InputFileId { get; } - public string InputQuote { get; } public string OutputFileId { get; } public int StartIndex { get; } public string TextToReplace { get; } @@ -563,7 +564,6 @@ namespace OpenAI.Assistants { public class TextAnnotation { public int EndIndex { get; } public string InputFileId { get; } - public string InputQuote { get; } public string OutputFileId { get; } public int StartIndex { get; } public string TextToReplace { get; } @@ -572,13 +572,13 @@ namespace OpenAI.Assistants { public int ContentIndex { get; } public int? EndIndex { get; } public string InputFileId { get; } - public string InputQuote { get; } public string OutputFileId { get; } public int? StartIndex { get; } public string TextToReplace { get; } } public class ThreadInitializationMessage : MessageCreationOptions { public ThreadInitializationMessage(IEnumerable content); + public static implicit operator ThreadInitializationMessage(string initializationMessage); } public class ThreadMessage { public string AssistantId { get; } @@ -611,6 +611,7 @@ namespace OpenAI.Assistants { public IReadOnlyDictionary Metadata { get; } public string Model { get; } public float? NucleusSamplingFactor { get; } + public bool? ParallelToolCallsEnabled { get; init; } public IReadOnlyList RequiredActions { get; } public AssistantResponseFormat ResponseFormat { get; } public DateTimeOffset? StartedAt { get; } @@ -635,9 +636,10 @@ namespace OpenAI.Assistants { public static ToolConstraint Required { get; } } public abstract class ToolDefinition { + protected ToolDefinition(string type); protected ToolDefinition(); public static CodeInterpreterToolDefinition CreateCodeInterpreter(); - public static FileSearchToolDefinition CreateFileSearch(); + public static FileSearchToolDefinition CreateFileSearch(int? maxResults = null); public static FunctionToolDefinition CreateFunction(string name, string description = null, BinaryData parameters = null); } public class ToolOutput { @@ -839,11 +841,15 @@ namespace OpenAI.Chat { protected ChatClient(); public virtual ClientPipeline Pipeline { get; } public virtual ClientResult CompleteChat(IEnumerable messages, ChatCompletionOptions options = null); + public virtual ClientResult CompleteChat(params ChatMessage[] messages); public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null); public virtual Task> CompleteChatAsync(IEnumerable messages, ChatCompletionOptions options = null); + public virtual Task> CompleteChatAsync(params ChatMessage[] messages); public virtual Task CompleteChatAsync(BinaryContent content, RequestOptions options = null); public virtual ResultCollection CompleteChatStreaming(IEnumerable messages, ChatCompletionOptions options = null); + public virtual ResultCollection CompleteChatStreaming(params ChatMessage[] messages); public virtual AsyncResultCollection CompleteChatStreamingAsync(IEnumerable messages, ChatCompletionOptions options = null); + public virtual AsyncResultCollection CompleteChatStreamingAsync(params ChatMessage[] messages); } public class ChatCompletionOptions { public ChatCompletionOptions(); @@ -853,6 +859,7 @@ namespace OpenAI.Chat { public bool? IncludeLogProbabilities { get; init; } public IDictionary LogitBiases { get; } public int? MaxTokens { get; init; } + public bool? ParallelToolCallsEnabled { get; init; } public float? PresencePenalty { get; init; } public ChatResponseFormat ResponseFormat { get; init; } public long? Seed { get; init; } @@ -885,6 +892,7 @@ namespace OpenAI.Chat { public string SystemFingerprint { get; } public IReadOnlyList ToolCalls { get; } public ChatTokenUsage Usage { get; } + public override string ToString(); } [Obsolete("This field is marked as deprecated.")] public class ChatFunction { @@ -916,6 +924,7 @@ namespace OpenAI.Chat { public static UserChatMessage CreateUserMessage(string content); public static UserChatMessage CreateUserMessage(IEnumerable contentParts); public static UserChatMessage CreateUserMessage(params ChatMessageContentPart[] contentParts); + public static implicit operator ChatMessage(string userMessage); } public class ChatMessageContentPart { public BinaryData ImageBytes { get; } @@ -927,6 +936,8 @@ namespace OpenAI.Chat { public static ChatMessageContentPart CreateImageMessageContentPart(Uri imageUri, ImageChatMessageContentPartDetail? imageDetail = null); public static ChatMessageContentPart CreateImageMessageContentPart(BinaryData imageBytes, string imageBytesMediaType, ImageChatMessageContentPartDetail? imageDetail = null); public static ChatMessageContentPart CreateTextMessageContentPart(string text); + public static implicit operator ChatMessageContentPart(string content); + public override string ToString(); } public readonly struct ChatMessageContentPartKind : IEquatable { public ChatMessageContentPartKind(string value); @@ -1481,6 +1492,7 @@ namespace OpenAI.VectorStores { } public class VectorStoreCreationOptions { public VectorStoreCreationOptions(); + public FileChunkingStrategy ChunkingStrategy { get; init; } public VectorStoreExpirationPolicy ExpirationPolicy { get; init; } public IList FileIds { get; init; } public IDictionary Metadata { get; } @@ -1492,6 +1504,17 @@ namespace OpenAI.VectorStores { public IDictionary Metadata { get; } public string Name { get; init; } } + public abstract class FileChunkingStrategy { + protected FileChunkingStrategy(); + public static FileChunkingStrategy Auto { get; } + public static FileChunkingStrategy Unknown { get; } + public static FileChunkingStrategy CreateStaticStrategy(int maxTokensPerChunk, int overlappingTokenCount); + } + public class StaticFileChunkingStrategy : FileChunkingStrategy { + public StaticFileChunkingStrategy(int maxTokensPerChunk, int overlappingTokenCount); + public int MaxTokensPerChunk { get; } + public int OverlappingTokenCount { get; } + } public class VectorStore { public DateTimeOffset CreatedAt { get; } public VectorStoreExpirationPolicy ExpirationPolicy { get; } @@ -1533,6 +1556,7 @@ namespace OpenAI.VectorStores { public required int Days { get; init; } } public class VectorStoreFileAssociation { + public FileChunkingStrategy ChunkingStrategy { get; } public DateTimeOffset CreatedAt { get; } public string FileId { get; } public VectorStoreFileAssociationError? LastError { get; } diff --git a/examples/Assistants/Example02_FunctionCalling.cs b/examples/Assistants/Example02_FunctionCalling.cs index c1cd91ca..a6049137 100644 --- a/examples/Assistants/Example02_FunctionCalling.cs +++ b/examples/Assistants/Example02_FunctionCalling.cs @@ -173,7 +173,6 @@ PageableCollection messages foreach (TextAnnotation annotation in contentItem.TextAnnotations) { Console.WriteLine($"* File ID used by file_search: {annotation.InputFileId}"); - Console.WriteLine($"* file_search quote from file: {annotation.InputQuote}"); Console.WriteLine($"* File ID created by code_interpreter: {annotation.OutputFileId}"); Console.WriteLine($"* Text to replace: {annotation.TextToReplace}"); Console.WriteLine($"* Message content index range: {annotation.StartIndex}-{annotation.EndIndex}"); diff --git a/examples/Assistants/Example02_FunctionCallingAsync.cs b/examples/Assistants/Example02_FunctionCallingAsync.cs index 9cbb3de8..08bbd0bd 100644 --- a/examples/Assistants/Example02_FunctionCallingAsync.cs +++ b/examples/Assistants/Example02_FunctionCallingAsync.cs @@ -173,7 +173,6 @@ AsyncPageableCollection messages foreach (TextAnnotation annotation in contentItem.TextAnnotations) { Console.WriteLine($"* File ID used by file_search: {annotation.InputFileId}"); - Console.WriteLine($"* file_search quote from file: {annotation.InputQuote}"); Console.WriteLine($"* File ID created by code_interpreter: {annotation.OutputFileId}"); Console.WriteLine($"* Text to replace: {annotation.TextToReplace}"); Console.WriteLine($"* Message content index range: {annotation.StartIndex}-{annotation.EndIndex}"); diff --git a/examples/Assistants/Example04_AllTheTools.cs b/examples/Assistants/Example04_AllTheTools.cs index 8ffbaa4c..30c8fc9f 100644 --- a/examples/Assistants/Example04_AllTheTools.cs +++ b/examples/Assistants/Example04_AllTheTools.cs @@ -159,7 +159,6 @@ PageableCollection messages foreach (TextAnnotation annotation in contentItem.TextAnnotations) { Console.WriteLine($"* File ID used by file_search: {annotation.InputFileId}"); - Console.WriteLine($"* file_search quote from file: {annotation.InputQuote}"); Console.WriteLine($"* File ID created by code_interpreter: {annotation.OutputFileId}"); Console.WriteLine($"* Text to replace: {annotation.TextToReplace}"); Console.WriteLine($"* Message content index range: {annotation.StartIndex}-{annotation.EndIndex}"); diff --git a/src/Custom/Assistants/AssistantClient.cs b/src/Custom/Assistants/AssistantClient.cs index 542c0e51..a1ab32d2 100644 --- a/src/Custom/Assistants/AssistantClient.cs +++ b/src/Custom/Assistants/AssistantClient.cs @@ -968,6 +968,7 @@ private static BinaryContent CreateThreadAndRunProtocolContent( runOptions.MaxCompletionTokens, runOptions.TruncationStrategy, runOptions.ToolConstraint, + runOptions.ParallelToolCallsEnabled, runOptions.ResponseFormat, serializedAdditionalRawData: null); return internalRequest.ToBinaryContent(); diff --git a/src/Custom/Assistants/FileSearchToolDefinition.cs b/src/Custom/Assistants/FileSearchToolDefinition.cs new file mode 100644 index 00000000..cfad3e72 --- /dev/null +++ b/src/Custom/Assistants/FileSearchToolDefinition.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Assistants; + +[CodeGenModel("AssistantToolsFileSearch")] +[CodeGenSuppress(nameof(FileSearchToolDefinition))] +public partial class FileSearchToolDefinition : ToolDefinition +{ + public int? MaxResults + { + get => _fileSearch.InternalMaxNumResults; + init => _fileSearch.InternalMaxNumResults = value; + } + + /// + /// Creates a new instance of . + /// + public FileSearchToolDefinition() + : base("file_search") + { + _fileSearch = new InternalAssistantToolsFileSearchFileSearch(); + } + + [CodeGenMember("FileSearch")] + private InternalAssistantToolsFileSearchFileSearch _fileSearch; +} diff --git a/src/Custom/Assistants/FunctionToolDefinition.cs b/src/Custom/Assistants/FunctionToolDefinition.cs index 3587d3b0..862af47e 100644 --- a/src/Custom/Assistants/FunctionToolDefinition.cs +++ b/src/Custom/Assistants/FunctionToolDefinition.cs @@ -39,14 +39,17 @@ public BinaryData Parameters /// [SetsRequiredMembers] public FunctionToolDefinition(string name, string description = null, BinaryData parameters = null) - : this("function", null, new InternalFunctionDefinition(description, name, parameters, null)) - {} + : base("function") + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + _internalFunction = new(description, name, parameters, null); + } /// /// Creates a new instance of . /// public FunctionToolDefinition() - : base("function", null) + : base("function") { _internalFunction = new InternalFunctionDefinition(); } diff --git a/src/Custom/Assistants/GeneratorStubs.cs b/src/Custom/Assistants/GeneratorStubs.cs index 671e6539..ab1bb1ff 100644 --- a/src/Custom/Assistants/GeneratorStubs.cs +++ b/src/Custom/Assistants/GeneratorStubs.cs @@ -8,9 +8,6 @@ [CodeGenModel("AssistantToolsCode")] public partial class CodeInterpreterToolDefinition : ToolDefinition { } -[CodeGenModel("AssistantToolsFileSearch")] -public partial class FileSearchToolDefinition : ToolDefinition { } - [CodeGenModel("ThreadMessageStatus")] public readonly partial struct MessageStatus { } diff --git a/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs b/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs index ecf4929a..a842463a 100644 --- a/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs +++ b/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs @@ -420,4 +420,7 @@ internal partial class InternalThreadObjectToolResources { } internal partial class InternalThreadObjectToolResourcesCodeInterpreter { } [CodeGenModel("ThreadObjectToolResourcesFileSearch")] -internal partial class InternalThreadObjectToolResourcesFileSearch { } \ No newline at end of file +internal partial class InternalThreadObjectToolResourcesFileSearch { } + +[CodeGenModel("AssistantToolsFileSearchTypeOnly")] +internal readonly partial struct InternalAssistantToolsFileSearchTypeOnly { } \ No newline at end of file diff --git a/src/Custom/Assistants/Internal/InternalAssistantToolsFileSearchFileSearch.cs b/src/Custom/Assistants/Internal/InternalAssistantToolsFileSearchFileSearch.cs new file mode 100644 index 00000000..781f98db --- /dev/null +++ b/src/Custom/Assistants/Internal/InternalAssistantToolsFileSearchFileSearch.cs @@ -0,0 +1,8 @@ +namespace OpenAI.Assistants; + +[CodeGenModel("AssistantToolsFileSearchFileSearch")] +internal partial class InternalAssistantToolsFileSearchFileSearch +{ + [CodeGenMember("MaxNumResults")] + internal int? InternalMaxNumResults { get; set; } +} \ No newline at end of file diff --git a/src/Custom/Assistants/MessageTextContentAnnotation.cs b/src/Custom/Assistants/MessageTextContentAnnotation.cs index ea4199e5..5903fc92 100644 --- a/src/Custom/Assistants/MessageTextContentAnnotation.cs +++ b/src/Custom/Assistants/MessageTextContentAnnotation.cs @@ -5,12 +5,6 @@ public class MessageTextContentAnnotation private readonly MessageContentTextAnnotationsFileCitationObject _fileSearchCitation; private readonly MessageContentTextAnnotationsFilePathObject _codeCitation; - /// - /// The specific quote cited from the file identified by , as generated by the - /// file_search tool. - /// - public string InputQuote => _fileSearchCitation?.FileCitation?.Quote; - /// /// The ID of the file cited by the file_search tool for this annotation. /// diff --git a/src/Custom/Assistants/RunCreationOptions.cs b/src/Custom/Assistants/RunCreationOptions.cs index 5487cda9..820fef20 100644 --- a/src/Custom/Assistants/RunCreationOptions.cs +++ b/src/Custom/Assistants/RunCreationOptions.cs @@ -66,6 +66,15 @@ private set } } + /// + /// Whether to enable parallel function calling during tool use. + /// + /// + /// Assumed true if not otherwise specified. + /// + [CodeGenMember("ParallelToolCalls")] + public bool? ParallelToolCallsEnabled { get; init; } + /// /// A run-specific collection of tool definitions that will override the assistant-level defaults. If not provided, /// the assistant's defined tools will be used. Available tools include: diff --git a/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs b/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs index 4b8498cf..f36c388e 100644 --- a/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs +++ b/src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs @@ -7,12 +7,6 @@ public class TextAnnotationUpdate /// public int ContentIndex => _fileSearchCitation?.Index ?? _codeCitation?.Index ?? -1; - /// - /// The specific quote cited from the file identified by , as generated by the - /// file_search tool. - /// - public string InputQuote => _fileSearchCitation?.FileCitation?.Quote; - /// /// The ID of the file cited by the file_search tool for this annotation. /// diff --git a/src/Custom/Assistants/TextAnnotation.cs b/src/Custom/Assistants/TextAnnotation.cs index 8eac6ec3..4a63f5d4 100644 --- a/src/Custom/Assistants/TextAnnotation.cs +++ b/src/Custom/Assistants/TextAnnotation.cs @@ -5,12 +5,6 @@ public class TextAnnotation private readonly MessageContentTextAnnotationsFileCitationObject _fileSearchCitation; private readonly MessageContentTextAnnotationsFilePathObject _codeCitation; - /// - /// The specific quote cited from the file identified by , as generated by the - /// file_search tool. - /// - public string InputQuote => _fileSearchCitation?.FileCitation?.Quote; - /// /// The ID of the file cited by the file_search tool for this annotation. /// diff --git a/src/Custom/Assistants/ThreadRun.cs b/src/Custom/Assistants/ThreadRun.cs index 63801281..ace76316 100644 --- a/src/Custom/Assistants/ThreadRun.cs +++ b/src/Custom/Assistants/ThreadRun.cs @@ -44,4 +44,14 @@ public partial class ThreadRun /// [CodeGenMember("TopP")] public float? NucleusSamplingFactor { get; } + + /// + /// Whether parallel function calling is enabled during tool use for the thread. + /// + /// + /// Assumed true if not otherwise specified. + /// + [CodeGenMember("ParallelToolCalls")] + public bool? ParallelToolCallsEnabled { get; init; } + } diff --git a/src/Custom/Assistants/ToolDefinition.cs b/src/Custom/Assistants/ToolDefinition.cs index adfe572b..ddedfdf1 100644 --- a/src/Custom/Assistants/ToolDefinition.cs +++ b/src/Custom/Assistants/ToolDefinition.cs @@ -7,8 +7,18 @@ public abstract partial class ToolDefinition { public static CodeInterpreterToolDefinition CreateCodeInterpreter() => new CodeInterpreterToolDefinition(); - public static FileSearchToolDefinition CreateFileSearch() - => new FileSearchToolDefinition(); + public static FileSearchToolDefinition CreateFileSearch(int? maxResults = null) + { + return new FileSearchToolDefinition() + { + MaxResults = maxResults + }; + } public static FunctionToolDefinition CreateFunction(string name, string description = null, BinaryData parameters = null) => new FunctionToolDefinition(name, description, parameters); + + protected ToolDefinition(string type) + { + Type = type; + } } diff --git a/src/Custom/Chat/ChatCompletionOptions.cs b/src/Custom/Chat/ChatCompletionOptions.cs index d3e34232..12f474f1 100644 --- a/src/Custom/Chat/ChatCompletionOptions.cs +++ b/src/Custom/Chat/ChatCompletionOptions.cs @@ -101,4 +101,13 @@ public ChatCompletionOptions() /// [CodeGenMember("FunctionCall")] public ChatFunctionChoice FunctionChoice { get; init; } + + /// + /// Whether to enable parallel function calling during tool use. + /// + /// + /// Assumed true if not otherwise specified. + /// + [CodeGenMember("ParallelToolCalls")] + public bool? ParallelToolCallsEnabled { get; init; } } \ No newline at end of file diff --git a/src/Custom/Chat/ChatMessage.Serialization.cs b/src/Custom/Chat/ChatMessage.Serialization.cs index d8940478..5bcd0aef 100644 --- a/src/Custom/Chat/ChatMessage.Serialization.cs +++ b/src/Custom/Chat/ChatMessage.Serialization.cs @@ -10,13 +10,13 @@ namespace OpenAI.Chat; public abstract partial class ChatMessage : IJsonModel { [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) + internal void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) { throw new NotImplementedException(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void DeserializeContentValue(JsonProperty property, ref IList content, ModelReaderWriterOptions options = null) + internal static void DeserializeContentValue(JsonProperty property, ref IList content, ModelReaderWriterOptions options = null) { throw new NotImplementedException(); } diff --git a/src/Custom/FineTuning/Internal/GeneratorStubs.cs b/src/Custom/FineTuning/Internal/GeneratorStubs.cs index 0083584d..01c6201b 100644 --- a/src/Custom/FineTuning/Internal/GeneratorStubs.cs +++ b/src/Custom/FineTuning/Internal/GeneratorStubs.cs @@ -80,3 +80,23 @@ internal partial class InternalListPaginatedFineTuningJobsResponse { } [CodeGenModel("ListPaginatedFineTuningJobsResponseObject")] internal readonly partial struct InternalListPaginatedFineTuningJobsResponseObject { } +[CodeGenModel("FinetuneCompletionRequestInput")] +internal partial class InternalFinetuneCompletionRequestInput { } + +[CodeGenModel("FinetuneChatRequestInput")] +internal partial class InternalFinetuneChatRequestInput { } + +[CodeGenModel("FineTuneChatCompletionRequestAssistantMessage")] +internal partial class InternalFineTuneChatCompletionRequestAssistantMessage { } + +[CodeGenModel("FineTuneChatCompletionRequestAssistantMessageFunctionCall")] +internal partial class InternalFineTuneChatCompletionRequestAssistantMessageFunctionCall { } + +[CodeGenModel("FineTuneChatCompletionRequestAssistantMessageRole")] +internal readonly partial struct InternalFineTuneChatCompletionRequestAssistantMessageRole { } + +[CodeGenModel("FineTuneChatCompletionRequestAssistantMessageWeight")] +internal readonly partial struct InternalFineTuneChatCompletionRequestAssistantMessageWeight { } + +[CodeGenModel("FineTuneChatCompletionRequestFunctionMessage")] +internal partial class InternalFineTuneChatCompletionRequestFunctionMessage { } diff --git a/src/Custom/VectorStores/FileChunkingStrategy.cs b/src/Custom/VectorStores/FileChunkingStrategy.cs new file mode 100644 index 00000000..0f642d66 --- /dev/null +++ b/src/Custom/VectorStores/FileChunkingStrategy.cs @@ -0,0 +1,36 @@ +namespace OpenAI.VectorStores; + +[CodeGenModel("FileChunkingStrategyResponseParam")] +public abstract partial class FileChunkingStrategy +{ + /// + /// Gets a value representing the default, automatic selection for a file chunking strategy. + /// + /// + /// This value is only valid on vector store requests. response instances + /// will report the concrete chunking strategy applied after automatic selection. + /// + public static FileChunkingStrategy Auto => _autoValue ??= new(); + + /// + /// Gets a value representing the other, unknown strategy type. + /// + /// + /// This value is present on responses when no chunking strategy could be found. This is typically only true for + /// vector stores created earlier than file chunking strategy availability. + /// + public static FileChunkingStrategy Unknown => _unknownValue ??= new(); + + /// + public static FileChunkingStrategy CreateStaticStrategy( + int maxTokensPerChunk, + int overlappingTokenCount) + { + return new StaticFileChunkingStrategy( + maxTokensPerChunk, + overlappingTokenCount); + } + + private static InternalAutoChunkingStrategy _autoValue; + private static InternalUnknownChunkingStrategy _unknownValue; +} diff --git a/src/Custom/VectorStores/Internal/GeneratorStubs.cs b/src/Custom/VectorStores/Internal/GeneratorStubs.cs index c61519ad..3fa00a75 100644 --- a/src/Custom/VectorStores/Internal/GeneratorStubs.cs +++ b/src/Custom/VectorStores/Internal/GeneratorStubs.cs @@ -42,4 +42,28 @@ internal readonly partial struct InternalVectorStoreFileBatchObjectObject { } internal readonly partial struct InternalVectorStoreFileObjectObject { } [CodeGenModel("VectorStoreObjectObject")] -internal readonly partial struct InternalVectorStoreObjectObject { } \ No newline at end of file +internal readonly partial struct InternalVectorStoreObjectObject { } + +[CodeGenModel("StaticChunkingStrategy")] +internal partial class InternalStaticChunkingStrategyDetails { } + +[CodeGenModel("FileChunkingStrategyRequestParam")] +internal partial class InternalFileChunkingStrategyRequestParam { } + +[CodeGenModel("AutoChunkingStrategyRequestParam")] +internal partial class InternalAutoChunkingStrategyRequestParam { } + +[CodeGenModel("StaticChunkingStrategyRequestParam")] +internal partial class InternalStaticChunkingStrategyRequestParam { } + +[CodeGenModel("UnknownFileChunkingStrategyRequestParam")] +internal partial class InternalUnknownFileChunkingStrategyRequestParamProxy { } + +[CodeGenModel("AutoChunkingStrategyResponseParam")] +internal partial class InternalAutoChunkingStrategy { } + +[CodeGenModel("OtherChunkingStrategyResponseParam")] +internal partial class InternalUnknownChunkingStrategy { } + +[CodeGenModel("UnknownFileChunkingStrategyResponseParam")] +internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy { } diff --git a/src/Custom/VectorStores/Internal/InternalCreateVectorStoreFileRequest.cs b/src/Custom/VectorStores/Internal/InternalCreateVectorStoreFileRequest.cs new file mode 100644 index 00000000..338a848e --- /dev/null +++ b/src/Custom/VectorStores/Internal/InternalCreateVectorStoreFileRequest.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores; + +internal partial class InternalCreateVectorStoreFileRequest +{ + [CodeGenMember("ChunkingStrategy")] + public FileChunkingStrategy ChunkingStrategy { get; set; } +} diff --git a/src/Custom/VectorStores/StaticFileChunkingStrategy.cs b/src/Custom/VectorStores/StaticFileChunkingStrategy.cs new file mode 100644 index 00000000..035f5cc6 --- /dev/null +++ b/src/Custom/VectorStores/StaticFileChunkingStrategy.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores; + +[CodeGenModel("StaticChunkingStrategyResponseParam")] +public partial class StaticFileChunkingStrategy : FileChunkingStrategy +{ + [CodeGenMember("Static")] + private InternalStaticChunkingStrategyDetails _internalDetails; + + /// + /// The maximum size of a file chunk, in tokens. + /// + /// + /// If not otherwise specified, a default of 800 will be used. + /// + public int MaxTokensPerChunk => _internalDetails.MaxChunkSizeTokens; + /// + /// The number of shared, overlapping tokens allowed between chunks. + /// + /// + /// + /// This value may not exceed half of . + /// + /// If not otherwise specified, a default of 400 will be used. + /// + public int OverlappingTokenCount => _internalDetails.ChunkOverlapTokens; + + /// + /// Creates a new instance of , which allows for direct specification of + /// file chunk size and chunk overlap windows. + /// + /// + /// + public StaticFileChunkingStrategy(int maxTokensPerChunk, int overlappingTokenCount) + : this(new InternalStaticChunkingStrategyDetails(maxTokensPerChunk, overlappingTokenCount)) + {} +} diff --git a/src/Custom/VectorStores/VectorStoreCreationOptions.cs b/src/Custom/VectorStores/VectorStoreCreationOptions.cs index 195898ed..26d71d60 100644 --- a/src/Custom/VectorStores/VectorStoreCreationOptions.cs +++ b/src/Custom/VectorStores/VectorStoreCreationOptions.cs @@ -11,4 +11,7 @@ public partial class VectorStoreCreationOptions /// Gets or sets the policy that controls when the new vector store will be automatically deleted. [CodeGenMember("ExpiresAfter")] public VectorStoreExpirationPolicy ExpirationPolicy { get; init; } + + [CodeGenMember("ChunkingStrategy")] + public FileChunkingStrategy ChunkingStrategy { get; init; } } diff --git a/src/Custom/VectorStores/VectorStoreFileAssociation.cs b/src/Custom/VectorStores/VectorStoreFileAssociation.cs index cb8bb630..5d0513f1 100644 --- a/src/Custom/VectorStores/VectorStoreFileAssociation.cs +++ b/src/Custom/VectorStores/VectorStoreFileAssociation.cs @@ -23,4 +23,7 @@ public partial class VectorStoreFileAssociation /// [CodeGenMember("UsageBytes")] public int Size { get; } + + [CodeGenMember("ChunkingStrategy")] + public FileChunkingStrategy ChunkingStrategy { get; } } \ No newline at end of file diff --git a/src/Generated/Models/AssistantToolsFileSearchTypeOnlyType.cs b/src/Generated/Models/AssistantToolsFileSearchTypeOnlyType.cs new file mode 100644 index 00000000..5993c76e --- /dev/null +++ b/src/Generated/Models/AssistantToolsFileSearchTypeOnlyType.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace OpenAI.Internal.Models +{ + internal readonly partial struct AssistantToolsFileSearchTypeOnlyType : IEquatable + { + private readonly string _value; + + public AssistantToolsFileSearchTypeOnlyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FileSearchValue = "file_search"; + + public static AssistantToolsFileSearchTypeOnlyType FileSearch { get; } = new AssistantToolsFileSearchTypeOnlyType(FileSearchValue); + public static bool operator ==(AssistantToolsFileSearchTypeOnlyType left, AssistantToolsFileSearchTypeOnlyType right) => left.Equals(right); + public static bool operator !=(AssistantToolsFileSearchTypeOnlyType left, AssistantToolsFileSearchTypeOnlyType right) => !left.Equals(right); + public static implicit operator AssistantToolsFileSearchTypeOnlyType(string value) => new AssistantToolsFileSearchTypeOnlyType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantToolsFileSearchTypeOnlyType other && Equals(other); + public bool Equals(AssistantToolsFileSearchTypeOnlyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + public override string ToString() => _value; + } +} diff --git a/src/Generated/Models/ChatCompletionOptions.Serialization.cs b/src/Generated/Models/ChatCompletionOptions.Serialization.cs index 10d42d6b..8d63136d 100644 --- a/src/Generated/Models/ChatCompletionOptions.Serialization.cs +++ b/src/Generated/Models/ChatCompletionOptions.Serialization.cs @@ -199,6 +199,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW writer.WritePropertyName("tool_choice"u8); writer.WriteObjectValue(ToolChoice, options); } + if (Optional.IsDefined(ParallelToolCallsEnabled)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + } if (Optional.IsDefined(User)) { writer.WritePropertyName("user"u8); @@ -275,6 +280,7 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme float? topP = default; IList tools = default; ChatToolChoice toolChoice = default; + bool? parallelToolCalls = default; string user = default; ChatFunctionChoice functionCall = default; IList functions = default; @@ -449,6 +455,15 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme toolChoice = ChatToolChoice.DeserializeChatToolChoice(property.Value, options); continue; } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parallelToolCalls = property.Value.GetBoolean(); + continue; + } if (property.NameEquals("user"u8)) { user = property.Value.GetString(); @@ -502,6 +517,7 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme topP, tools ?? new ChangeTrackingList(), toolChoice, + parallelToolCalls, user, functionCall, functions ?? new ChangeTrackingList(), diff --git a/src/Generated/Models/ChatCompletionOptions.cs b/src/Generated/Models/ChatCompletionOptions.cs index b9da717b..c4ac90b9 100644 --- a/src/Generated/Models/ChatCompletionOptions.cs +++ b/src/Generated/Models/ChatCompletionOptions.cs @@ -12,7 +12,7 @@ public partial class ChatCompletionOptions { internal IDictionary _serializedAdditionalRawData; - internal ChatCompletionOptions(IList messages, InternalCreateChatCompletionRequestModel model, float? frequencyPenalty, IDictionary logitBiases, bool? includeLogProbabilities, int? topLogProbabilityCount, int? maxTokens, int? n, float? presencePenalty, ChatResponseFormat responseFormat, long? seed, IList stopSequences, bool? stream, InternalChatCompletionStreamOptions streamOptions, float? temperature, float? topP, IList tools, ChatToolChoice toolChoice, string user, ChatFunctionChoice functionChoice, IList functions, IDictionary serializedAdditionalRawData) + internal ChatCompletionOptions(IList messages, InternalCreateChatCompletionRequestModel model, float? frequencyPenalty, IDictionary logitBiases, bool? includeLogProbabilities, int? topLogProbabilityCount, int? maxTokens, int? n, float? presencePenalty, ChatResponseFormat responseFormat, long? seed, IList stopSequences, bool? stream, InternalChatCompletionStreamOptions streamOptions, float? temperature, float? topP, IList tools, ChatToolChoice toolChoice, bool? parallelToolCallsEnabled, string user, ChatFunctionChoice functionChoice, IList functions, IDictionary serializedAdditionalRawData) { Messages = messages; Model = model; @@ -32,6 +32,7 @@ internal ChatCompletionOptions(IList messages, InternalCreateChatCo TopP = topP; Tools = tools; ToolChoice = toolChoice; + ParallelToolCallsEnabled = parallelToolCallsEnabled; User = user; FunctionChoice = functionChoice; Functions = functions; diff --git a/src/Generated/Models/FileChunkingStrategy.Serialization.cs b/src/Generated/Models/FileChunkingStrategy.Serialization.cs new file mode 100644 index 00000000..46818ec4 --- /dev/null +++ b/src/Generated/Models/FileChunkingStrategy.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + [PersistableModelProxy(typeof(InternalUnknownFileChunkingStrategyResponseParamProxy))] + public partial class FileChunkingStrategy : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } + + internal static FileChunkingStrategy DeserializeFileChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "auto": return InternalAutoChunkingStrategy.DeserializeInternalAutoChunkingStrategy(element, options); + case "other": return InternalUnknownChunkingStrategy.DeserializeInternalUnknownChunkingStrategy(element, options); + case "static": return StaticFileChunkingStrategy.DeserializeStaticFileChunkingStrategy(element, options); + } + } + return InternalUnknownFileChunkingStrategyResponseParamProxy.DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{options.Format}' format."); + } + } + + FileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FileChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileChunkingStrategy(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/FileChunkingStrategy.cs b/src/Generated/Models/FileChunkingStrategy.cs new file mode 100644 index 00000000..60538187 --- /dev/null +++ b/src/Generated/Models/FileChunkingStrategy.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + public abstract partial class FileChunkingStrategy + { + private protected IDictionary _serializedAdditionalRawData; + + protected FileChunkingStrategy() + { + } + + internal FileChunkingStrategy(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + internal string Type { get; init; } + } +} diff --git a/src/Generated/Models/FileSearchToolDefinition.Serialization.cs b/src/Generated/Models/FileSearchToolDefinition.Serialization.cs index 88c6fa03..8a0e5f63 100644 --- a/src/Generated/Models/FileSearchToolDefinition.Serialization.cs +++ b/src/Generated/Models/FileSearchToolDefinition.Serialization.cs @@ -21,6 +21,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead } writer.WriteStartObject(); + if (Optional.IsDefined(_fileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(_fileSearch, options); + } writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); if (true && _serializedAdditionalRawData != null) @@ -61,11 +66,21 @@ internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(Jso { return null; } + InternalAssistantToolsFileSearchFileSearch fileSearch = default; string type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = InternalAssistantToolsFileSearchFileSearch.DeserializeInternalAssistantToolsFileSearchFileSearch(property.Value, options); + continue; + } if (property.NameEquals("type"u8)) { type = property.Value.GetString(); @@ -77,7 +92,7 @@ internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(Jso } } serializedAdditionalRawData = rawDataDictionary; - return new FileSearchToolDefinition(type, serializedAdditionalRawData); + return new FileSearchToolDefinition(type, serializedAdditionalRawData, fileSearch); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/src/Generated/Models/FileSearchToolDefinition.cs b/src/Generated/Models/FileSearchToolDefinition.cs index f7a75019..a91be72a 100644 --- a/src/Generated/Models/FileSearchToolDefinition.cs +++ b/src/Generated/Models/FileSearchToolDefinition.cs @@ -9,13 +9,9 @@ namespace OpenAI.Assistants { public partial class FileSearchToolDefinition : ToolDefinition { - public FileSearchToolDefinition() - { - Type = "file_search"; - } - - internal FileSearchToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + internal FileSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalAssistantToolsFileSearchFileSearch fileSearch) : base(type, serializedAdditionalRawData) { + _fileSearch = fileSearch; } } } diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.Serialization.cs b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.Serialization.cs new file mode 100644 index 00000000..3d285d4a --- /dev/null +++ b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.Assistants +{ + internal partial class InternalAssistantToolsFileSearchFileSearch : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(InternalMaxNumResults)) + { + writer.WritePropertyName("max_num_results"u8); + writer.WriteNumberValue(InternalMaxNumResults.Value); + } + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalAssistantToolsFileSearchFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement, options); + } + + internal static InternalAssistantToolsFileSearchFileSearch DeserializeInternalAssistantToolsFileSearchFileSearch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxNumResults = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_num_results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxNumResults = property.Value.GetInt32(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantToolsFileSearchFileSearch(maxNumResults, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support writing '{options.Format}' format."); + } + } + + InternalAssistantToolsFileSearchFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalAssistantToolsFileSearchFileSearch FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.cs b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.cs new file mode 100644 index 00000000..1d922c77 --- /dev/null +++ b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Assistants +{ + internal partial class InternalAssistantToolsFileSearchFileSearch + { + internal IDictionary _serializedAdditionalRawData; + + public InternalAssistantToolsFileSearchFileSearch() + { + } + + internal InternalAssistantToolsFileSearchFileSearch(int? internalMaxNumResults, IDictionary serializedAdditionalRawData) + { + InternalMaxNumResults = internalMaxNumResults; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + } +} diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.Serialization.cs b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.Serialization.cs new file mode 100644 index 00000000..ba4a8c83 --- /dev/null +++ b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI.Internal.Models; + +namespace OpenAI.Internal.Assistants +{ + internal partial struct InternalAssistantToolsFileSearchTypeOnly : IJsonModel, IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalAssistantToolsFileSearchTypeOnly IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement, options); + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)this).Write(writer, options); + + object IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)this).Create(ref reader, options); + + internal static InternalAssistantToolsFileSearchTypeOnly DeserializeInternalAssistantToolsFileSearchTypeOnly(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + AssistantToolsFileSearchTypeOnlyType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new AssistantToolsFileSearchTypeOnlyType(property.Value.GetString()); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantToolsFileSearchTypeOnly(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support writing '{options.Format}' format."); + } + } + + InternalAssistantToolsFileSearchTypeOnly IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ((IPersistableModel)this).Write(options); + + object IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ((IPersistableModel)this).Create(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)this).GetFormatFromOptions(options); + + internal static InternalAssistantToolsFileSearchTypeOnly FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement); + } + + internal BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.cs b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.cs new file mode 100644 index 00000000..c84929a8 --- /dev/null +++ b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI.Internal.Models; + +namespace OpenAI.Internal.Assistants +{ + internal readonly partial struct InternalAssistantToolsFileSearchTypeOnly + { + private readonly IDictionary _serializedAdditionalRawData; + + public InternalAssistantToolsFileSearchTypeOnly(AssistantToolsFileSearchTypeOnlyType type) + { + Type = type; + } + + internal InternalAssistantToolsFileSearchTypeOnly(AssistantToolsFileSearchTypeOnlyType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + public InternalAssistantToolsFileSearchTypeOnly() + { + } + + public AssistantToolsFileSearchTypeOnlyType Type { get; } = AssistantToolsFileSearchTypeOnlyType.FileSearch; + } +} diff --git a/src/Generated/Models/InternalAutoChunkingStrategy.Serialization.cs b/src/Generated/Models/InternalAutoChunkingStrategy.Serialization.cs new file mode 100644 index 00000000..5ec90783 --- /dev/null +++ b/src/Generated/Models/InternalAutoChunkingStrategy.Serialization.cs @@ -0,0 +1,125 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + internal partial class InternalAutoChunkingStrategy : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalAutoChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAutoChunkingStrategy(document.RootElement, options); + } + + internal static InternalAutoChunkingStrategy DeserializeInternalAutoChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAutoChunkingStrategy(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support writing '{options.Format}' format."); + } + } + + InternalAutoChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAutoChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalAutoChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAutoChunkingStrategy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalAutoChunkingStrategy.cs b/src/Generated/Models/InternalAutoChunkingStrategy.cs new file mode 100644 index 00000000..737fe05c --- /dev/null +++ b/src/Generated/Models/InternalAutoChunkingStrategy.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal partial class InternalAutoChunkingStrategy : FileChunkingStrategy + { + internal InternalAutoChunkingStrategy() + { + Type = "auto"; + } + + internal InternalAutoChunkingStrategy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.Serialization.cs b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.Serialization.cs new file mode 100644 index 00000000..e9c4669f --- /dev/null +++ b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.Serialization.cs @@ -0,0 +1,125 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + internal partial class InternalAutoChunkingStrategyRequestParam : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalAutoChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement, options); + } + + internal static InternalAutoChunkingStrategyRequestParam DeserializeInternalAutoChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAutoChunkingStrategyRequestParam(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); + } + } + + InternalAutoChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalAutoChunkingStrategyRequestParam FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.cs b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.cs new file mode 100644 index 00000000..3b429d3e --- /dev/null +++ b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal partial class InternalAutoChunkingStrategyRequestParam : InternalFileChunkingStrategyRequestParam + { + public InternalAutoChunkingStrategyRequestParam() + { + Type = "auto"; + } + + internal InternalAutoChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs b/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs index 7026c0f2..3c826f8a 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs @@ -183,6 +183,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, writer.WriteNull("tool_choice"); } } + if (Optional.IsDefined(ParallelToolCalls)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls.Value); + } if (Optional.IsDefined(ResponseFormat)) { if (ResponseFormat != null) @@ -247,6 +252,7 @@ internal static InternalCreateThreadAndRunRequest DeserializeInternalCreateThrea int? maxCompletionTokens = default; RunTruncationStrategy truncationStrategy = default; ToolConstraint toolChoice = default; + bool? parallelToolCalls = default; AssistantResponseFormat responseFormat = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -394,6 +400,15 @@ internal static InternalCreateThreadAndRunRequest DeserializeInternalCreateThrea toolChoice = ToolConstraint.DeserializeToolConstraint(property.Value, options); continue; } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parallelToolCalls = property.Value.GetBoolean(); + continue; + } if (property.NameEquals("response_format"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -425,6 +440,7 @@ internal static InternalCreateThreadAndRunRequest DeserializeInternalCreateThrea maxCompletionTokens, truncationStrategy, toolChoice, + parallelToolCalls, responseFormat, serializedAdditionalRawData); } diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequest.cs b/src/Generated/Models/InternalCreateThreadAndRunRequest.cs index c6f10ace..63980b82 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequest.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequest.cs @@ -20,7 +20,7 @@ public InternalCreateThreadAndRunRequest(string assistantId) Metadata = new ChangeTrackingDictionary(); } - internal InternalCreateThreadAndRunRequest(string assistantId, ThreadCreationOptions thread, string model, string instructions, IList tools, ToolResources toolResources, IDictionary metadata, float? temperature, float? topP, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolChoice, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + internal InternalCreateThreadAndRunRequest(string assistantId, ThreadCreationOptions thread, string model, string instructions, IList tools, ToolResources toolResources, IDictionary metadata, float? temperature, float? topP, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolChoice, bool? parallelToolCalls, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) { AssistantId = assistantId; Thread = thread; @@ -36,6 +36,7 @@ internal InternalCreateThreadAndRunRequest(string assistantId, ThreadCreationOpt MaxCompletionTokens = maxCompletionTokens; TruncationStrategy = truncationStrategy; ToolChoice = toolChoice; + ParallelToolCalls = parallelToolCalls; ResponseFormat = responseFormat; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -55,5 +56,6 @@ internal InternalCreateThreadAndRunRequest() public int? MaxPromptTokens { get; set; } public int? MaxCompletionTokens { get; set; } public RunTruncationStrategy TruncationStrategy { get; set; } + public bool? ParallelToolCalls { get; set; } } } diff --git a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs index 73c144dc..bd173b9f 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs @@ -28,6 +28,18 @@ void IJsonModel.Write(Utf8JsonWriter writer.WriteStringValue(item); } writer.WriteEndArray(); + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ChunkingStrategy); +#else + using (JsonDocument document = JsonDocument.Parse(ChunkingStrategy)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } if (true && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -67,6 +79,7 @@ internal static InternalCreateVectorStoreFileBatchRequest DeserializeInternalCre return null; } IList fileIds = default; + BinaryData chunkingStrategy = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -81,13 +94,22 @@ internal static InternalCreateVectorStoreFileBatchRequest DeserializeInternalCre fileIds = array; continue; } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = BinaryData.FromString(property.Value.GetRawText()); + continue; + } if (true) { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateVectorStoreFileBatchRequest(fileIds, serializedAdditionalRawData); + return new InternalCreateVectorStoreFileBatchRequest(fileIds, chunkingStrategy, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs index 76a9f7fb..d0bd0d83 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs @@ -19,9 +19,10 @@ public InternalCreateVectorStoreFileBatchRequest(IEnumerable fileIds) FileIds = fileIds.ToList(); } - internal InternalCreateVectorStoreFileBatchRequest(IList fileIds, IDictionary serializedAdditionalRawData) + internal InternalCreateVectorStoreFileBatchRequest(IList fileIds, BinaryData chunkingStrategy, IDictionary serializedAdditionalRawData) { FileIds = fileIds; + ChunkingStrategy = chunkingStrategy; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -30,5 +31,6 @@ internal InternalCreateVectorStoreFileBatchRequest() } public IList FileIds { get; } + public BinaryData ChunkingStrategy { get; set; } } } diff --git a/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs b/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs index 322f8d2d..72f7af32 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs @@ -23,6 +23,11 @@ void IJsonModel.Write(Utf8JsonWriter write writer.WriteStartObject(); writer.WritePropertyName("file_id"u8); writer.WriteStringValue(FileId); + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } if (true && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -62,6 +67,7 @@ internal static InternalCreateVectorStoreFileRequest DeserializeInternalCreateVe return null; } string fileId = default; + FileChunkingStrategy chunkingStrategy = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -71,13 +77,22 @@ internal static InternalCreateVectorStoreFileRequest DeserializeInternalCreateVe fileId = property.Value.GetString(); continue; } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); + continue; + } if (true) { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateVectorStoreFileRequest(fileId, serializedAdditionalRawData); + return new InternalCreateVectorStoreFileRequest(fileId, chunkingStrategy, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs b/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs index f901b481..0aaf19fc 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs @@ -18,9 +18,10 @@ public InternalCreateVectorStoreFileRequest(string fileId) FileId = fileId; } - internal InternalCreateVectorStoreFileRequest(string fileId, IDictionary serializedAdditionalRawData) + internal InternalCreateVectorStoreFileRequest(string fileId, FileChunkingStrategy chunkingStrategy, IDictionary serializedAdditionalRawData) { FileId = fileId; + ChunkingStrategy = chunkingStrategy; _serializedAdditionalRawData = serializedAdditionalRawData; } diff --git a/src/Generated/Models/InternalFileChunkingStrategyRequestParam.Serialization.cs b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.Serialization.cs new file mode 100644 index 00000000..a203498c --- /dev/null +++ b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.Serialization.cs @@ -0,0 +1,117 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + [PersistableModelProxy(typeof(InternalUnknownFileChunkingStrategyRequestParamProxy))] + internal partial class InternalFileChunkingStrategyRequestParam : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalFileChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } + + internal static InternalFileChunkingStrategyRequestParam DeserializeInternalFileChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "auto": return InternalAutoChunkingStrategyRequestParam.DeserializeInternalAutoChunkingStrategyRequestParam(element, options); + case "static": return InternalStaticChunkingStrategyRequestParam.DeserializeInternalStaticChunkingStrategyRequestParam(element, options); + } + } + return InternalUnknownFileChunkingStrategyRequestParamProxy.DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); + } + } + + InternalFileChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFileChunkingStrategyRequestParam FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalFileChunkingStrategyRequestParam.cs b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.cs new file mode 100644 index 00000000..0ecf2703 --- /dev/null +++ b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal abstract partial class InternalFileChunkingStrategyRequestParam + { + private protected IDictionary _serializedAdditionalRawData; + + protected InternalFileChunkingStrategyRequestParam() + { + } + + internal InternalFileChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + internal string Type { get; set; } + } +} diff --git a/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs new file mode 100644 index 00000000..ba8506f4 --- /dev/null +++ b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs @@ -0,0 +1,202 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI.Chat; + +namespace OpenAI.Internal.FineTuning +{ + internal partial class InternalFineTuneChatCompletionRequestAssistantMessage : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ParticipantName)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(ParticipantName); + } + if (Optional.IsCollectionDefined(ToolCalls)) + { + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(FunctionCall)) + { + if (FunctionCall != null) + { + writer.WritePropertyName("function_call"u8); + writer.WriteObjectValue(FunctionCall, options); + } + else + { + writer.WriteNull("function_call"); + } + } + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role); + if (Optional.IsCollectionDefined(Content)) + { + writer.WritePropertyName("content"u8); + SerializeContentValue(writer); + } + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalFineTuneChatCompletionRequestAssistantMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement, options); + } + + internal static InternalFineTuneChatCompletionRequestAssistantMessage DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IList toolCalls = default; + ChatFunctionCall functionCall = default; + string role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatToolCall.DeserializeChatToolCall(item, options)); + } + toolCalls = array; + continue; + } + if (property.NameEquals("function_call"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + functionCall = null; + continue; + } + functionCall = ChatFunctionCall.DeserializeChatFunctionCall(property.Value, options); + continue; + } + if (property.NameEquals("role"u8)) + { + role = property.Value.GetString(); + continue; + } + if (property.NameEquals("content"u8)) + { + DeserializeContentValue(property, ref content); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFineTuneChatCompletionRequestAssistantMessage( + role, + content ?? new ChangeTrackingList(), + serializedAdditionalRawData, + name, + toolCalls ?? new ChangeTrackingList(), + functionCall); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support writing '{options.Format}' format."); + } + } + + InternalFineTuneChatCompletionRequestAssistantMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalFineTuneChatCompletionRequestAssistantMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs new file mode 100644 index 00000000..30d11dae --- /dev/null +++ b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI.Chat; + +namespace OpenAI.Internal.FineTuning +{ + internal partial class InternalFineTuneChatCompletionRequestAssistantMessage : AssistantChatMessage + { + public InternalFineTuneChatCompletionRequestAssistantMessage() + { + } + + internal InternalFineTuneChatCompletionRequestAssistantMessage(string role, IList content, IDictionary serializedAdditionalRawData, string participantName, IList toolCalls, ChatFunctionCall functionCall) : base(role, content, serializedAdditionalRawData, participantName, toolCalls, functionCall) + { + } + } +} diff --git a/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs b/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs new file mode 100644 index 00000000..c9c7c274 --- /dev/null +++ b/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs @@ -0,0 +1,227 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI.Chat; + +namespace OpenAI.Internal.FineTuning +{ + internal partial class InternalFinetuneChatRequestInput : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Messages)) + { + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ParallelToolCalls)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls.Value); + } + if (Optional.IsCollectionDefined(Functions)) + { + writer.WritePropertyName("functions"u8); + writer.WriteStartArray(); + foreach (var item in Functions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalFinetuneChatRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); + } + + internal static InternalFinetuneChatRequestInput DeserializeInternalFinetuneChatRequestInput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList messages = default; + IReadOnlyList tools = default; + bool? parallelToolCalls = default; + IReadOnlyList functions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + messages = array; + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatTool.DeserializeChatTool(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("functions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatFunction.DeserializeChatFunction(item, options)); + } + functions = array; + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFinetuneChatRequestInput(messages ?? new ChangeTrackingList(), tools ?? new ChangeTrackingList(), parallelToolCalls, functions ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{options.Format}' format."); + } + } + + InternalFinetuneChatRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFinetuneChatRequestInput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFinetuneChatRequestInput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalFinetuneChatRequestInput.cs b/src/Generated/Models/InternalFinetuneChatRequestInput.cs new file mode 100644 index 00000000..31815039 --- /dev/null +++ b/src/Generated/Models/InternalFinetuneChatRequestInput.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI.Chat; + +namespace OpenAI.Internal.FineTuning +{ + internal partial class InternalFinetuneChatRequestInput + { + internal IDictionary _serializedAdditionalRawData; + + internal InternalFinetuneChatRequestInput() + { + Messages = new ChangeTrackingList(); + Tools = new ChangeTrackingList(); + Functions = new ChangeTrackingList(); + } + + internal InternalFinetuneChatRequestInput(IReadOnlyList messages, IReadOnlyList tools, bool? parallelToolCalls, IReadOnlyList functions, IDictionary serializedAdditionalRawData) + { + Messages = messages; + Tools = tools; + ParallelToolCalls = parallelToolCalls; + Functions = functions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + public IReadOnlyList Messages { get; } + public IReadOnlyList Tools { get; } + public bool? ParallelToolCalls { get; } + public IReadOnlyList Functions { get; } + } +} diff --git a/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs b/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs new file mode 100644 index 00000000..2de2bf10 --- /dev/null +++ b/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.FineTuning +{ + internal partial class InternalFinetuneCompletionRequestInput : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Completion)) + { + writer.WritePropertyName("completion"u8); + writer.WriteStringValue(Completion); + } + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalFinetuneCompletionRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); + } + + internal static InternalFinetuneCompletionRequestInput DeserializeInternalFinetuneCompletionRequestInput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string prompt = default; + string completion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("prompt"u8)) + { + prompt = property.Value.GetString(); + continue; + } + if (property.NameEquals("completion"u8)) + { + completion = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFinetuneCompletionRequestInput(prompt, completion, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{options.Format}' format."); + } + } + + InternalFinetuneCompletionRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFinetuneCompletionRequestInput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs b/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs new file mode 100644 index 00000000..eb098306 --- /dev/null +++ b/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.FineTuning +{ + internal partial class InternalFinetuneCompletionRequestInput + { + internal IDictionary _serializedAdditionalRawData; + + internal InternalFinetuneCompletionRequestInput() + { + } + + internal InternalFinetuneCompletionRequestInput(string prompt, string completion, IDictionary serializedAdditionalRawData) + { + Prompt = prompt; + Completion = completion; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + public string Prompt { get; } + public string Completion { get; } + } +} diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs index 41848d14..9fc3672f 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs @@ -23,8 +23,6 @@ void IJsonModel serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -74,18 +71,13 @@ internal static InternalMessageContentTextAnnotationsFileCitationObjectFileCitat fileId = property.Value.GetString(); continue; } - if (property.NameEquals("quote"u8)) - { - quote = property.Value.GetString(); - continue; - } if (true) { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(fileId, quote, serializedAdditionalRawData); + return new InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(fileId, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs index d23b8bc4..857b8907 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs @@ -11,19 +11,16 @@ internal partial class InternalMessageContentTextAnnotationsFileCitationObjectFi { internal IDictionary _serializedAdditionalRawData; - public InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId, string quote) + public InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId) { Argument.AssertNotNull(fileId, nameof(fileId)); - Argument.AssertNotNull(quote, nameof(quote)); FileId = fileId; - Quote = quote; } - internal InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId, string quote, IDictionary serializedAdditionalRawData) + internal InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId, IDictionary serializedAdditionalRawData) { FileId = fileId; - Quote = quote; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -32,6 +29,5 @@ internal InternalMessageContentTextAnnotationsFileCitationObjectFileCitation() } public string FileId { get; set; } - public string Quote { get; set; } } } diff --git a/src/Generated/Models/InternalStaticChunkingStrategyDetails.Serialization.cs b/src/Generated/Models/InternalStaticChunkingStrategyDetails.Serialization.cs new file mode 100644 index 00000000..deb8e7f3 --- /dev/null +++ b/src/Generated/Models/InternalStaticChunkingStrategyDetails.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + internal partial class InternalStaticChunkingStrategyDetails : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("max_chunk_size_tokens"u8); + writer.WriteNumberValue(MaxChunkSizeTokens); + writer.WritePropertyName("chunk_overlap_tokens"u8); + writer.WriteNumberValue(ChunkOverlapTokens); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalStaticChunkingStrategyDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement, options); + } + + internal static InternalStaticChunkingStrategyDetails DeserializeInternalStaticChunkingStrategyDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int maxChunkSizeTokens = default; + int chunkOverlapTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_chunk_size_tokens"u8)) + { + maxChunkSizeTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("chunk_overlap_tokens"u8)) + { + chunkOverlapTokens = property.Value.GetInt32(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalStaticChunkingStrategyDetails(maxChunkSizeTokens, chunkOverlapTokens, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalStaticChunkingStrategyDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalStaticChunkingStrategyDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalStaticChunkingStrategyDetails.cs b/src/Generated/Models/InternalStaticChunkingStrategyDetails.cs new file mode 100644 index 00000000..051e4555 --- /dev/null +++ b/src/Generated/Models/InternalStaticChunkingStrategyDetails.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal partial class InternalStaticChunkingStrategyDetails + { + internal IDictionary _serializedAdditionalRawData; + + public InternalStaticChunkingStrategyDetails(int maxChunkSizeTokens, int chunkOverlapTokens) + { + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + } + + internal InternalStaticChunkingStrategyDetails(int maxChunkSizeTokens, int chunkOverlapTokens, IDictionary serializedAdditionalRawData) + { + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalStaticChunkingStrategyDetails() + { + } + + public int MaxChunkSizeTokens { get; set; } + public int ChunkOverlapTokens { get; set; } + } +} diff --git a/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.Serialization.cs b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.Serialization.cs new file mode 100644 index 00000000..881cfebf --- /dev/null +++ b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + internal partial class InternalStaticChunkingStrategyRequestParam : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(Static, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalStaticChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement, options); + } + + internal static InternalStaticChunkingStrategyRequestParam DeserializeInternalStaticChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalStaticChunkingStrategyDetails @static = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) + { + @static = InternalStaticChunkingStrategyDetails.DeserializeInternalStaticChunkingStrategyDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalStaticChunkingStrategyRequestParam(type, serializedAdditionalRawData, @static); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); + } + } + + InternalStaticChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalStaticChunkingStrategyRequestParam FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.cs b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.cs new file mode 100644 index 00000000..2b96bd6e --- /dev/null +++ b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal partial class InternalStaticChunkingStrategyRequestParam : InternalFileChunkingStrategyRequestParam + { + public InternalStaticChunkingStrategyRequestParam(InternalStaticChunkingStrategyDetails @static) + { + Argument.AssertNotNull(@static, nameof(@static)); + + Type = "static"; + Static = @static; + } + + internal InternalStaticChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData, InternalStaticChunkingStrategyDetails @static) : base(type, serializedAdditionalRawData) + { + Static = @static; + } + + internal InternalStaticChunkingStrategyRequestParam() + { + } + + public InternalStaticChunkingStrategyDetails Static { get; } + } +} diff --git a/src/Generated/Models/InternalUnknownChunkingStrategy.Serialization.cs b/src/Generated/Models/InternalUnknownChunkingStrategy.Serialization.cs new file mode 100644 index 00000000..9f9a663d --- /dev/null +++ b/src/Generated/Models/InternalUnknownChunkingStrategy.Serialization.cs @@ -0,0 +1,125 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + internal partial class InternalUnknownChunkingStrategy : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalUnknownChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalUnknownChunkingStrategy(document.RootElement, options); + } + + internal static InternalUnknownChunkingStrategy DeserializeInternalUnknownChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownChunkingStrategy(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support writing '{options.Format}' format."); + } + } + + InternalUnknownChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalUnknownChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownChunkingStrategy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalUnknownChunkingStrategy.cs b/src/Generated/Models/InternalUnknownChunkingStrategy.cs new file mode 100644 index 00000000..c67c751d --- /dev/null +++ b/src/Generated/Models/InternalUnknownChunkingStrategy.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal partial class InternalUnknownChunkingStrategy : FileChunkingStrategy + { + internal InternalUnknownChunkingStrategy() + { + Type = "other"; + } + + internal InternalUnknownChunkingStrategy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.Serialization.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.Serialization.cs new file mode 100644 index 00000000..2f6c829a --- /dev/null +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.Serialization.cs @@ -0,0 +1,125 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + internal partial class InternalUnknownFileChunkingStrategyRequestParamProxy : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalFileChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } + + internal static InternalUnknownFileChunkingStrategyRequestParamProxy DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownFileChunkingStrategyRequestParamProxy(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); + } + } + + InternalFileChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownFileChunkingStrategyRequestParamProxy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.cs new file mode 100644 index 00000000..91f50cab --- /dev/null +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal partial class InternalUnknownFileChunkingStrategyRequestParamProxy : InternalFileChunkingStrategyRequestParam + { + internal InternalUnknownFileChunkingStrategyRequestParamProxy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + internal InternalUnknownFileChunkingStrategyRequestParamProxy() + { + } + } +} diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.Serialization.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.Serialization.cs new file mode 100644 index 00000000..f4b8d85b --- /dev/null +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.Serialization.cs @@ -0,0 +1,125 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } + + internal static InternalUnknownFileChunkingStrategyResponseParamProxy DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownFileChunkingStrategyResponseParamProxy(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{options.Format}' format."); + } + } + + FileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownFileChunkingStrategyResponseParamProxy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.cs new file mode 100644 index 00000000..db5bbec8 --- /dev/null +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy : FileChunkingStrategy + { + internal InternalUnknownFileChunkingStrategyResponseParamProxy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + internal InternalUnknownFileChunkingStrategyResponseParamProxy() + { + } + } +} diff --git a/src/Generated/Models/RunCreationOptions.Serialization.cs b/src/Generated/Models/RunCreationOptions.Serialization.cs index b2a246ca..906ca5c8 100644 --- a/src/Generated/Models/RunCreationOptions.Serialization.cs +++ b/src/Generated/Models/RunCreationOptions.Serialization.cs @@ -195,6 +195,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("tool_choice"); } } + if (Optional.IsDefined(ParallelToolCallsEnabled)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + } if (Optional.IsDefined(ResponseFormat)) { if (ResponseFormat != null) @@ -259,6 +264,7 @@ internal static RunCreationOptions DeserializeRunCreationOptions(JsonElement ele int? maxCompletionTokens = default; RunTruncationStrategy truncationStrategy = default; ToolConstraint toolChoice = default; + bool? parallelToolCalls = default; AssistantResponseFormat responseFormat = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -411,6 +417,15 @@ internal static RunCreationOptions DeserializeRunCreationOptions(JsonElement ele toolChoice = Assistants.ToolConstraint.DeserializeToolConstraint(property.Value, options); continue; } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parallelToolCalls = property.Value.GetBoolean(); + continue; + } if (property.NameEquals("response_format"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -442,6 +457,7 @@ internal static RunCreationOptions DeserializeRunCreationOptions(JsonElement ele maxCompletionTokens, truncationStrategy, toolChoice, + parallelToolCalls, responseFormat, serializedAdditionalRawData); } diff --git a/src/Generated/Models/RunCreationOptions.cs b/src/Generated/Models/RunCreationOptions.cs index 7e5dcbb1..86a41fa8 100644 --- a/src/Generated/Models/RunCreationOptions.cs +++ b/src/Generated/Models/RunCreationOptions.cs @@ -11,7 +11,7 @@ public partial class RunCreationOptions { internal IDictionary _serializedAdditionalRawData; - internal RunCreationOptions(string assistantId, string modelOverride, string instructionsOverride, string additionalInstructions, IList internalMessages, IList toolsOverride, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + internal RunCreationOptions(string assistantId, string modelOverride, string instructionsOverride, string additionalInstructions, IList internalMessages, IList toolsOverride, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) { AssistantId = assistantId; ModelOverride = modelOverride; @@ -27,6 +27,7 @@ internal RunCreationOptions(string assistantId, string modelOverride, string ins MaxCompletionTokens = maxCompletionTokens; TruncationStrategy = truncationStrategy; ToolConstraint = toolConstraint; + ParallelToolCallsEnabled = parallelToolCallsEnabled; ResponseFormat = responseFormat; _serializedAdditionalRawData = serializedAdditionalRawData; } diff --git a/src/Generated/Models/StaticFileChunkingStrategy.Serialization.cs b/src/Generated/Models/StaticFileChunkingStrategy.Serialization.cs new file mode 100644 index 00000000..0d1fcf6f --- /dev/null +++ b/src/Generated/Models/StaticFileChunkingStrategy.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace OpenAI.VectorStores +{ + public partial class StaticFileChunkingStrategy : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(_internalDetails, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (true && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + StaticFileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStaticFileChunkingStrategy(document.RootElement, options); + } + + internal static StaticFileChunkingStrategy DeserializeStaticFileChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalStaticChunkingStrategyDetails @static = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) + { + @static = InternalStaticChunkingStrategyDetails.DeserializeInternalStaticChunkingStrategyDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StaticFileChunkingStrategy(type, serializedAdditionalRawData, @static); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support writing '{options.Format}' format."); + } + } + + StaticFileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStaticFileChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new StaticFileChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeStaticFileChunkingStrategy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/src/Generated/Models/StaticFileChunkingStrategy.cs b/src/Generated/Models/StaticFileChunkingStrategy.cs new file mode 100644 index 00000000..09f4736f --- /dev/null +++ b/src/Generated/Models/StaticFileChunkingStrategy.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.VectorStores +{ + public partial class StaticFileChunkingStrategy : FileChunkingStrategy + { + internal StaticFileChunkingStrategy(InternalStaticChunkingStrategyDetails internalDetails) + { + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "static"; + _internalDetails = internalDetails; + } + + internal StaticFileChunkingStrategy(string type, IDictionary serializedAdditionalRawData, InternalStaticChunkingStrategyDetails internalDetails) : base(type, serializedAdditionalRawData) + { + _internalDetails = internalDetails; + } + + internal StaticFileChunkingStrategy() + { + } + } +} diff --git a/src/Generated/Models/ThreadRun.Serialization.cs b/src/Generated/Models/ThreadRun.Serialization.cs index 6ecfcdf8..bbcfff94 100644 --- a/src/Generated/Models/ThreadRun.Serialization.cs +++ b/src/Generated/Models/ThreadRun.Serialization.cs @@ -200,6 +200,8 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions { writer.WriteNull("tool_choice"); } + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); if (ResponseFormat != null) { writer.WritePropertyName("response_format"u8); @@ -272,6 +274,7 @@ internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderW int? maxCompletionTokens = default; RunTruncationStrategy truncationStrategy = default; ToolConstraint toolChoice = default; + bool? parallelToolCalls = default; AssistantResponseFormat responseFormat = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -502,6 +505,11 @@ internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderW toolChoice = Assistants.ToolConstraint.DeserializeToolConstraint(property.Value, options); continue; } + if (property.NameEquals("parallel_tool_calls"u8)) + { + parallelToolCalls = property.Value.GetBoolean(); + continue; + } if (property.NameEquals("response_format"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -544,6 +552,7 @@ internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderW maxCompletionTokens, truncationStrategy, toolChoice, + parallelToolCalls, responseFormat, serializedAdditionalRawData); } diff --git a/src/Generated/Models/ThreadRun.cs b/src/Generated/Models/ThreadRun.cs index e50f8e4d..a4e456f5 100644 --- a/src/Generated/Models/ThreadRun.cs +++ b/src/Generated/Models/ThreadRun.cs @@ -12,7 +12,7 @@ public partial class ThreadRun { internal IDictionary _serializedAdditionalRawData; - internal ThreadRun(string id, DateTimeOffset createdAt, string threadId, string assistantId, RunStatus status, InternalRunRequiredAction internalRequiredAction, RunError lastError, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, RunIncompleteDetails incompleteDetails, string model, string instructions, IEnumerable tools, IReadOnlyDictionary metadata, RunTokenUsage usage, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, AssistantResponseFormat responseFormat) + internal ThreadRun(string id, DateTimeOffset createdAt, string threadId, string assistantId, RunStatus status, InternalRunRequiredAction internalRequiredAction, RunError lastError, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, RunIncompleteDetails incompleteDetails, string model, string instructions, IEnumerable tools, IReadOnlyDictionary metadata, RunTokenUsage usage, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat) { Argument.AssertNotNull(id, nameof(id)); Argument.AssertNotNull(threadId, nameof(threadId)); @@ -43,10 +43,11 @@ internal ThreadRun(string id, DateTimeOffset createdAt, string threadId, string MaxCompletionTokens = maxCompletionTokens; TruncationStrategy = truncationStrategy; ToolConstraint = toolConstraint; + ParallelToolCallsEnabled = parallelToolCallsEnabled; ResponseFormat = responseFormat; } - internal ThreadRun(string id, InternalRunObjectObject @object, DateTimeOffset createdAt, string threadId, string assistantId, RunStatus status, InternalRunRequiredAction internalRequiredAction, RunError lastError, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, RunIncompleteDetails incompleteDetails, string model, string instructions, IReadOnlyList tools, IReadOnlyDictionary metadata, RunTokenUsage usage, float? temperature, float? nucleusSamplingFactor, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + internal ThreadRun(string id, InternalRunObjectObject @object, DateTimeOffset createdAt, string threadId, string assistantId, RunStatus status, InternalRunRequiredAction internalRequiredAction, RunError lastError, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, RunIncompleteDetails incompleteDetails, string model, string instructions, IReadOnlyList tools, IReadOnlyDictionary metadata, RunTokenUsage usage, float? temperature, float? nucleusSamplingFactor, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; @@ -73,6 +74,7 @@ internal ThreadRun(string id, InternalRunObjectObject @object, DateTimeOffset cr MaxCompletionTokens = maxCompletionTokens; TruncationStrategy = truncationStrategy; ToolConstraint = toolConstraint; + ParallelToolCallsEnabled = parallelToolCallsEnabled; ResponseFormat = responseFormat; _serializedAdditionalRawData = serializedAdditionalRawData; } diff --git a/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs b/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs index bed0e74f..6f1af224 100644 --- a/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs +++ b/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs @@ -48,6 +48,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe writer.WriteNull("expires_after"); } } + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } if (Optional.IsCollectionDefined(Metadata)) { if (Metadata != null) @@ -107,6 +112,7 @@ internal static VectorStoreCreationOptions DeserializeVectorStoreCreationOptions IList fileIds = default; string name = default; VectorStoreExpirationPolicy expiresAfter = default; + FileChunkingStrategy chunkingStrategy = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -141,6 +147,15 @@ internal static VectorStoreCreationOptions DeserializeVectorStoreCreationOptions expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); continue; } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -161,7 +176,13 @@ internal static VectorStoreCreationOptions DeserializeVectorStoreCreationOptions } } serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreCreationOptions(fileIds ?? new ChangeTrackingList(), name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new VectorStoreCreationOptions( + fileIds ?? new ChangeTrackingList(), + name, + expiresAfter, + chunkingStrategy, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/src/Generated/Models/VectorStoreCreationOptions.cs b/src/Generated/Models/VectorStoreCreationOptions.cs index 27aaf8cb..8ab8faf5 100644 --- a/src/Generated/Models/VectorStoreCreationOptions.cs +++ b/src/Generated/Models/VectorStoreCreationOptions.cs @@ -17,11 +17,12 @@ public VectorStoreCreationOptions() Metadata = new ChangeTrackingDictionary(); } - internal VectorStoreCreationOptions(IList fileIds, string name, VectorStoreExpirationPolicy expirationPolicy, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal VectorStoreCreationOptions(IList fileIds, string name, VectorStoreExpirationPolicy expirationPolicy, FileChunkingStrategy chunkingStrategy, IDictionary metadata, IDictionary serializedAdditionalRawData) { FileIds = fileIds; Name = name; ExpirationPolicy = expirationPolicy; + ChunkingStrategy = chunkingStrategy; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } diff --git a/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs b/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs index 21c1ea86..0b3490d1 100644 --- a/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs +++ b/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs @@ -42,6 +42,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe { writer.WriteNull("last_error"); } + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } if (true && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -87,6 +92,7 @@ internal static VectorStoreFileAssociation DeserializeVectorStoreFileAssociation string vectorStoreId = default; VectorStoreFileAssociationStatus status = default; VectorStoreFileAssociationError? lastError = default; + FileChunkingStrategy chunkingStrategy = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -131,6 +137,15 @@ internal static VectorStoreFileAssociation DeserializeVectorStoreFileAssociation lastError = VectorStoreFileAssociationError.DeserializeVectorStoreFileAssociationError(property.Value, options); continue; } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); + continue; + } if (true) { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -145,6 +160,7 @@ internal static VectorStoreFileAssociation DeserializeVectorStoreFileAssociation vectorStoreId, status, lastError, + chunkingStrategy, serializedAdditionalRawData); } diff --git a/src/Generated/Models/VectorStoreFileAssociation.cs b/src/Generated/Models/VectorStoreFileAssociation.cs index 3cb1bc37..68f11585 100644 --- a/src/Generated/Models/VectorStoreFileAssociation.cs +++ b/src/Generated/Models/VectorStoreFileAssociation.cs @@ -24,7 +24,7 @@ internal VectorStoreFileAssociation(string fileId, int size, DateTimeOffset crea LastError = lastError; } - internal VectorStoreFileAssociation(string fileId, InternalVectorStoreFileObjectObject @object, int size, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileAssociationStatus status, VectorStoreFileAssociationError? lastError, IDictionary serializedAdditionalRawData) + internal VectorStoreFileAssociation(string fileId, InternalVectorStoreFileObjectObject @object, int size, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileAssociationStatus status, VectorStoreFileAssociationError? lastError, FileChunkingStrategy chunkingStrategy, IDictionary serializedAdditionalRawData) { FileId = fileId; Object = @object; @@ -33,6 +33,7 @@ internal VectorStoreFileAssociation(string fileId, InternalVectorStoreFileObject VectorStoreId = vectorStoreId; Status = status; LastError = lastError; + ChunkingStrategy = chunkingStrategy; _serializedAdditionalRawData = serializedAdditionalRawData; } diff --git a/tests/Assistants/AssistantTests.cs b/tests/Assistants/AssistantTests.cs index 6eeb4926..8f8ca41e 100644 --- a/tests/Assistants/AssistantTests.cs +++ b/tests/Assistants/AssistantTests.cs @@ -365,7 +365,7 @@ public void FunctionToolsWork() Assert.That(messages.Count, Is.GreaterThan(1)); Assert.That(messages.First().Role, Is.EqualTo(MessageRole.Assistant)); Assert.That(messages.First().Content?[0], Is.Not.Null); - Assert.That(messages.First().Content[0].Text, Does.Contain("tacos")); + Assert.That(messages.First().Content[0].Text.ToLowerInvariant(), Does.Contain("tacos")); } [Test] @@ -578,7 +578,7 @@ This file describes the favorite foods of several people. Console.WriteLine(content.Text); foreach (TextAnnotation annotation in content.TextAnnotations) { - Console.WriteLine($" --> From file: {annotation.InputFileId}, quote: {annotation.InputQuote}, replacement: {annotation.TextToReplace}"); + Console.WriteLine($" --> From file: {annotation.InputFileId}, replacement: {annotation.TextToReplace}"); } } } diff --git a/tests/Assistants/VectorStoreTests.cs b/tests/Assistants/VectorStoreTests.cs index b151d6bb..8377f7d2 100644 --- a/tests/Assistants/VectorStoreTests.cs +++ b/tests/Assistants/VectorStoreTests.cs @@ -237,6 +237,61 @@ public void CanUseBatchIngestion() } } + public enum ChunkingStrategyKind { Auto, Static } + + [Test] + [TestCase(ChunkingStrategyKind.Auto)] + [TestCase(ChunkingStrategyKind.Static)] + public async Task CanApplyChunkingStrategy(ChunkingStrategyKind strategyKind) + { + IReadOnlyList testFiles = GetNewTestFiles(5); + + VectorStoreClient client = GetTestClient(); + + FileChunkingStrategy chunkingStrategy = strategyKind switch + { + ChunkingStrategyKind.Auto => FileChunkingStrategy.Auto, + ChunkingStrategyKind.Static => FileChunkingStrategy.CreateStaticStrategy(1200, 250), + _ => throw new NotImplementedException(), + }; + + if (chunkingStrategy is StaticFileChunkingStrategy inputStaticStrategy) + { + Assert.That(inputStaticStrategy.MaxTokensPerChunk, Is.EqualTo(1200)); + Assert.That(inputStaticStrategy.OverlappingTokenCount, Is.EqualTo(250)); + } + + VectorStore vectorStore = await client.CreateVectorStoreAsync(new VectorStoreCreationOptions() + { + FileIds = testFiles.Select(file => file.Id).ToList(), + ChunkingStrategy = chunkingStrategy, + }); + Validate(vectorStore); + Assert.That(vectorStore.FileCounts.Total, Is.EqualTo(5)); + + AsyncPageableCollection associations = client.GetFileAssociationsAsync(vectorStore); + + await foreach (VectorStoreFileAssociation association in associations) + { + Assert.That(testFiles.Any(file => file.Id == association.FileId), Is.True); + Assert.That(association.ChunkingStrategy, Is.InstanceOf()); + StaticFileChunkingStrategy staticStrategy = association.ChunkingStrategy as StaticFileChunkingStrategy; + + Assert.That(staticStrategy.MaxTokensPerChunk, Is.EqualTo(strategyKind switch + { + ChunkingStrategyKind.Auto => 800, + ChunkingStrategyKind.Static => 1200, + _ => throw new NotImplementedException() + })); + Assert.That(staticStrategy.OverlappingTokenCount, Is.EqualTo(strategyKind switch + { + ChunkingStrategyKind.Auto => 400, + ChunkingStrategyKind.Static => 250, + _ => throw new NotImplementedException() + })); + } + } + private IReadOnlyList GetNewTestFiles(int count) { List files = []; @@ -254,6 +309,7 @@ private IReadOnlyList GetNewTestFiles(int count) return files; } + [TearDown] protected void Cleanup() { diff --git a/tests/Audio/TranscriptionTests.cs b/tests/Audio/TranscriptionTests.cs index 5961ea40..100877c3 100644 --- a/tests/Audio/TranscriptionTests.cs +++ b/tests/Audio/TranscriptionTests.cs @@ -3,6 +3,7 @@ using OpenAI.Tests.Utility; using System; using System.ClientModel; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; @@ -72,10 +73,14 @@ public async Task TimestampsWork(AudioTimestampGranularities granularityFlags) Granularities = granularityFlags, }; - AudioTranscription transcription = IsAsync + ClientResult transcriptionResult = IsAsync ? await client.TranscribeAudioAsync(inputStream, "audio_hello_world.mp3", options) : client.TranscribeAudio(inputStream, "audio_hello_world.mp3", options); + PipelineResponse rawResponse = transcriptionResult.GetRawResponse(); + Assert.That(rawResponse.Content.ToString(), Is.Not.Null.And.Not.Empty); + + AudioTranscription transcription = transcriptionResult; Assert.That(transcription, Is.Not.Null); IReadOnlyList words = transcription.Words; @@ -114,7 +119,7 @@ public async Task TimestampsWork(AudioTimestampGranularities granularityFlags) Assert.That(segments[i].TokenIds, Is.Not.Null.And.Not.Empty); foreach (int tokenId in segments[i].TokenIds) { - Assert.That(tokenId, Is.GreaterThan(0)); + Assert.That(tokenId, Is.GreaterThanOrEqualTo(0)); } Assert.That(segments[i].Temperature, Is.LessThan(-0.001f).Or.GreaterThan(0.001f)); Assert.That(segments[i].AverageLogProbability, Is.LessThan(-0.001f).Or.GreaterThan(0.001f)); diff --git a/tests/Chat/ChatClientTests.cs b/tests/Chat/ChatClientTests.cs index 284a5b7c..7929d2b7 100644 --- a/tests/Chat/ChatClientTests.cs +++ b/tests/Chat/ChatClientTests.cs @@ -201,20 +201,18 @@ public async Task TwoTurnChat() List messages = [ - new UserChatMessage("What are ten of the most common colors, including the brightest and darkest?"), + new UserChatMessage("In geometry, what are the different kinds of triangles, as defined by lengths of their sides?"), ]; ClientResult firstResult = IsAsync ? await client.CompleteChatAsync(messages) : client.CompleteChat(messages); Assert.That(firstResult?.Value, Is.Not.Null); - Assert.That(firstResult.Value.Content[0].Text.ToLowerInvariant(), Contains.Substring("white")); - Assert.That(firstResult.Value.Content[0].Text.ToLowerInvariant(), Contains.Substring("black")); + Assert.That(firstResult.Value.Content[0].Text.ToLowerInvariant(), Contains.Substring("isosceles")); messages.Add(new AssistantChatMessage(firstResult.Value)); - messages.Add(new UserChatMessage("Which of those are considered brightest, aligning with hexadecimal rgb notation?")); + messages.Add(new UserChatMessage("Which of those is the one where exactly two sides are the same length?")); ClientResult secondResult = client.CompleteChat(messages); Assert.That(secondResult?.Value, Is.Not.Null); - Assert.That(secondResult.Value.Content[0].Text.ToLowerInvariant(), Contains.Substring("white")); - Assert.That(secondResult.Value.Content[0].Text.ToLowerInvariant(), Does.Not.Contains("black")); + Assert.That(secondResult.Value.Content[0].Text.ToLowerInvariant(), Contains.Substring("isosceles")); } [Test]